summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2020-06-24 07:28:38 +0000
committertb <>2020-06-24 07:28:38 +0000
commit1b5079de613ae3744d2654a6d70ce52644fc66eb (patch)
tree7c1b63d3c778f27da58f18d0adf05a7f79a1e2cf /src
parente2ab506451a88600ca5dba29aff8b3d0cd203f01 (diff)
downloadopenbsd-1b5079de613ae3744d2654a6d70ce52644fc66eb.tar.gz
openbsd-1b5079de613ae3744d2654a6d70ce52644fc66eb.tar.bz2
openbsd-1b5079de613ae3744d2654a6d70ce52644fc66eb.zip
Enforce restrictions for ClientHello extensions
RFC 8446 section 9.2 imposes some requirements on the extensions sent in the ClientHello: key_share and supported_groups must either both be present or both be absent. If no pre_shared_key was sent, the CH must contain both signature_algorithms and supported_groups. If either of these conditions is violated, servers must abort the handshake with a missing_extensions alert. Add a function that enforces this. If we are going to enforce that clients send an SNI, we can also do this in this function. Fixes failing test case in tlsfuzzer's test-tls13-keyshare-omitted.py ok beck inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/tls13_server.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index ccbb46652b..843b572401 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.58 2020/06/06 01:40:09 beck Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.59 2020/06/24 07:28:38 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>
@@ -96,6 +96,44 @@ tls13_client_hello_is_legacy(CBS *cbs)
96 return (max_version < TLS1_3_VERSION); 96 return (max_version < TLS1_3_VERSION);
97} 97}
98 98
99int
100tls13_client_hello_required_extensions(struct tls13_ctx *ctx)
101{
102 SSL *ssl = ctx->ssl;
103
104 /*
105 * RFC 8446, section 9.2. If the ClientHello has supported_versions
106 * containing TLSv1.3, presence or absence of some extensions requires
107 * presence or absence of others.
108 */
109
110 /*
111 * supported_groups and key_share must either both be present or
112 * both be absent.
113 */
114 if (tlsext_extension_seen(ssl, TLSEXT_TYPE_supported_groups) !=
115 tlsext_extension_seen(ssl, TLSEXT_TYPE_key_share))
116 return 0;
117
118 /*
119 * If we got no pre_shared_key, then signature_algorithms and
120 * supported_groups must both be present.
121 */
122 if (!tlsext_extension_seen(ssl, TLSEXT_TYPE_pre_shared_key)) {
123 if (!tlsext_extension_seen(ssl, TLSEXT_TYPE_signature_algorithms))
124 return 0;
125 if (!tlsext_extension_seen(ssl, TLSEXT_TYPE_supported_groups))
126 return 0;
127 }
128
129 /*
130 * XXX - Require server_name from client? If so, we SHOULD enforce
131 * this here - RFC 8446, 9.2.
132 */
133
134 return 1;
135}
136
99static const uint8_t tls13_compression_null_only[] = { 0 }; 137static const uint8_t tls13_compression_null_only[] = { 0 };
100 138
101static int 139static int
@@ -172,6 +210,11 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs)
172 tls13_clienthello_hash_clear(ctx->hs); 210 tls13_clienthello_hash_clear(ctx->hs);
173 } 211 }
174 212
213 if (!tls13_client_hello_required_extensions(ctx)) {
214 ctx->alert = TLS13_ALERT_MISSING_EXTENSION;
215 goto err;
216 }
217
175 /* 218 /*
176 * If we got this far we have a supported versions extension that offers 219 * If we got this far we have a supported versions extension that offers
177 * TLS 1.3 or later. This requires the legacy version be set to 0x0303. 220 * TLS 1.3 or later. This requires the legacy version be set to 0x0303.