diff options
| author | jsing <> | 2018-01-27 15:30:05 +0000 |
|---|---|---|
| committer | jsing <> | 2018-01-27 15:30:05 +0000 |
| commit | 493e742f784a4d7d846e7a28b384c113d30ed942 (patch) | |
| tree | 3d53d5ec7c827462ec31ee3156e980e4c951418a /src/lib/libssl/t1_lib.c | |
| parent | d591e698ee2bf88b94fcbab7fc07c798cf0b3ba8 (diff) | |
| download | openbsd-493e742f784a4d7d846e7a28b384c113d30ed942.tar.gz openbsd-493e742f784a4d7d846e7a28b384c113d30ed942.tar.bz2 openbsd-493e742f784a4d7d846e7a28b384c113d30ed942.zip | |
Complete the TLS extension handling rewrite for the server-side.
This removes ssl_parse_clienthello_tlsext() and allows the CBS to be
passed all the way through from ssl3_get_client_hello(). The renegotation
check gets pulled up into ssl3_get_client_hello() which is where other
such checks exist.
The TLS extension parsing now also ensures that we do not get duplicates
of any known extensions (the old pre-rewrite code only did this for some
extensions).
ok inoguchi@
Diffstat (limited to 'src/lib/libssl/t1_lib.c')
| -rw-r--r-- | src/lib/libssl/t1_lib.c | 71 |
1 files changed, 1 insertions, 70 deletions
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index 1cef08d094..fbd79431db 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.139 2017/10/11 17:35:00 jsing Exp $ */ | 1 | /* $OpenBSD: t1_lib.c,v 1.140 2018/01/27 15:30:05 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 | * |
| @@ -662,75 +662,6 @@ tls12_get_req_sig_algs(SSL *s, unsigned char **sigalgs, size_t *sigalgs_len) | |||
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | int | 664 | int |
| 665 | ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, | ||
| 666 | int n, int *al) | ||
| 667 | { | ||
| 668 | unsigned short type; | ||
| 669 | unsigned short size; | ||
| 670 | unsigned short len; | ||
| 671 | unsigned char *data = *p; | ||
| 672 | unsigned char *end = d + n; | ||
| 673 | CBS cbs; | ||
| 674 | |||
| 675 | s->internal->servername_done = 0; | ||
| 676 | s->tlsext_status_type = -1; | ||
| 677 | S3I(s)->renegotiate_seen = 0; | ||
| 678 | free(S3I(s)->alpn_selected); | ||
| 679 | S3I(s)->alpn_selected = NULL; | ||
| 680 | s->internal->srtp_profile = NULL; | ||
| 681 | |||
| 682 | if (data == end) | ||
| 683 | goto ri_check; | ||
| 684 | |||
| 685 | if (end - data < 2) | ||
| 686 | goto err; | ||
| 687 | n2s(data, len); | ||
| 688 | |||
| 689 | if (end - data != len) | ||
| 690 | goto err; | ||
| 691 | |||
| 692 | while (end - data >= 4) { | ||
| 693 | n2s(data, type); | ||
| 694 | n2s(data, size); | ||
| 695 | |||
| 696 | if (end - data < size) | ||
| 697 | goto err; | ||
| 698 | |||
| 699 | if (s->internal->tlsext_debug_cb) | ||
| 700 | s->internal->tlsext_debug_cb(s, 0, type, data, size, | ||
| 701 | s->internal->tlsext_debug_arg); | ||
| 702 | |||
| 703 | CBS_init(&cbs, data, size); | ||
| 704 | if (!tlsext_clienthello_parse_one(s, &cbs, type, al)) | ||
| 705 | return 0; | ||
| 706 | |||
| 707 | data += size; | ||
| 708 | } | ||
| 709 | |||
| 710 | /* Spurious data on the end */ | ||
| 711 | if (data != end) | ||
| 712 | goto err; | ||
| 713 | |||
| 714 | *p = data; | ||
| 715 | |||
| 716 | ri_check: | ||
| 717 | |||
| 718 | /* Need RI if renegotiating */ | ||
| 719 | |||
| 720 | if (!S3I(s)->renegotiate_seen && s->internal->renegotiate) { | ||
| 721 | *al = SSL_AD_HANDSHAKE_FAILURE; | ||
| 722 | SSLerror(s, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); | ||
| 723 | return 0; | ||
| 724 | } | ||
| 725 | |||
| 726 | return 1; | ||
| 727 | |||
| 728 | err: | ||
| 729 | *al = SSL_AD_DECODE_ERROR; | ||
| 730 | return 0; | ||
| 731 | } | ||
| 732 | |||
| 733 | int | ||
| 734 | ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al) | 665 | ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, size_t n, int *al) |
| 735 | { | 666 | { |
| 736 | unsigned short type; | 667 | unsigned short type; |
