Skip to content

Commit

Permalink
sm3: kdf, reduce memory allocation times #220
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored May 15, 2024
1 parent 4fe8d28 commit 105331f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sm3/sm3.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func Kdf(z []byte, keyLen int) []byte {
}
var countBytes [4]byte
var ct uint32 = 1
var k []byte
k := make([]byte, keyLen)
baseMD := new(digest)
baseMD.Reset()
baseMD.Write(z)
Expand All @@ -229,8 +229,8 @@ func Kdf(z []byte, keyLen int) []byte {
md := *baseMD
md.Write(countBytes[:])
h := md.checkSum()
k = append(k, h[:]...)
copy(k[i*Size:], h[:])
ct++
}
return k[:keyLen]
return k
}

0 comments on commit 105331f

Please sign in to comment.