diff options
| author | tb <> | 2026-05-09 11:45:50 +0000 |
|---|---|---|
| committer | tb <> | 2026-05-09 11:45:50 +0000 |
| commit | eb7b0089a32bfe0cc25aea8748f4b35f315d31a7 (patch) | |
| tree | a87ca03351b4dc89d8bbdc7603ca7c0edc6c2869 /src/lib/libssl | |
| parent | 8ea86b6171685902bc68700cb1dbf84a0b3006cb (diff) | |
| download | openbsd-eb7b0089a32bfe0cc25aea8748f4b35f315d31a7.tar.gz openbsd-eb7b0089a32bfe0cc25aea8748f4b35f315d31a7.tar.bz2 openbsd-eb7b0089a32bfe0cc25aea8748f4b35f315d31a7.zip | |
libssl: record extension lengths in ClientHello hashing
The ClientHello hash is intended to ensure that the second CH after an HRR
only makes the allowed changes to the TLS extensiosn by recording message
type followed by the raw extension data if it must remain unchanged.
This makes it possible (in principle) that part of free form extension
data is confused with type (and length) information of a subsequent
extension.
Recording the length after the type prevents such a confusion and fixes
the framing of the extensions.
Found by Frank Denis
ok jsing
Diffstat (limited to 'src/lib/libssl')
| -rw-r--r-- | src/lib/libssl/ssl_tlsext.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c index d879b3304e..f6fbf43dfd 100644 --- a/src/lib/libssl/ssl_tlsext.c +++ b/src/lib/libssl/ssl_tlsext.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_tlsext.c,v 1.159 2025/12/04 21:16:17 beck Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.c,v 1.160 2026/05/09 11:45:50 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> |
| 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> | 4 | * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> |
| @@ -2558,6 +2558,7 @@ tlsext_clienthello_hash_extension(SSL *s, uint16_t type, CBS *cbs) | |||
| 2558 | * cookie may be added, padding may be removed. | 2558 | * cookie may be added, padding may be removed. |
| 2559 | */ | 2559 | */ |
| 2560 | struct tls13_ctx *ctx = s->tls13; | 2560 | struct tls13_ctx *ctx = s->tls13; |
| 2561 | uint16_t len = CBS_len(cbs); | ||
| 2561 | 2562 | ||
| 2562 | if (type == TLSEXT_TYPE_early_data || type == TLSEXT_TYPE_cookie || | 2563 | if (type == TLSEXT_TYPE_early_data || type == TLSEXT_TYPE_cookie || |
| 2563 | type == TLSEXT_TYPE_padding) | 2564 | type == TLSEXT_TYPE_padding) |
| @@ -2571,6 +2572,8 @@ tlsext_clienthello_hash_extension(SSL *s, uint16_t type, CBS *cbs) | |||
| 2571 | */ | 2572 | */ |
| 2572 | if (type == TLSEXT_TYPE_pre_shared_key || type == TLSEXT_TYPE_key_share) | 2573 | if (type == TLSEXT_TYPE_pre_shared_key || type == TLSEXT_TYPE_key_share) |
| 2573 | return 1; | 2574 | return 1; |
| 2575 | if (!tls13_clienthello_hash_update_bytes(ctx, (void *)&len, sizeof(len))) | ||
| 2576 | return 0; | ||
| 2574 | if (!tls13_clienthello_hash_update(ctx, cbs)) | 2577 | if (!tls13_clienthello_hash_update(ctx, cbs)) |
| 2575 | return 0; | 2578 | return 0; |
| 2576 | 2579 | ||
