summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2020-05-09 16:43:05 +0000
committertb <>2020-05-09 16:43:05 +0000
commit5f9e50161ad02213ce0e8e216933bde0efc8bc02 (patch)
treeb490ec08313675814e5201e93eb75bdb10cac539 /src/lib
parent99c3d9d6560601ac170c9657a01cf72bd69cfe63 (diff)
downloadopenbsd-5f9e50161ad02213ce0e8e216933bde0efc8bc02.tar.gz
openbsd-5f9e50161ad02213ce0e8e216933bde0efc8bc02.tar.bz2
openbsd-5f9e50161ad02213ce0e8e216933bde0efc8bc02.zip
Send dummy ChangeCipherSpec messages from the TLSv1.3 server
If the client has requested middle box compatibility mode by sending a non-empty legacy_session_id, the server must send a dummy CCS right after its first handshake message. This means right after ServerHello or HelloRetryRequest. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/tls13_handshake.c9
-rw-r--r--src/lib/libssl/tls13_internal.h3
-rw-r--r--src/lib/libssl/tls13_server.c25
3 files changed, 34 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c
index 05446380dd..1825bfbf6c 100644
--- a/src/lib/libssl/tls13_handshake.c
+++ b/src/lib/libssl/tls13_handshake.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_handshake.c,v 1.57 2020/05/09 15:47:11 jsing Exp $ */ 1/* $OpenBSD: tls13_handshake.c,v 1.58 2020/05/09 16:43:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org>
4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org>
@@ -102,6 +102,7 @@ static const struct tls13_handshake_action state_machine[] = {
102 .sender = TLS13_HS_SERVER, 102 .sender = TLS13_HS_SERVER,
103 .send = tls13_server_hello_retry_request_send, 103 .send = tls13_server_hello_retry_request_send,
104 .recv = tls13_server_hello_retry_request_recv, 104 .recv = tls13_server_hello_retry_request_recv,
105 .sent = tls13_server_hello_retry_request_sent,
105 }, 106 },
106 [SERVER_ENCRYPTED_EXTENSIONS] = { 107 [SERVER_ENCRYPTED_EXTENSIONS] = {
107 .handshake_type = TLS13_MT_ENCRYPTED_EXTENSIONS, 108 .handshake_type = TLS13_MT_ENCRYPTED_EXTENSIONS,
@@ -373,6 +374,12 @@ tls13_handshake_send_action(struct tls13_ctx *ctx,
373 if (action->sent != NULL && !action->sent(ctx)) 374 if (action->sent != NULL && !action->sent(ctx))
374 return TLS13_IO_FAILURE; 375 return TLS13_IO_FAILURE;
375 376
377 if (ctx->send_dummy_ccs) {
378 if ((ret = tls13_send_dummy_ccs(ctx->rl)) != TLS13_IO_SUCCESS)
379 return ret;
380 ctx->send_dummy_ccs = 0;
381 }
382
376 return TLS13_IO_SUCCESS; 383 return TLS13_IO_SUCCESS;
377} 384}
378 385
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index 438423aaff..e3aaf634c3 100644
--- a/src/lib/libssl/tls13_internal.h
+++ b/src/lib/libssl/tls13_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_internal.h,v 1.70 2020/05/09 15:47:11 jsing Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.71 2020/05/09 16:43:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -323,6 +323,7 @@ int tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb);
323int tls13_server_hello_sent(struct tls13_ctx *ctx); 323int tls13_server_hello_sent(struct tls13_ctx *ctx);
324int tls13_server_hello_retry_request_recv(struct tls13_ctx *ctx, CBS *cbs); 324int tls13_server_hello_retry_request_recv(struct tls13_ctx *ctx, CBS *cbs);
325int tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb); 325int tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb);
326int tls13_server_hello_retry_request_sent(struct tls13_ctx *ctx);
326int tls13_server_encrypted_extensions_recv(struct tls13_ctx *ctx, CBS *cbs); 327int tls13_server_encrypted_extensions_recv(struct tls13_ctx *ctx, CBS *cbs);
327int tls13_server_encrypted_extensions_send(struct tls13_ctx *ctx, CBB *cbb); 328int tls13_server_encrypted_extensions_send(struct tls13_ctx *ctx, CBB *cbb);
328int tls13_server_certificate_recv(struct tls13_ctx *ctx, CBS *cbs); 329int tls13_server_certificate_recv(struct tls13_ctx *ctx, CBS *cbs);
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index 2fe5428b71..5e2711d4d4 100644
--- a/src/lib/libssl/tls13_server.c
+++ b/src/lib/libssl/tls13_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_server.c,v 1.38 2020/05/09 14:02:24 tb Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.39 2020/05/09 16:43:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
@@ -335,6 +335,20 @@ tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb)
335} 335}
336 336
337int 337int
338tls13_server_hello_retry_request_sent(struct tls13_ctx *ctx)
339{
340 /*
341 * If the client has requested middlebox compatibility mode,
342 * we MUST send a dummy CCS following our first handshake message.
343 * See RFC 8446 Appendix D.4.
344 */
345 if (ctx->hs->legacy_session_id_len > 0)
346 ctx->send_dummy_ccs = 1;
347
348 return 1;
349}
350
351int
338tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs) 352tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs)
339{ 353{
340 SSL *s = ctx->ssl; 354 SSL *s = ctx->ssl;
@@ -368,6 +382,15 @@ tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb)
368int 382int
369tls13_server_hello_sent(struct tls13_ctx *ctx) 383tls13_server_hello_sent(struct tls13_ctx *ctx)
370{ 384{
385 /*
386 * If the client has requested middlebox compatibility mode,
387 * we MUST send a dummy CCS following our first handshake message.
388 * See RFC 8446 Appendix D.4.
389 */
390 if ((ctx->handshake_stage.hs_type & WITHOUT_HRR) &&
391 ctx->hs->legacy_session_id_len > 0)
392 ctx->send_dummy_ccs = 1;
393
371 return tls13_server_engage_record_protection(ctx); 394 return tls13_server_engage_record_protection(ctx);
372} 395}
373 396