kdf-sm3: fix buffer length issue

This commit is contained in:
Sun Yimin 2024-05-21 15:46:59 +08:00 committed by GitHub
parent dc23026764
commit 53cd7522a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,9 +28,11 @@ func copyResult(result []byte, dig *[8]uint32) {
binary.BigEndian.PutUint32(result[28:], dig[7]) binary.BigEndian.PutUint32(result[28:], dig[7])
} }
// state || words // p || state || words
// 1216 = 68 * 4 * 4 + 8 * 4 * 4 = 76 * 16 // p = 64 * 4 * 2 = 512
const preallocSize = 1216 // state = 8 * 16 = 128
// words = 68 * 16 = 1088
const preallocSize = 1728
func kdfBy4(baseMD *digest, keyLen int, limit int) []byte { func kdfBy4(baseMD *digest, keyLen int, limit int) []byte {
if limit < 4 { if limit < 4 {