From 84fe391fb9021a6be2b592ffb9543ccc421a80be Mon Sep 17 00:00:00 2001 From: jsing <> Date: Fri, 24 Aug 2018 18:10:25 +0000 Subject: 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@ --- src/lib/libssl/ssl_srvr.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/lib/libssl/ssl_srvr.c') diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index b9b2c58705..f06491e558 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/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) -- cgit v1.2.3-55-g6feb