diff options
author | jsing <> | 2017-07-24 17:39:43 +0000 |
---|---|---|
committer | jsing <> | 2017-07-24 17:39:43 +0000 |
commit | 6642dc2432218e4d9462f7b283b0b3695c80f3ee (patch) | |
tree | 7bd66962dd8d0a3f77e083181d094633228b180a /src/lib | |
parent | 4594b1e8ad00ae1d91a124a6062005c5f4c0a260 (diff) | |
download | openbsd-6642dc2432218e4d9462f7b283b0b3695c80f3ee.tar.gz openbsd-6642dc2432218e4d9462f7b283b0b3695c80f3ee.tar.bz2 openbsd-6642dc2432218e4d9462f7b283b0b3695c80f3ee.zip |
Rewrite and move the last remnants of the ServerHello SNI handling into
tlsext_sni_serverhello_parse(). This also adds a check to ensure that
if we have an existing session, the name matches what we specified via
SNI.
ok doug@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/ssl_tlsext.c | 24 | ||||
-rw-r--r-- | src/lib/libssl/t1_lib.c | 30 |
2 files changed, 25 insertions, 29 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c index 539c380fb9..400c69fa87 100644 --- a/src/lib/libssl/ssl_tlsext.c +++ b/src/lib/libssl/ssl_tlsext.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_tlsext.c,v 1.2 2017/07/24 17:10:31 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_tlsext.c,v 1.3 2017/07/24 17:39:43 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -259,6 +259,28 @@ tlsext_sni_serverhello_parse(SSL *s, CBS *cbs, int *alert) | |||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | if (s->internal->hit) { | ||
263 | if (s->session->tlsext_hostname == NULL) { | ||
264 | *alert = TLS1_AD_UNRECOGNIZED_NAME; | ||
265 | return 0; | ||
266 | } | ||
267 | if (strcmp(s->tlsext_hostname, | ||
268 | s->session->tlsext_hostname) != 0) { | ||
269 | *alert = TLS1_AD_UNRECOGNIZED_NAME; | ||
270 | return 0; | ||
271 | } | ||
272 | } else { | ||
273 | if (s->session->tlsext_hostname != NULL) { | ||
274 | *alert = SSL_AD_DECODE_ERROR; | ||
275 | return 0; | ||
276 | } | ||
277 | if ((s->session->tlsext_hostname = | ||
278 | strdup(s->tlsext_hostname)) == NULL) { | ||
279 | *alert = TLS1_AD_INTERNAL_ERROR; | ||
280 | return 0; | ||
281 | } | ||
282 | } | ||
283 | |||
262 | return 1; | 284 | return 1; |
263 | } | 285 | } |
264 | 286 | ||
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index bf5e2de80b..b061bd1100 100644 --- a/src/lib/libssl/t1_lib.c +++ b/src/lib/libssl/t1_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t1_lib.c,v 1.121 2017/07/24 17:10:31 jsing Exp $ */ | 1 | /* $OpenBSD: t1_lib.c,v 1.122 2017/07/24 17:39:43 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1504,7 +1504,6 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al) | |||
1504 | unsigned short len; | 1504 | unsigned short len; |
1505 | unsigned char *data = *p; | 1505 | unsigned char *data = *p; |
1506 | unsigned char *end = *p + n; | 1506 | unsigned char *end = *p + n; |
1507 | int tlsext_servername = 0; | ||
1508 | CBS cbs; | 1507 | CBS cbs; |
1509 | 1508 | ||
1510 | S3I(s)->renegotiate_seen = 0; | 1509 | S3I(s)->renegotiate_seen = 0; |
@@ -1537,15 +1536,7 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al) | |||
1537 | if (!tlsext_serverhello_parse_one(s, &cbs, type, al)) | 1536 | if (!tlsext_serverhello_parse_one(s, &cbs, type, al)) |
1538 | return 0; | 1537 | return 0; |
1539 | 1538 | ||
1540 | if (type == TLSEXT_TYPE_server_name) { | 1539 | if (type == TLSEXT_TYPE_ec_point_formats && |
1541 | if (s->tlsext_hostname == NULL || size > 0) { | ||
1542 | *al = TLS1_AD_UNRECOGNIZED_NAME; | ||
1543 | return 0; | ||
1544 | } | ||
1545 | tlsext_servername = 1; | ||
1546 | |||
1547 | } | ||
1548 | else if (type == TLSEXT_TYPE_ec_point_formats && | ||
1549 | s->version != DTLS1_VERSION) { | 1540 | s->version != DTLS1_VERSION) { |
1550 | unsigned char *sdata = data; | 1541 | unsigned char *sdata = data; |
1551 | size_t formatslen; | 1542 | size_t formatslen; |
@@ -1688,23 +1679,6 @@ ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al) | |||
1688 | return 0; | 1679 | return 0; |
1689 | } | 1680 | } |
1690 | 1681 | ||
1691 | if (!s->internal->hit && tlsext_servername == 1) { | ||
1692 | if (s->tlsext_hostname) { | ||
1693 | if (s->session->tlsext_hostname == NULL) { | ||
1694 | s->session->tlsext_hostname = | ||
1695 | strdup(s->tlsext_hostname); | ||
1696 | |||
1697 | if (!s->session->tlsext_hostname) { | ||
1698 | *al = SSL_AD_UNRECOGNIZED_NAME; | ||
1699 | return 0; | ||
1700 | } | ||
1701 | } else { | ||
1702 | *al = SSL_AD_DECODE_ERROR; | ||
1703 | return 0; | ||
1704 | } | ||
1705 | } | ||
1706 | } | ||
1707 | |||
1708 | *p = data; | 1682 | *p = data; |
1709 | 1683 | ||
1710 | ri_check: | 1684 | ri_check: |