mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 12:16:20 +08:00
sm3: kdf constant time check all zero
This commit is contained in:
parent
05aeed5c34
commit
b7cc21a055
10
sm3/sm3.go
10
sm3/sm3.go
@ -225,10 +225,10 @@ func Kdf(z []byte, len int) ([]byte, bool) {
|
||||
ct++
|
||||
md.Reset()
|
||||
}
|
||||
for i := 0; i < len; i++ {
|
||||
if k[i] != 0 {
|
||||
return k[:len], true
|
||||
}
|
||||
k = k[:len]
|
||||
var b uint8
|
||||
for _, v := range k {
|
||||
b |= v
|
||||
}
|
||||
return k, false
|
||||
return k, int((uint32(b)-1)>>31) != 1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user