OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package tls | 5 package tls |
6 | 6 |
7 import ( | 7 import ( |
8 "math/rand" | 8 "math/rand" |
9 "reflect" | 9 "reflect" |
10 "testing" | 10 "testing" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 if rand.Intn(10) > 5 { | 132 if rand.Intn(10) > 5 { |
133 m.ticketSupported = true | 133 m.ticketSupported = true |
134 if rand.Intn(10) > 5 { | 134 if rand.Intn(10) > 5 { |
135 m.sessionTicket = randomBytes(rand.Intn(300), rand) | 135 m.sessionTicket = randomBytes(rand.Intn(300), rand) |
136 } | 136 } |
137 } | 137 } |
138 if rand.Intn(10) > 5 { | 138 if rand.Intn(10) > 5 { |
139 m.signatureAndHashes = supportedSKXSignatureAlgorithms | 139 m.signatureAndHashes = supportedSKXSignatureAlgorithms |
140 } | 140 } |
| 141 m.alpnProtocols = make([]string, rand.Intn(5)) |
| 142 for i := range m.alpnProtocols { |
| 143 m.alpnProtocols[i] = randomString(rand.Intn(20)+1, rand) |
| 144 } |
141 | 145 |
142 return reflect.ValueOf(m) | 146 return reflect.ValueOf(m) |
143 } | 147 } |
144 | 148 |
145 func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { | 149 func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { |
146 m := &serverHelloMsg{} | 150 m := &serverHelloMsg{} |
147 m.vers = uint16(rand.Intn(65536)) | 151 m.vers = uint16(rand.Intn(65536)) |
148 m.random = randomBytes(32, rand) | 152 m.random = randomBytes(32, rand) |
149 m.sessionId = randomBytes(rand.Intn(32), rand) | 153 m.sessionId = randomBytes(rand.Intn(32), rand) |
150 m.cipherSuite = uint16(rand.Int31()) | 154 m.cipherSuite = uint16(rand.Int31()) |
151 m.compressionMethod = uint8(rand.Intn(256)) | 155 m.compressionMethod = uint8(rand.Intn(256)) |
152 | 156 |
153 if rand.Intn(10) > 5 { | 157 if rand.Intn(10) > 5 { |
154 m.nextProtoNeg = true | 158 m.nextProtoNeg = true |
155 | 159 |
156 n := rand.Intn(10) | 160 n := rand.Intn(10) |
157 m.nextProtos = make([]string, n) | 161 m.nextProtos = make([]string, n) |
158 for i := 0; i < n; i++ { | 162 for i := 0; i < n; i++ { |
159 m.nextProtos[i] = randomString(20, rand) | 163 m.nextProtos[i] = randomString(20, rand) |
160 } | 164 } |
161 } | 165 } |
162 | 166 |
163 if rand.Intn(10) > 5 { | 167 if rand.Intn(10) > 5 { |
164 m.ocspStapling = true | 168 m.ocspStapling = true |
165 } | 169 } |
166 if rand.Intn(10) > 5 { | 170 if rand.Intn(10) > 5 { |
167 m.ticketSupported = true | 171 m.ticketSupported = true |
168 } | 172 } |
| 173 m.alpnProtocol = randomString(rand.Intn(32)+1, rand) |
169 | 174 |
170 return reflect.ValueOf(m) | 175 return reflect.ValueOf(m) |
171 } | 176 } |
172 | 177 |
173 func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value { | 178 func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value { |
174 m := &certificateMsg{} | 179 m := &certificateMsg{} |
175 numCerts := rand.Intn(20) | 180 numCerts := rand.Intn(20) |
176 m.certificates = make([][]byte, numCerts) | 181 m.certificates = make([][]byte, numCerts) |
177 for i := 0; i < numCerts; i++ { | 182 for i := 0; i < numCerts; i++ { |
178 m.certificates[i] = randomBytes(rand.Intn(10)+1, rand) | 183 m.certificates[i] = randomBytes(rand.Intn(10)+1, rand) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 s.vers = uint16(rand.Intn(10000)) | 242 s.vers = uint16(rand.Intn(10000)) |
238 s.cipherSuite = uint16(rand.Intn(10000)) | 243 s.cipherSuite = uint16(rand.Intn(10000)) |
239 s.masterSecret = randomBytes(rand.Intn(100), rand) | 244 s.masterSecret = randomBytes(rand.Intn(100), rand) |
240 numCerts := rand.Intn(20) | 245 numCerts := rand.Intn(20) |
241 s.certificates = make([][]byte, numCerts) | 246 s.certificates = make([][]byte, numCerts) |
242 for i := 0; i < numCerts; i++ { | 247 for i := 0; i < numCerts; i++ { |
243 s.certificates[i] = randomBytes(rand.Intn(10)+1, rand) | 248 s.certificates[i] = randomBytes(rand.Intn(10)+1, rand) |
244 } | 249 } |
245 return reflect.ValueOf(s) | 250 return reflect.ValueOf(s) |
246 } | 251 } |
OLD | NEW |