summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_srvr.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2021-03-10 18:27:03 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2021-03-10 18:27:03 +0000
commit06d4511f550945476dc17abd95853923792052be (patch)
treed3485c697017cae21d625c75682302bf3b8c7228 /lib/libssl/ssl_srvr.c
parent1b9ee26d82faa9776b136c078d6fbe082eb6459c (diff)
Improve internal version handling.
Add handshake fields for our minimum TLS version, our maximum TLS version and the TLS version negotiated during the handshake. Initialise our min/max versions at the start of the handshake and leave these unchanged. The negotiated TLS version is set in the client once we receive the ServerHello and in the server at the point we select the highest shared version. Provide an ssl_effective_version() function that returns the negotiated TLS version if known, otherwise our maximum TLS version - this is effectively what is stored in s->version currently. Convert most of the internal code to use one of these three version fields, which greatly simplifies code (especially in the TLS extension handling code). ok tb@
Diffstat (limited to 'lib/libssl/ssl_srvr.c')
-rw-r--r--lib/libssl/ssl_srvr.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/libssl/ssl_srvr.c b/lib/libssl/ssl_srvr.c
index be9c27f73f8..373a20d61b4 100644
--- a/lib/libssl/ssl_srvr.c
+++ b/lib/libssl/ssl_srvr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_srvr.c,v 1.95 2021/02/20 14:16:56 tb Exp $ */
+/* $OpenBSD: ssl_srvr.c,v 1.96 2021/03/10 18:27:02 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -219,6 +219,14 @@ ssl3_accept(SSL *s)
goto end;
}
+ if (!ssl_supported_tls_version_range(s,
+ &S3I(s)->hs.our_min_tls_version,
+ &S3I(s)->hs.our_max_tls_version)) {
+ SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE);
+ ret = -1;
+ goto end;
+ }
+
s->internal->type = SSL_ST_ACCEPT;
if (!ssl3_setup_init_buffer(s)) {
@@ -844,7 +852,7 @@ ssl3_get_client_hello(SSL *s)
*/
if (!ssl_downgrade_max_version(s, &max_version))
goto err;
- if (ssl_max_shared_version(s, client_version, &shared_version) != 1) {
+ if (!ssl_max_shared_version(s, client_version, &shared_version)) {
if ((s->client_version >> 8) == SSL3_VERSION_MAJOR &&
!tls12_record_layer_write_protected(s->internal->rl)) {
/*
@@ -860,6 +868,12 @@ ssl3_get_client_hello(SSL *s)
s->client_version = client_version;
s->version = shared_version;
+ S3I(s)->hs.negotiated_tls_version = ssl_tls_version(shared_version);
+ if (S3I(s)->hs.negotiated_tls_version == 0) {
+ SSLerror(s, ERR_R_INTERNAL_ERROR);
+ goto err;
+ }
+
if ((method = ssl_get_method(shared_version)) == NULL) {
SSLerror(s, ERR_R_INTERNAL_ERROR);
goto err;
@@ -1718,6 +1732,8 @@ ssl3_get_client_kex_rsa(SSL *s, CBS *cbs)
int al = -1;
arc4random_buf(fakekey, sizeof(fakekey));
+
+ /* XXX - peer max protocol version. */
fakekey[0] = s->client_version >> 8;
fakekey[1] = s->client_version & 0xff;
@@ -1754,6 +1770,7 @@ ssl3_get_client_kex_rsa(SSL *s, CBS *cbs)
/* SSLerror(s, SSL_R_BAD_RSA_DECRYPT); */
}
+ /* XXX - peer max version. */
if ((al == -1) && !((pms[0] == (s->client_version >> 8)) &&
(pms[1] == (s->client_version & 0xff)))) {
/*