summaryrefslogtreecommitdiffstats
path: root/lib/libssl/ssl_srvr.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2018-08-24 18:10:25 +0000
committerjsing <jsing@openbsd.org>2018-08-24 18:10:25 +0000
commit307759ee4c8d98d4647f86f8ff8b8f7b7fbf3a68 (patch)
tree3933f4654be004b7b797b9a820e96bdf16e0c3f5 /lib/libssl/ssl_srvr.c
parentPull up the parsing of a ClientHello. (diff)
downloadwireguard-openbsd-307759ee4c8d98d4647f86f8ff8b8f7b7fbf3a68.tar.xz
wireguard-openbsd-307759ee4c8d98d4647f86f8ff8b8f7b7fbf3a68.zip
Simplify session ticket parsing/handling.
The original implementation is rather crazy and means that we effectively have two lots of code that parse a ClientHello and two lots of code that parse TLS extensions. Partially simplify this by passing a CBS containing the extension block through to the session handling functions, removing the need to reimplement the ClientHello parsing. While here standarise on naming for session_id and session_id_len. ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/ssl_srvr.c')
-rw-r--r--lib/libssl/ssl_srvr.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libssl/ssl_srvr.c b/lib/libssl/ssl_srvr.c
index b9b2c58705b..f06491e558b 100644
--- a/lib/libssl/ssl_srvr.c
+++ b/lib/libssl/ssl_srvr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_srvr.c,v 1.44 2018/08/24 17:44:22 jsing Exp $ */
+/* $OpenBSD: ssl_srvr.c,v 1.45 2018/08/24 18:10:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -818,7 +818,6 @@ ssl3_get_client_hello(SSL *s)
unsigned long alg_k;
const SSL_METHOD *method;
uint16_t shared_version;
- unsigned char *end;
/*
* We do this so that we will respond with our native type.
@@ -842,8 +841,6 @@ ssl3_get_client_hello(SSL *s)
if (n < 0)
goto err;
- end = (unsigned char *)s->internal->init_msg + n;
-
CBS_init(&cbs, s->internal->init_msg, n);
/* Parse client hello up until the extensions (if any). */
@@ -928,10 +925,12 @@ ssl3_get_client_hello(SSL *s)
if (!ssl_get_new_session(s, 1))
goto err;
} else {
- /* XXX - pass CBS through instead... */
- i = ssl_get_prev_session(s,
- (unsigned char *)CBS_data(&session_id),
- CBS_len(&session_id), end);
+ CBS ext_block;
+
+ CBS_dup(&cbs, &ext_block);
+
+ i = ssl_get_prev_session(s, CBS_data(&session_id),
+ CBS_len(&session_id), &ext_block);
if (i == 1) { /* previous session */
s->internal->hit = 1;
} else if (i == -1)