summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeck <>2020-01-23 06:15:44 +0000
committerbeck <>2020-01-23 06:15:44 +0000
commit932b432c3b9e9c407ff00712d9587cdd1bdfd76a (patch)
treeffc60c78456130825a15045a1cef8731c2786b40
parentdfacc34b5531758fbd9129e03771aa661e80e93e (diff)
downloadopenbsd-932b432c3b9e9c407ff00712d9587cdd1bdfd76a.tar.gz
openbsd-932b432c3b9e9c407ff00712d9587cdd1bdfd76a.tar.bz2
openbsd-932b432c3b9e9c407ff00712d9587cdd1bdfd76a.zip
Save the legacy session id in the client, and enforce that it is returned
the same from the server. ok jsing@ tb@
-rw-r--r--src/lib/libssl/ssl_locl.h6
-rw-r--r--src/lib/libssl/tls13_client.c19
2 files changed, 18 insertions, 7 deletions
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 8649f651fa..2c774a3d77 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.253 2020/01/23 03:17:40 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.254 2020/01/23 06:15:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -469,6 +469,10 @@ typedef struct ssl_handshake_tls13_st {
469 /* Preserved transcript hash. */ 469 /* Preserved transcript hash. */
470 uint8_t transcript_hash[EVP_MAX_MD_SIZE]; 470 uint8_t transcript_hash[EVP_MAX_MD_SIZE];
471 size_t transcript_hash_len; 471 size_t transcript_hash_len;
472
473 /* Legacy session ID. */
474 uint8_t legacy_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
475 size_t legacy_session_id_len;
472} SSL_HANDSHAKE_TLS13; 476} SSL_HANDSHAKE_TLS13;
473 477
474typedef struct ssl_ctx_internal_st { 478typedef struct ssl_ctx_internal_st {
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c
index 1d59f33279..cab113b8c3 100644
--- a/src/lib/libssl/tls13_client.c
+++ b/src/lib/libssl/tls13_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_client.c,v 1.29 2020/01/23 02:24:38 jsing Exp $ */ 1/* $OpenBSD: tls13_client.c,v 1.30 2020/01/23 06:15:44 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -157,7 +157,6 @@ tls13_client_hello_build(struct tls13_ctx *ctx, CBB *cbb)
157 CBB cipher_suites, compression_methods, session_id; 157 CBB cipher_suites, compression_methods, session_id;
158 uint16_t client_version; 158 uint16_t client_version;
159 SSL *s = ctx->ssl; 159 SSL *s = ctx->ssl;
160 uint8_t *sid;
161 160
162 /* Legacy client version is capped at TLS 1.2. */ 161 /* Legacy client version is capped at TLS 1.2. */
163 client_version = ctx->hs->max_version; 162 client_version = ctx->hs->max_version;
@@ -170,12 +169,15 @@ tls13_client_hello_build(struct tls13_ctx *ctx, CBB *cbb)
170 goto err; 169 goto err;
171 170
172 /* Either 32-random bytes or zero length... */ 171 /* Either 32-random bytes or zero length... */
173 /* XXX - session resumption for TLSv1.2? */ 172 arc4random_buf(ctx->hs->legacy_session_id,
173 sizeof(ctx->hs->legacy_session_id));
174 ctx->hs->legacy_session_id_len = sizeof(ctx->hs->legacy_session_id);
175
174 if (!CBB_add_u8_length_prefixed(cbb, &session_id)) 176 if (!CBB_add_u8_length_prefixed(cbb, &session_id))
175 goto err; 177 goto err;
176 if (!CBB_add_space(&session_id, &sid, 32)) 178 if (!CBB_add_bytes(&session_id, ctx->hs->legacy_session_id,
179 ctx->hs->legacy_session_id_len))
177 goto err; 180 goto err;
178 arc4random_buf(sid, 32);
179 181
180 if (!CBB_add_u16_length_prefixed(cbb, &cipher_suites)) 182 if (!CBB_add_u16_length_prefixed(cbb, &cipher_suites))
181 goto err; 183 goto err;
@@ -315,7 +317,12 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs)
315 ctx->hs->server_version = legacy_version; 317 ctx->hs->server_version = legacy_version;
316 } 318 }
317 319
318 /* XXX - session_id must match. */ 320 /* The session_id must match. */
321 if (!CBS_mem_equal(&session_id, ctx->hs->legacy_session_id,
322 ctx->hs->legacy_session_id_len)) {
323 ctx->alert = SSL_AD_ILLEGAL_PARAMETER;
324 goto err;
325 }
319 326
320 /* 327 /*
321 * Ensure that the cipher suite is one that we offered in the client 328 * Ensure that the cipher suite is one that we offered in the client