Skip to content

Commit dcc600e

Browse files
committed
fix bigUint32
1 parent ef51648 commit dcc600e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cng/hkdf.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package cng
88

99
import (
10+
"encoding/binary"
1011
"errors"
1112
"hash"
1213
"runtime"
@@ -82,7 +83,7 @@ func ExtractHKDF(h func() hash.Hash, secret, salt []byte) ([]byte, error) {
8283
if len(blob) < 4 {
8384
return nil, errors.New("cng: exported key is corrupted")
8485
}
85-
cbHashName := bigUint32(blob)
86+
cbHashName := binary.BigEndian.Uint32(blob)
8687
blob = blob[4:]
8788
if len(blob) < int(cbHashName) {
8889
return nil, errors.New("cng: exported key is corrupted")
@@ -124,5 +125,5 @@ func ExpandHKDF(h func() hash.Hash, pseudorandomKey, info []byte, keyLength int)
124125

125126
func bigUint32(b []byte) uint32 {
126127
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
127-
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
128+
return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
128129
}

0 commit comments

Comments
 (0)