fix randomness

This commit is contained in:
Lucas Clemente
2016-04-20 22:23:00 +02:00
parent b3e88f8019
commit bb3c8b707b
3 changed files with 6 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/rand"
"fmt"
"io"
"sync"
"github.com/lucas-clemente/quic-go/crypto"
@@ -37,7 +38,7 @@ var _ crypto.AEAD = &CryptoSetup{}
// NewCryptoSetup creates a new CryptoSetup instance
func NewCryptoSetup(connID protocol.ConnectionID, version protocol.VersionNumber, scfg *ServerConfig, cryptoStream utils.Stream) *CryptoSetup {
nonce := make([]byte, 32)
if _, err := rand.Reader.Read(nonce); err != nil {
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
panic(err)
}
return &CryptoSetup{

View File

@@ -3,6 +3,7 @@ package handshake
import (
"bytes"
"crypto/rand"
"io"
"github.com/lucas-clemente/quic-go/crypto"
)
@@ -17,7 +18,7 @@ type ServerConfig struct {
// NewServerConfig creates a new server config
func NewServerConfig(kex crypto.KeyExchange, signer crypto.Signer) *ServerConfig {
id := make([]byte, 16)
_, err := rand.Reader.Read(id)
_, err := io.ReadFull(rand.Reader, id)
if err != nil {
panic(err)
}