mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 04:36:19 +08:00
zuc: add comment and fix a bug
This commit is contained in:
parent
7e81d05ce9
commit
1a75fd65ca
@ -117,7 +117,7 @@ func New() hash.Hash {
|
|||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum appends the current hash to b and returns the resulting slice.
|
// Sum appends the current hash to in and returns the resulting slice.
|
||||||
// It does not change the underlying hash state.
|
// It does not change the underlying hash state.
|
||||||
func (d *digest) Sum(in []byte) []byte {
|
func (d *digest) Sum(in []byte) []byte {
|
||||||
// Make a copy of d so that caller can keep writing and summing.
|
// Make a copy of d so that caller can keep writing and summing.
|
||||||
|
@ -206,6 +206,8 @@ func (m *ZUC128Mac) Finish(p []byte, nbits int) []byte {
|
|||||||
return digest[:]
|
return digest[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sum appends the current hash to in and returns the resulting slice.
|
||||||
|
// It does not change the underlying hash state.
|
||||||
func (m *ZUC128Mac) Sum(in []byte) []byte {
|
func (m *ZUC128Mac) Sum(in []byte) []byte {
|
||||||
// Make a copy of d so that caller can keep writing and summing.
|
// Make a copy of d so that caller can keep writing and summing.
|
||||||
d0 := *m
|
d0 := *m
|
||||||
|
@ -231,9 +231,13 @@ func (m *ZUC256Mac) Finish(p []byte, nbits int) []byte {
|
|||||||
return digest[:]
|
return digest[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sum appends the current hash to in and returns the resulting slice.
|
||||||
|
// It does not change the underlying hash state.
|
||||||
func (m *ZUC256Mac) Sum(in []byte) []byte {
|
func (m *ZUC256Mac) Sum(in []byte) []byte {
|
||||||
// Make a copy of d so that caller can keep writing and summing.
|
// Make a copy of d so that caller can keep writing and summing.
|
||||||
d0 := *m
|
d0 := *m
|
||||||
|
d0.t = make([]uint32, len(m.t))
|
||||||
|
copy(d0.t, m.t)
|
||||||
hash := d0.checkSum(0, 0)
|
hash := d0.checkSum(0, 0)
|
||||||
return append(in, hash[:]...)
|
return append(in, hash[:]...)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user