diff options
| author | tb <> | 2026-08-29 05:12:47 +0000 |
|---|---|---|
| committer | tb <> | 2026-08-29 05:12:47 +0000 |
| commit | c087cfb4dd519b837fdf6897a81c00d4bf2fa78e (patch) | |
| tree | 64c70e38fbee2e37fc467e564537b262c2870f13 | |
| parent | a86ec57849247ba2ba6e7d7d7d9ccb619e5d01bf (diff) | |
| download | openbsd-c087cfb4dd519b837fdf6897a81c00d4bf2fa78e.tar.gz openbsd-c087cfb4dd519b837fdf6897a81c00d4bf2fa78e.tar.bz2 openbsd-c087cfb4dd519b837fdf6897a81c00d4bf2fa78e.zip | |
tlsext: check we reject unadvertised selected protocol
This test currently fails and will be fixed in ssl_tlsect.c r1.168
| -rw-r--r-- | src/regress/lib/libssl/tlsext/tlsexttest.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c index 9c4c0f55a1..29b348154f 100644 --- a/src/regress/lib/libssl/tlsext/tlsexttest.c +++ b/src/regress/lib/libssl/tlsext/tlsexttest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tlsexttest.c,v 1.97 2026/04/03 07:37:52 jsing Exp $ */ | 1 | /* $OpenBSD: tlsexttest.c,v 1.98 2026/08/29 05:12:47 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> |
| 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
| @@ -153,6 +153,14 @@ const uint8_t tlsext_alpn_single_proto[] = { | |||
| 153 | 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31 | 153 | 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31 |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| 156 | const uint8_t tlsext_alpn_single_proto_unadvertised[] = { | ||
| 157 | /* ProtocolName protocol_name_list<2..2^16-1> -- ALPN names */ | ||
| 158 | 0x00, 0x09, /* len of all names */ | ||
| 159 | /* opaque ProtocolName<1..2^8-1> -- 'http/1.2' */ | ||
| 160 | 0x08, /* len */ | ||
| 161 | 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x32 | ||
| 162 | }; | ||
| 163 | |||
| 156 | #define TLSEXT_TYPE_alpn TLSEXT_TYPE_application_layer_protocol_negotiation | 164 | #define TLSEXT_TYPE_alpn TLSEXT_TYPE_application_layer_protocol_negotiation |
| 157 | 165 | ||
| 158 | static int | 166 | static int |
| @@ -334,6 +342,21 @@ test_tlsext_alpn_client(void) | |||
| 334 | goto err; | 342 | goto err; |
| 335 | } | 343 | } |
| 336 | 344 | ||
| 345 | /* Make sure we don't accept a protocol we did not advertise. */ | ||
| 346 | |||
| 347 | CBS_init(&cbs, tlsext_alpn_single_proto_unadvertised, | ||
| 348 | sizeof(tlsext_alpn_single_proto_unadvertised)); | ||
| 349 | |||
| 350 | if (client_funcs->process(ssl, SSL_TLSEXT_MSG_SH, &cbs, &alert)) { | ||
| 351 | FAIL("failed to reject unadvertised ALPN protocol\n"); | ||
| 352 | goto err; | ||
| 353 | } | ||
| 354 | if (alert != SSL_AD_ILLEGAL_PARAMETER) { | ||
| 355 | FAIL("unadvertised ALPN: want illegal_parameter, got %s\n", | ||
| 356 | SSL_alert_desc_string_long(alert)); | ||
| 357 | goto err; | ||
| 358 | } | ||
| 359 | |||
| 337 | /* Make sure we can remove the list and avoid ALPN */ | 360 | /* Make sure we can remove the list and avoid ALPN */ |
| 338 | 361 | ||
| 339 | free(ssl->alpn_client_proto_list); | 362 | free(ssl->alpn_client_proto_list); |
