]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/tls/handshake_messages_test.go
[dev.boringcrypto] all: merge master (nearly Go 1.10 beta 1) into dev.boringcrypto
[gostls13.git] / src / crypto / tls / handshake_messages_test.go
index 7f3d03a4634fe3760c354b60a95e2b7126c0cf57..1bf12c9ff245be16936c74cc4e528b3f7a089db9 100644 (file)
@@ -98,8 +98,8 @@ func TestFuzz(t *testing.T) {
 
 func randomBytes(n int, rand *rand.Rand) []byte {
        r := make([]byte, n)
-       for i := 0; i < n; i++ {
-               r[i] = byte(rand.Int31())
+       if _, err := rand.Read(r); err != nil {
+               panic("rand.Read failed: " + err.Error())
        }
        return r
 }
@@ -116,7 +116,11 @@ func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value {
        m.sessionId = randomBytes(rand.Intn(32), rand)
        m.cipherSuites = make([]uint16, rand.Intn(63)+1)
        for i := 0; i < len(m.cipherSuites); i++ {
-               m.cipherSuites[i] = uint16(rand.Int31())
+               cs := uint16(rand.Int31())
+               if cs == scsvRenegotiation {
+                       cs += 1
+               }
+               m.cipherSuites[i] = cs
        }
        m.compressionMethods = randomBytes(rand.Intn(63)+1, rand)
        if rand.Intn(10) > 5 {
@@ -141,7 +145,7 @@ func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value {
                }
        }
        if rand.Intn(10) > 5 {
-               m.signatureAndHashes = supportedSignatureAlgorithms()
+               m.supportedSignatureAlgorithms = supportedSignatureAlgorithms()
        }
        m.alpnProtocols = make([]string, rand.Intn(5))
        for i := range m.alpnProtocols {