-
Notifications
You must be signed in to change notification settings - Fork 25
/
gost.go
71 lines (55 loc) · 1 KB
/
gost.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package gost
import (
"hash"
"github.com/deatil/go-cryptobin/gost"
"github.com/deatil/go-cryptobin/hash/gost/gost34112012256"
)
type (
// HashFunc
HashFunc = func() hash.Hash
)
/**
* Gost
*
* @create 2024-2-25
* @author deatil
*/
type Gost struct {
// 私钥
privateKey *gost.PrivateKey
// 公钥
publicKey *gost.PublicKey
// 生成类型
curve *gost.Curve
// 签名验证类型
signHash HashFunc
// [私钥/公钥]数据
keyData []byte
// 传入数据
data []byte
// 解析后的数据
parsedData []byte
// 密码数据
secretData []byte
// 验证结果
verify bool
// 错误
Errors []error
}
// 构造函数
func NewGost() Gost {
return Gost{
curve: gost.CurveDefault(),
signHash: gost34112012256.New,
verify: false,
Errors: make([]error, 0),
}
}
// 构造函数
func New() Gost {
return NewGost()
}
var (
// 默认
defaultGost = NewGost()
)