mirror of
https://github.com/howmp/reality
synced 2025-02-22 18:12:20 +08:00
fix nonce #3
This commit is contained in:
parent
b29f81307d
commit
9bb9c6d084
2
utils.go
2
utils.go
@ -33,7 +33,7 @@ var seqNumerOne = [8]byte{0, 0, 0, 0, 0, 0, 0, 1}
|
||||
// generateNonce 根据SessionKey和ExpireSecond生成Nonce
|
||||
func generateNonce(NonceSize int, SessionKey []byte, ExpireSecond uint32) ([]byte, error) {
|
||||
info := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(info, uint64(time.Now().Unix()%int64(ExpireSecond)))
|
||||
binary.BigEndian.PutUint64(info, uint64(time.Now().Unix()/int64(ExpireSecond)))
|
||||
nonce := make([]byte, NonceSize)
|
||||
_, err := hkdf.New(sha256.New, SessionKey[:], Prefix, info).Read(nonce[:])
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user