move nonce generation to separate file

This commit is contained in:
Lucas Clemente
2016-08-01 16:27:38 +02:00
parent 8a9f5f9833
commit 8a08171322
2 changed files with 14 additions and 8 deletions

14
crypto/nonce.go Normal file
View File

@@ -0,0 +1,14 @@
package crypto
import (
"encoding/binary"
"github.com/lucas-clemente/quic-go/protocol"
)
func makeNonce(iv []byte, packetNumber protocol.PacketNumber) []byte {
res := make([]byte, 12)
copy(res[0:4], iv)
binary.LittleEndian.PutUint64(res[4:12], uint64(packetNumber))
return res
}