mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
ecies: Fix reps calculation
NIST SP 800-56 specifies that reps should equal: ceil(keydatalen / hashlen) where hashlen is the length, in bits, of the output block of the hash function. In the hash.Hash interface, this value is given by Size() * 8, not BlockSize() * 8. (BlockSize is a confusingly-named method that relates to hash *input*, not output.)
This commit is contained in:
parent
84f4975520
commit
5b6118e7f2
1 changed files with 1 additions and 2 deletions
|
|
@ -169,9 +169,8 @@ func concatKDF(hash hash.Hash, z, s1 []byte, kdLen int) (k []byte, err error) {
|
|||
s1 = make([]byte, 0)
|
||||
}
|
||||
|
||||
reps := ((kdLen + 7) * 8) / (hash.BlockSize() * 8)
|
||||
reps := ((kdLen + 7) * 8) / (hash.Size() * 8)
|
||||
if big.NewInt(int64(reps)).Cmp(big2To32M1) > 0 {
|
||||
fmt.Println(big2To32M1)
|
||||
return nil, ErrKeyDataTooLong
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue