mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 12:16:20 +08:00
sm3: kdf, reduce memory allocation times #220
This commit is contained in:
parent
4fe8d28d31
commit
105331f164
@ -220,7 +220,7 @@ func Kdf(z []byte, keyLen int) []byte {
|
|||||||
}
|
}
|
||||||
var countBytes [4]byte
|
var countBytes [4]byte
|
||||||
var ct uint32 = 1
|
var ct uint32 = 1
|
||||||
var k []byte
|
k := make([]byte, keyLen)
|
||||||
baseMD := new(digest)
|
baseMD := new(digest)
|
||||||
baseMD.Reset()
|
baseMD.Reset()
|
||||||
baseMD.Write(z)
|
baseMD.Write(z)
|
||||||
@ -229,8 +229,8 @@ func Kdf(z []byte, keyLen int) []byte {
|
|||||||
md := *baseMD
|
md := *baseMD
|
||||||
md.Write(countBytes[:])
|
md.Write(countBytes[:])
|
||||||
h := md.checkSum()
|
h := md.checkSum()
|
||||||
k = append(k, h[:]...)
|
copy(k[i*Size:], h[:])
|
||||||
ct++
|
ct++
|
||||||
}
|
}
|
||||||
return k[:keyLen]
|
return k
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user