mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 20:26:19 +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++
|
ct++
|
||||||
md.Reset()
|
md.Reset()
|
||||||
}
|
}
|
||||||
for i := 0; i < len; i++ {
|
k = k[:len]
|
||||||
if k[i] != 0 {
|
var b uint8
|
||||||
return k[:len], true
|
for _, v := range k {
|
||||||
|
b |= v
|
||||||
}
|
}
|
||||||
}
|
return k, int((uint32(b)-1)>>31) != 1
|
||||||
return k, false
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user