diff options
author | tb <> | 2024-07-11 13:51:47 +0000 |
---|---|---|
committer | tb <> | 2024-07-11 13:51:47 +0000 |
commit | ddf5531a62ecff7872cb85dd71281c9bc93364e6 (patch) | |
tree | bac84e34fee66065d1ab024b8f50d7ba0e85ed36 /src | |
parent | d5570db0ecb5af46042a0ddacaf70875880b6f5a (diff) | |
download | openbsd-ddf5531a62ecff7872cb85dd71281c9bc93364e6.tar.gz openbsd-ddf5531a62ecff7872cb85dd71281c9bc93364e6.tar.bz2 openbsd-ddf5531a62ecff7872cb85dd71281c9bc93364e6.zip |
Adjust regress to match changes in SSL_select_next_proto() args
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libssl/unit/ssl_set_alpn_protos.c | 222 |
1 files changed, 99 insertions, 123 deletions
diff --git a/src/regress/lib/libssl/unit/ssl_set_alpn_protos.c b/src/regress/lib/libssl/unit/ssl_set_alpn_protos.c index 6f3fcfbc2a..d8447c8999 100644 --- a/src/regress/lib/libssl/unit/ssl_set_alpn_protos.c +++ b/src/regress/lib/libssl/unit/ssl_set_alpn_protos.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_set_alpn_protos.c,v 1.3 2024/06/28 14:50:37 tb Exp $ */ | 1 | /* $OpenBSD: ssl_set_alpn_protos.c,v 1.4 2024/07/11 13:51:47 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -202,162 +202,138 @@ test_ssl_set_alpn_protos_edge_cases(void) | |||
202 | } | 202 | } |
203 | 203 | ||
204 | static const struct select_next_proto_test { | 204 | static const struct select_next_proto_test { |
205 | const unsigned char *server_list; | 205 | const unsigned char *peer_list; |
206 | size_t server_list_len; | 206 | size_t peer_list_len; |
207 | const unsigned char *client_list; | 207 | const unsigned char *supported_list; |
208 | size_t client_list_len; | 208 | size_t supported_list_len; |
209 | int want_ret; | 209 | int want_ret; |
210 | const unsigned char *want_out; | 210 | const unsigned char *want_out; |
211 | unsigned char want_out_len; /* yes, unsigned char */ | 211 | unsigned char want_out_len; /* yes, unsigned char */ |
212 | } select_next_proto_tests[] = { | 212 | } select_next_proto_tests[] = { |
213 | { | 213 | { |
214 | .server_list = "\x01" "a" "\x01" "b" "\x01" "c", | 214 | .peer_list = "\x01" "a" "\x01" "b" "\x01" "c", |
215 | .server_list_len = 6, | 215 | .peer_list_len = 6, |
216 | .client_list = "\x01" "a", | 216 | .supported_list = "\x01" "a", |
217 | .client_list_len = 2, | 217 | .supported_list_len = 2, |
218 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 218 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
219 | .want_out = "a", | 219 | .want_out = "a", |
220 | .want_out_len = 1, | 220 | .want_out_len = 1, |
221 | }, | 221 | }, |
222 | { | 222 | { |
223 | .server_list = "\x01" "a" "\x01" "b" "\x01" "c", | 223 | .peer_list = "\x01" "a" "\x01" "b" "\x01" "c", |
224 | .server_list_len = 6, | 224 | .peer_list_len = 6, |
225 | .client_list = "\x02" "aa" "\x01" "b" "\x01" "c", | 225 | .supported_list = "\x02" "aa" "\x01" "b" "\x01" "c", |
226 | .client_list_len = 7, | 226 | .supported_list_len = 7, |
227 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 227 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
228 | .want_out = "b", | 228 | .want_out = "b", |
229 | .want_out_len = 1, | 229 | .want_out_len = 1, |
230 | }, | 230 | }, |
231 | { | 231 | { |
232 | /* Use server preference. */ | 232 | /* Use peer preference. */ |
233 | .server_list = "\x01" "a" "\x01" "b" "\x01" "c", | 233 | .peer_list = "\x01" "a" "\x01" "b" "\x01" "c", |
234 | .server_list_len = 6, | 234 | .peer_list_len = 6, |
235 | .client_list = "\x01" "c" "\x01" "b" "\x01" "a", | 235 | .supported_list = "\x01" "c" "\x01" "b" "\x01" "a", |
236 | .client_list_len = 6, | 236 | .supported_list_len = 6, |
237 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 237 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
238 | .want_out = "a", | 238 | .want_out = "a", |
239 | .want_out_len = 1, | 239 | .want_out_len = 1, |
240 | }, | 240 | }, |
241 | { | 241 | { |
242 | /* Again server preference wins. */ | 242 | /* Again peer preference wins. */ |
243 | .server_list = "\x01" "a" "\x03" "bbb" "\x02" "cc", | 243 | .peer_list = "\x01" "a" "\x03" "bbb" "\x02" "cc", |
244 | .server_list_len = 9, | 244 | .peer_list_len = 9, |
245 | .client_list = "\x01" "z" "\x02" "cc" "\x03" "bbb", | 245 | .supported_list = "\x01" "z" "\x02" "cc" "\x03" "bbb", |
246 | .client_list_len = 9, | 246 | .supported_list_len = 9, |
247 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 247 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
248 | .want_out = "bbb", | 248 | .want_out = "bbb", |
249 | .want_out_len = 3, | 249 | .want_out_len = 3, |
250 | }, | 250 | }, |
251 | { | 251 | { |
252 | /* No overlap fails with first client protocol. */ | 252 | /* No overlap fails with first supported protocol. */ |
253 | .server_list = "\x01" "a" "\x01" "b" "\x01" "c", | 253 | .peer_list = "\x01" "a" "\x01" "b" "\x01" "c", |
254 | .server_list_len = 6, | 254 | .peer_list_len = 6, |
255 | .client_list = "\x01" "z" "\x01" "y", | 255 | .supported_list = "\x01" "z" "\x01" "y", |
256 | .client_list_len = 4, | 256 | .supported_list_len = 4, |
257 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 257 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
258 | .want_out = "z", | 258 | .want_out = "z", |
259 | .want_out_len = 1, | 259 | .want_out_len = 1, |
260 | }, | 260 | }, |
261 | { | 261 | { |
262 | /* | 262 | /* No peer protocols fails cleanly. */ |
263 | * No server protocols is a misconfiguration, but should fail | 263 | .peer_list = "", |
264 | * cleanly. | 264 | .peer_list_len = 0, |
265 | */ | 265 | .supported_list = "\x01" "a" "\x01" "b" "\x01" "c", |
266 | .server_list = "", | 266 | .supported_list_len = 6, |
267 | .server_list_len = 0, | ||
268 | .client_list = "\x01" "a" "\x01" "b" "\x01" "c", | ||
269 | .client_list_len = 6, | ||
270 | .want_out = "a", | 267 | .want_out = "a", |
271 | .want_out_len = 1, | 268 | .want_out_len = 1, |
272 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 269 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
273 | }, | 270 | }, |
274 | { | 271 | { |
275 | /* | 272 | /* NULL peer protocols fails cleanly. */ |
276 | * NULL server protocols is a programming error that fails | 273 | .peer_list = NULL, |
277 | * cleanly. | 274 | .peer_list_len = 0, |
278 | */ | 275 | .supported_list = "\x01" "a" "\x01" "b" "\x01" "c", |
279 | .server_list = NULL, | 276 | .supported_list_len = 6, |
280 | .server_list_len = 0, | ||
281 | .client_list = "\x01" "a" "\x01" "b" "\x01" "c", | ||
282 | .client_list_len = 6, | ||
283 | .want_out = "a", | 277 | .want_out = "a", |
284 | .want_out_len = 1, | 278 | .want_out_len = 1, |
285 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 279 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
286 | }, | 280 | }, |
287 | { | 281 | { |
288 | /* | 282 | /* Malformed peer protocols fails cleanly. */ |
289 | * Malformed server protocols is a misconfiguration, but it | 283 | .peer_list = "\x00", |
290 | * should fail cleanly. | 284 | .peer_list_len = 1, |
291 | */ | 285 | .supported_list = "\x01" "a" "\x01" "b" "\x01" "c", |
292 | .server_list = "\x00", | 286 | .supported_list_len = 6, |
293 | .server_list_len = 1, | ||
294 | .client_list = "\x01" "a" "\x01" "b" "\x01" "c", | ||
295 | .client_list_len = 6, | ||
296 | .want_out = "a", | 287 | .want_out = "a", |
297 | .want_out_len = 1, | 288 | .want_out_len = 1, |
298 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 289 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
299 | }, | 290 | }, |
300 | { | 291 | { |
301 | /* | 292 | /* Malformed peer protocols fails cleanly. */ |
302 | * Malformed server protocols is a misconfiguration, but it | 293 | .peer_list = "\x01" "a" "\x03" "bb", |
303 | * should fail cleanly. | 294 | .peer_list_len = 5, |
304 | */ | 295 | .supported_list = "\x01" "a" "\x01" "b" "\x01" "c", |
305 | .server_list = "\x01" "a" "\x03" "bb", | 296 | .supported_list_len = 6, |
306 | .server_list_len = 5, | ||
307 | .client_list = "\x01" "a" "\x01" "b" "\x01" "c", | ||
308 | .client_list_len = 6, | ||
309 | .want_out = "a", | 297 | .want_out = "a", |
310 | .want_out_len = 1, | 298 | .want_out_len = 1, |
311 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 299 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
312 | }, | 300 | }, |
313 | { | 301 | { |
314 | /* | 302 | /* Empty supported list fails cleanly. */ |
315 | * Empty client protocols is not reachable from the ALPN | 303 | .peer_list = "\x01" "a", |
316 | * callback. It fails cleanly with NULL protocol and 0 length. | 304 | .peer_list_len = 2, |
317 | */ | 305 | .supported_list = "", |
318 | .server_list = "\x01" "a", | 306 | .supported_list_len = 0, |
319 | .server_list_len = 2, | ||
320 | .client_list = "", | ||
321 | .client_list_len = 0, | ||
322 | .want_out = NULL, | 307 | .want_out = NULL, |
323 | .want_out_len = 0, | 308 | .want_out_len = 0, |
324 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 309 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
325 | }, | 310 | }, |
326 | { | 311 | { |
327 | /* | 312 | /* NULL supported list fails cleanly. */ |
328 | * NULL client protocols is not reachable from the ALPN | 313 | .peer_list = "\x01" "a", |
329 | * callback. It fails cleanly with NULL protocol and 0 length. | 314 | .peer_list_len = 2, |
330 | */ | 315 | .supported_list = NULL, |
331 | .server_list = "\x01" "a", | 316 | .supported_list_len = 0, |
332 | .server_list_len = 2, | ||
333 | .client_list = NULL, | ||
334 | .client_list_len = 0, | ||
335 | .want_out = NULL, | 317 | .want_out = NULL, |
336 | .want_out_len = 0, | 318 | .want_out_len = 0, |
337 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 319 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
338 | }, | 320 | }, |
339 | { | 321 | { |
340 | /* | 322 | /* Malformed supported list fails cleanly. */ |
341 | * Malformed client list fails cleanly with NULL protocol and | 323 | .peer_list = "\x01" "a", |
342 | * 0 length. | 324 | .peer_list_len = 2, |
343 | */ | 325 | .supported_list = "\x01" "a" "\x02" "bb" "\x03" "cc" "\x04" "ddd", |
344 | .server_list = "\x01" "a", | 326 | .supported_list_len = 12, |
345 | .server_list_len = 2, | ||
346 | .client_list = "\x01" "a" "\x02" "bb" "\x03" "cc" "\x04" "ddd", | ||
347 | .client_list_len = 12, | ||
348 | .want_out = NULL, | 327 | .want_out = NULL, |
349 | .want_out_len = 0, | 328 | .want_out_len = 0, |
350 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 329 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
351 | }, | 330 | }, |
352 | { | 331 | { |
353 | /* | 332 | /* Malformed client list fails cleanly. */ |
354 | * Malformed client list fails cleanly with NULL protocol and | 333 | .peer_list = "\x01" "a", |
355 | * 0 length. | 334 | .peer_list_len = 2, |
356 | */ | 335 | .supported_list = "\x01" "a" "\x02" "bb" "\x00" "\x03" "ddd", |
357 | .server_list = "\x01" "a", | 336 | .supported_list_len = 10, |
358 | .server_list_len = 2, | ||
359 | .client_list = "\x01" "a" "\x02" "bb" "\x00" "\x03" "ddd", | ||
360 | .client_list_len = 10, | ||
361 | .want_out = NULL, | 337 | .want_out = NULL, |
362 | .want_out_len = 0, | 338 | .want_out_len = 0, |
363 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 339 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
@@ -368,58 +344,58 @@ static const struct select_next_proto_test { | |||
368 | */ | 344 | */ |
369 | 345 | ||
370 | { | 346 | { |
371 | .server_list = "\x08" "http/1.1" "\x06" "spdy/1", | 347 | .peer_list = "\x08" "http/1.1" "\x06" "spdy/1", |
372 | .server_list_len = 16, | 348 | .peer_list_len = 16, |
373 | .client_list = "\x08" "http/2.0" "\x08" "http/1.1", | 349 | .supported_list = "\x08" "http/2.0" "\x08" "http/1.1", |
374 | .client_list_len = 18, | 350 | .supported_list_len = 18, |
375 | .want_out = "http/1.1", | 351 | .want_out = "http/1.1", |
376 | .want_out_len = 8, | 352 | .want_out_len = 8, |
377 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 353 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
378 | }, | 354 | }, |
379 | { | 355 | { |
380 | .server_list = "\x08" "http/2.0" "\x06" "spdy/1", | 356 | .peer_list = "\x08" "http/2.0" "\x06" "spdy/1", |
381 | .server_list_len = 16, | 357 | .peer_list_len = 16, |
382 | .client_list = "\x08" "http/1.0" "\x08" "http/1.1", | 358 | .supported_list = "\x08" "http/1.0" "\x08" "http/1.1", |
383 | .client_list_len = 18, | 359 | .supported_list_len = 18, |
384 | .want_out = "http/1.0", | 360 | .want_out = "http/1.0", |
385 | .want_out_len = 8, | 361 | .want_out_len = 8, |
386 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 362 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
387 | }, | 363 | }, |
388 | { | 364 | { |
389 | .server_list = "\x08" "http/1.1" "\x08" "http/1.0", | 365 | .peer_list = "\x08" "http/1.1" "\x08" "http/1.0", |
390 | .server_list_len = 18, | 366 | .peer_list_len = 18, |
391 | .client_list = "\x08" "http/1.0" "\x08" "http/1.1", | 367 | .supported_list = "\x08" "http/1.0" "\x08" "http/1.1", |
392 | .client_list_len = 18, | 368 | .supported_list_len = 18, |
393 | .want_out = "http/1.1", | 369 | .want_out = "http/1.1", |
394 | .want_out_len = 8, | 370 | .want_out_len = 8, |
395 | .want_ret = OPENSSL_NPN_NEGOTIATED, | 371 | .want_ret = OPENSSL_NPN_NEGOTIATED, |
396 | }, | 372 | }, |
397 | { | 373 | { |
398 | /* Server malformed. */ | 374 | /* Peer list malformed. */ |
399 | .server_list = "\x08" "http/1.1" "\x07" "http/1.0", | 375 | .peer_list = "\x08" "http/1.1" "\x07" "http/1.0", |
400 | .server_list_len = 18, | 376 | .peer_list_len = 18, |
401 | .client_list = "\x08" "http/1.0" "\x08" "http/1.1", | 377 | .supported_list = "\x08" "http/1.0" "\x08" "http/1.1", |
402 | .client_list_len = 18, | 378 | .supported_list_len = 18, |
403 | .want_out = "http/1.0", | 379 | .want_out = "http/1.0", |
404 | .want_out_len = 8, | 380 | .want_out_len = 8, |
405 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 381 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
406 | }, | 382 | }, |
407 | { | 383 | { |
408 | /* Server malformed. */ | 384 | /* Peer list malformed. */ |
409 | .server_list = "\x07" "http/1.1" "\x08" "http/1.0", | 385 | .peer_list = "\x07" "http/1.1" "\x08" "http/1.0", |
410 | .server_list_len = 18, | 386 | .peer_list_len = 18, |
411 | .client_list = "\x08" "http/1.0" "\x08" "http/1.1", | 387 | .supported_list = "\x08" "http/1.0" "\x08" "http/1.1", |
412 | .client_list_len = 18, | 388 | .supported_list_len = 18, |
413 | .want_out = "http/1.0", | 389 | .want_out = "http/1.0", |
414 | .want_out_len = 8, | 390 | .want_out_len = 8, |
415 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 391 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
416 | }, | 392 | }, |
417 | { | 393 | { |
418 | /* Client has trailing bytes. */ | 394 | /* Supported list has trailing bytes. */ |
419 | .server_list = "\x08" "http/1.1" "\x08" "http/1.0", | 395 | .peer_list = "\x08" "http/1.1" "\x08" "http/1.0", |
420 | .server_list_len = 18, | 396 | .peer_list_len = 18, |
421 | .client_list = "\x08" "http/1.0" "\x07" "http/1.1", | 397 | .supported_list = "\x08" "http/1.0" "\x07" "http/1.1", |
422 | .client_list_len = 18, | 398 | .supported_list_len = 18, |
423 | .want_out = NULL, | 399 | .want_out = NULL, |
424 | .want_out_len = 0, | 400 | .want_out_len = 0, |
425 | .want_ret = OPENSSL_NPN_NO_OVERLAP, | 401 | .want_ret = OPENSSL_NPN_NO_OVERLAP, |
@@ -437,8 +413,8 @@ select_next_proto_testcase(const struct select_next_proto_test *test) | |||
437 | int ret; | 413 | int ret; |
438 | int failed = 0; | 414 | int failed = 0; |
439 | 415 | ||
440 | ret = SSL_select_next_proto(&out, &out_len, test->server_list, | 416 | ret = SSL_select_next_proto(&out, &out_len, test->peer_list, |
441 | test->server_list_len, test->client_list, test->client_list_len); | 417 | test->peer_list_len, test->supported_list, test->supported_list_len); |
442 | 418 | ||
443 | if (ret != test->want_ret || out_len != test->want_out_len || | 419 | if (ret != test->want_ret || out_len != test->want_out_len || |
444 | (out == NULL && test->want_out != NULL) || | 420 | (out == NULL && test->want_out != NULL) || |
@@ -452,9 +428,9 @@ select_next_proto_testcase(const struct select_next_proto_test *test) | |||
452 | fprintf(stderr, "\nwant:\n"); | 428 | fprintf(stderr, "\nwant:\n"); |
453 | hexdump(test->want_out, test->want_out_len); | 429 | hexdump(test->want_out, test->want_out_len); |
454 | fprintf(stderr, "\nserver:\n"); | 430 | fprintf(stderr, "\nserver:\n"); |
455 | hexdump(test->server_list, test->server_list_len); | 431 | hexdump(test->peer_list, test->peer_list_len); |
456 | fprintf(stderr, "\nclient:\n"); | 432 | fprintf(stderr, "\nclient:\n"); |
457 | hexdump(test->client_list, test->client_list_len); | 433 | hexdump(test->supported_list, test->supported_list_len); |
458 | fprintf(stderr, "\n"); | 434 | fprintf(stderr, "\n"); |
459 | failed = 1; | 435 | failed = 1; |
460 | } | 436 | } |