diff options
Diffstat (limited to 'src/lib/libssl/t1_lib.c')
-rw-r--r-- | src/lib/libssl/t1_lib.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index b8aa989413..6af6d77edd 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.158 2019/04/22 14:49:42 jsing Exp $ */ | 1 | /* $OpenBSD: t1_lib.c,v 1.159 2019/04/22 15:12:20 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 | * |
@@ -122,9 +122,8 @@ | |||
122 | #include "ssl_sigalgs.h" | 122 | #include "ssl_sigalgs.h" |
123 | #include "ssl_tlsext.h" | 123 | #include "ssl_tlsext.h" |
124 | 124 | ||
125 | static int tls_decrypt_ticket(SSL *s, const unsigned char *tick, int ticklen, | 125 | static int tls_decrypt_ticket(SSL *s, CBS *session_id, |
126 | const unsigned char *sess_id, int sesslen, | 126 | const unsigned char *tick, int ticklen, SSL_SESSION **psess); |
127 | SSL_SESSION **psess); | ||
128 | 127 | ||
129 | SSL3_ENC_METHOD TLSv1_enc_data = { | 128 | SSL3_ENC_METHOD TLSv1_enc_data = { |
130 | .enc = tls1_enc, | 129 | .enc = tls1_enc, |
@@ -759,8 +758,7 @@ ssl_check_serverhello_tlsext(SSL *s) | |||
759 | * ClientHello, and other operations depend on the result, we need to handle | 758 | * ClientHello, and other operations depend on the result, we need to handle |
760 | * any TLS session ticket extension at the same time. | 759 | * any TLS session ticket extension at the same time. |
761 | * | 760 | * |
762 | * session_id: points at the session ID in the ClientHello. | 761 | * session_id: a CBS containing the session ID. |
763 | * session_id_len: the length of the session ID. | ||
764 | * ext_block: a CBS for the ClientHello extensions block. | 762 | * ext_block: a CBS for the ClientHello extensions block. |
765 | * ret: (output) on return, if a ticket was decrypted, then this is set to | 763 | * ret: (output) on return, if a ticket was decrypted, then this is set to |
766 | * point to the resulting session. | 764 | * point to the resulting session. |
@@ -787,8 +785,7 @@ ssl_check_serverhello_tlsext(SSL *s) | |||
787 | * Otherwise, s->internal->tlsext_ticket_expected is set to 0. | 785 | * Otherwise, s->internal->tlsext_ticket_expected is set to 0. |
788 | */ | 786 | */ |
789 | int | 787 | int |
790 | tls1_process_ticket(SSL *s, const unsigned char *session_id, int session_id_len, | 788 | tls1_process_ticket(SSL *s, CBS *session_id, CBS *ext_block, SSL_SESSION **ret) |
791 | CBS *ext_block, SSL_SESSION **ret) | ||
792 | { | 789 | { |
793 | CBS extensions, ext_data; | 790 | CBS extensions, ext_data; |
794 | uint16_t ext_type = 0; | 791 | uint16_t ext_type = 0; |
@@ -845,8 +842,8 @@ tls1_process_ticket(SSL *s, const unsigned char *session_id, int session_id_len, | |||
845 | return 2; | 842 | return 2; |
846 | } | 843 | } |
847 | 844 | ||
848 | r = tls_decrypt_ticket(s, CBS_data(&ext_data), CBS_len(&ext_data), | 845 | r = tls_decrypt_ticket(s, session_id, CBS_data(&ext_data), |
849 | session_id, session_id_len, ret); | 846 | CBS_len(&ext_data), ret); |
850 | switch (r) { | 847 | switch (r) { |
851 | case 2: /* ticket couldn't be decrypted */ | 848 | case 2: /* ticket couldn't be decrypted */ |
852 | s->internal->tlsext_ticket_expected = 1; | 849 | s->internal->tlsext_ticket_expected = 1; |
@@ -863,10 +860,9 @@ tls1_process_ticket(SSL *s, const unsigned char *session_id, int session_id_len, | |||
863 | 860 | ||
864 | /* tls_decrypt_ticket attempts to decrypt a session ticket. | 861 | /* tls_decrypt_ticket attempts to decrypt a session ticket. |
865 | * | 862 | * |
863 | * session_id: a CBS containing the session ID. | ||
866 | * etick: points to the body of the session ticket extension. | 864 | * etick: points to the body of the session ticket extension. |
867 | * eticklen: the length of the session tickets extenion. | 865 | * eticklen: the length of the session tickets extenion. |
868 | * sess_id: points at the session ID. | ||
869 | * sesslen: the length of the session ID. | ||
870 | * psess: (output) on return, if a ticket was decrypted, then this is set to | 866 | * psess: (output) on return, if a ticket was decrypted, then this is set to |
871 | * point to the resulting session. | 867 | * point to the resulting session. |
872 | * | 868 | * |
@@ -877,10 +873,11 @@ tls1_process_ticket(SSL *s, const unsigned char *session_id, int session_id_len, | |||
877 | * 4: same as 3, but the ticket needs to be renewed. | 873 | * 4: same as 3, but the ticket needs to be renewed. |
878 | */ | 874 | */ |
879 | static int | 875 | static int |
880 | tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, | 876 | tls_decrypt_ticket(SSL *s, CBS *session_id, const unsigned char *etick, |
881 | const unsigned char *sess_id, int sesslen, SSL_SESSION **psess) | 877 | int eticklen, SSL_SESSION **psess) |
882 | { | 878 | { |
883 | SSL_SESSION *sess; | 879 | SSL_SESSION *sess = NULL; |
880 | size_t session_id_len = 0; | ||
884 | unsigned char *sdec = NULL; | 881 | unsigned char *sdec = NULL; |
885 | const unsigned char *p; | 882 | const unsigned char *p; |
886 | int slen, mlen, renew_ticket = 0; | 883 | int slen, mlen, renew_ticket = 0; |
@@ -988,10 +985,14 @@ tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, | |||
988 | * the ticket has been accepted. So we copy it to the session structure. | 985 | * the ticket has been accepted. So we copy it to the session structure. |
989 | * If it is empty set length to zero as required by standard. | 986 | * If it is empty set length to zero as required by standard. |
990 | */ | 987 | */ |
991 | if (sesslen) | 988 | if (!CBS_write_bytes(session_id, sess->session_id, |
992 | memcpy(sess->session_id, sess_id, sesslen); | 989 | sizeof(sess->session_id), &session_id_len)) |
993 | sess->session_id_length = sesslen; | 990 | goto err; |
991 | sess->session_id_length = (unsigned int)session_id_len; | ||
992 | |||
994 | *psess = sess; | 993 | *psess = sess; |
994 | sess = NULL; | ||
995 | |||
995 | if (renew_ticket) | 996 | if (renew_ticket) |
996 | ret = 4; | 997 | ret = 4; |
997 | else | 998 | else |
@@ -1006,6 +1007,7 @@ tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, | |||
1006 | free(sdec); | 1007 | free(sdec); |
1007 | HMAC_CTX_cleanup(&hctx); | 1008 | HMAC_CTX_cleanup(&hctx); |
1008 | EVP_CIPHER_CTX_cleanup(&ctx); | 1009 | EVP_CIPHER_CTX_cleanup(&ctx); |
1010 | SSL_SESSION_free(sess); | ||
1009 | 1011 | ||
1010 | if (ret == 2) | 1012 | if (ret == 2) |
1011 | ERR_clear_error(); | 1013 | ERR_clear_error(); |