summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2020-01-23 11:47:13 +0000
committerjsing <>2020-01-23 11:47:13 +0000
commit19a3c1d96385a70d4641d597c708f03c347280ae (patch)
tree0695bd7c209a3204a49c4b95c1c100e5f7223a6c /src/lib
parente1c90a4e070ba366916c4e95414e9b0b2c2d5df7 (diff)
downloadopenbsd-19a3c1d96385a70d4641d597c708f03c347280ae.tar.gz
openbsd-19a3c1d96385a70d4641d597c708f03c347280ae.tar.bz2
openbsd-19a3c1d96385a70d4641d597c708f03c347280ae.zip
Correct several issues in the current TLSv1.3 server code.
Correct the parsing of the client hello support versions extension. This has one or more values, rather than just the single selected version. Allocate an SSL_SESSION - this is unused currently, but is needed as soon as we start parsing extensions. Also, pull the cipher suites list off correctly - this is u16 prefixed, not u8. ok beck@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/tls13_server.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index e56d4c16fd..3c832aec65 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.11 2020/01/23 10:48:36 beck Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.12 2020/01/23 11:47:13 jsing 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>
@@ -45,6 +45,9 @@ tls13_server_init(struct tls13_ctx *ctx)
45 if (!tls1_transcript_init(s)) 45 if (!tls1_transcript_init(s))
46 return 0; 46 return 0;
47 47
48 if ((s->session = SSL_SESSION_new()) == NULL)
49 return 0;
50
48 arc4random_buf(s->s3->server_random, SSL3_RANDOM_SIZE); 51 arc4random_buf(s->s3->server_random, SSL3_RANDOM_SIZE);
49 52
50 return 1; 53 return 1;
@@ -142,8 +145,8 @@ tls13_use_legacy_server(struct tls13_ctx *ctx)
142static int 145static int
143tls13_client_hello_is_legacy(CBS *cbs) 146tls13_client_hello_is_legacy(CBS *cbs)
144{ 147{
145 CBS extensions_block, extensions, extension_data; 148 CBS extensions_block, extensions, extension_data, versions;
146 uint16_t selected_version = 0; 149 uint16_t version, max_version = 0;
147 uint16_t type; 150 uint16_t type;
148 151
149 CBS_dup(cbs, &extensions_block); 152 CBS_dup(cbs, &extensions_block);
@@ -159,13 +162,19 @@ tls13_client_hello_is_legacy(CBS *cbs)
159 162
160 if (type != TLSEXT_TYPE_supported_versions) 163 if (type != TLSEXT_TYPE_supported_versions)
161 continue; 164 continue;
162 if (!CBS_get_u16(&extension_data, &selected_version)) 165 if (!CBS_get_u8_length_prefixed(&extension_data, &versions))
163 return 1; 166 return 1;
167 while (CBS_len(&versions) > 0) {
168 if (!CBS_get_u16(&versions, &version))
169 return 1;
170 if (version >= max_version)
171 max_version = version;
172 }
164 if (CBS_len(&extension_data) != 0) 173 if (CBS_len(&extension_data) != 0)
165 return 1; 174 return 1;
166 } 175 }
167 176
168 return (selected_version < TLS1_3_VERSION); 177 return (max_version < TLS1_3_VERSION);
169} 178}
170 179
171static int 180static int
@@ -182,7 +191,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs)
182 goto err; 191 goto err;
183 if (!CBS_get_u8_length_prefixed(cbs, &session_id)) 192 if (!CBS_get_u8_length_prefixed(cbs, &session_id))
184 goto err; 193 goto err;
185 if (!CBS_get_u8_length_prefixed(cbs, &cipher_suites)) 194 if (!CBS_get_u16_length_prefixed(cbs, &cipher_suites))
186 goto err; 195 goto err;
187 if (!CBS_get_u8_length_prefixed(cbs, &compression_methods)) 196 if (!CBS_get_u8_length_prefixed(cbs, &compression_methods))
188 goto err; 197 goto err;