mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
crypto/ecies: move hash.Reset call to end of loop
This makes a difference because the hash is re-used in Encrypt and Decrypt without an additional Reset.
This commit is contained in:
parent
870f40f7ec
commit
3b81617e94
1 changed files with 1 additions and 2 deletions
|
|
@ -143,18 +143,17 @@ var (
|
|||
ErrInvalidMessage = fmt.Errorf("ecies: invalid message")
|
||||
)
|
||||
|
||||
|
||||
// NIST SP 800-56 Concatenation Key Derivation Function (see section 5.8.1).
|
||||
func concatKDF(hash hash.Hash, z, s1 []byte, kdLen int) []byte {
|
||||
counterBytes := make([]byte, 4)
|
||||
k := make([]byte, 0, kdLen+hash.Size())
|
||||
for counter := uint32(1); len(k) < kdLen; counter++ {
|
||||
hash.Reset()
|
||||
binary.BigEndian.PutUint32(counterBytes, counter)
|
||||
hash.Write(counterBytes)
|
||||
hash.Write(z)
|
||||
hash.Write(s1)
|
||||
k = hash.Sum(k)
|
||||
hash.Reset()
|
||||
}
|
||||
return k[:kdLen]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue