/
gost.go
84 lines (59 loc) · 1.51 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
72
73
74
75
76
77
78
79
80
81
82
83
84
package hash
import (
"crypto/cipher"
"github.com/deatil/go-hash/gost/gost341194"
"github.com/deatil/go-hash/gost/gost34112012"
"github.com/deatil/go-hash/gost/gost34112012256"
"github.com/deatil/go-hash/gost/gost34112012512"
)
// gost341194 签名
func (this Hash) Gost341194(cipher func([]byte) cipher.Block) Hash {
h := gost341194.New(cipher)
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewGost341194
func (this Hash) NewGost341194(cipher func([]byte) cipher.Block) Hash {
this.hash = gost341194.New(cipher)
return this
}
// ===============
// gost34112012 签名
func (this Hash) Gost34112012(size int) Hash {
h := gost34112012.New(size)
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewGost34112012
func (this Hash) NewGost34112012(size int) Hash {
this.hash = gost34112012.New(size)
return this
}
// ===============
// gost34112012256 签名
func (this Hash) Gost34112012256() Hash {
h := gost34112012256.New()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewGost34112012256
func (this Hash) NewGost34112012256() Hash {
this.hash = gost34112012256.New()
return this
}
// ===============
// gost34112012512 签名
func (this Hash) Gost34112012512() Hash {
h := gost34112012512.New()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewGost34112012512
func (this Hash) NewGost34112012512() Hash {
this.hash = gost34112012512.New()
return this
}