提交 1266eefd 编写于 作者: M Matt Caswell

Various style updates following extensions refactor

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz
Reviewed-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 89247375
此差异已折叠。
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "../ssl_locl.h" #include "../ssl_locl.h"
#include "statem_locl.h" #include "statem_locl.h"
int tls_construct_client_renegotiate(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, int *al)
{ {
/* Add RI if renegotiating */ /* Add RI if renegotiating */
if (!s->renegotiate) if (!s->renegotiate)
...@@ -30,7 +30,7 @@ int tls_construct_client_renegotiate(SSL *s, WPACKET *pkt, int *al) ...@@ -30,7 +30,7 @@ int tls_construct_client_renegotiate(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_client_server_name(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->tlsext_hostname == NULL) if (s->tlsext_hostname == NULL)
return 1; return 1;
...@@ -54,7 +54,7 @@ int tls_construct_client_server_name(SSL *s, WPACKET *pkt, int *al) ...@@ -54,7 +54,7 @@ int tls_construct_client_server_name(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_SRP #ifndef OPENSSL_NO_SRP
int tls_construct_client_srp(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_srp(SSL *s, WPACKET *pkt, int *al)
{ {
/* Add SRP username if there is one */ /* Add SRP username if there is one */
if (s->srp_ctx.login == NULL) if (s->srp_ctx.login == NULL)
...@@ -81,8 +81,7 @@ int tls_construct_client_srp(SSL *s, WPACKET *pkt, int *al) ...@@ -81,8 +81,7 @@ int tls_construct_client_srp(SSL *s, WPACKET *pkt, int *al)
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
static int use_ecc(SSL *s) static int use_ecc(SSL *s)
{ {
int using_ecc = 0; int i, end;
int i;
unsigned long alg_k, alg_a; unsigned long alg_k, alg_a;
STACK_OF(SSL_CIPHER) *cipher_stack = NULL; STACK_OF(SSL_CIPHER) *cipher_stack = NULL;
...@@ -90,26 +89,23 @@ static int use_ecc(SSL *s) ...@@ -90,26 +89,23 @@ static int use_ecc(SSL *s)
if (s->version == SSL3_VERSION) if (s->version == SSL3_VERSION)
return 0; return 0;
cipher_stack = SSL_get_ciphers(s); cipher_stack = SSL_get_ciphers(s);
end = sk_SSL_CIPHER_num(cipher_stack);
for (i = 0; i < sk_SSL_CIPHER_num(cipher_stack); i++) { for (i = 0; i < end; i++) {
const SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i); const SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i);
alg_k = c->algorithm_mkey; alg_k = c->algorithm_mkey;
alg_a = c->algorithm_auth; alg_a = c->algorithm_auth;
if ((alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) if ((alg_k & (SSL_kECDHE | SSL_kECDHEPSK))
|| (alg_a & SSL_aECDSA) || (alg_a & SSL_aECDSA)
|| c->min_tls >= TLS1_3_VERSION) { || c->min_tls >= TLS1_3_VERSION)
using_ecc = 1;
break; break;
} }
}
return using_ecc; return i < end;
} }
int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
{ {
const unsigned char *pformats; const unsigned char *pformats;
size_t num_formats; size_t num_formats;
...@@ -118,7 +114,6 @@ int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) ...@@ -118,7 +114,6 @@ int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
/* Add TLS extension ECPointFormats to the ClientHello message */ /* Add TLS extension ECPointFormats to the ClientHello message */
tls1_get_formatlist(s, &pformats, &num_formats); tls1_get_formatlist(s, &pformats, &num_formats);
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_ec_point_formats) if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_ec_point_formats)
...@@ -134,7 +129,7 @@ int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) ...@@ -134,7 +129,7 @@ int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
} }
int tls_construct_client_supported_groups(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, int *al)
{ {
const unsigned char *pcurves = NULL, *pcurvestmp; const unsigned char *pcurves = NULL, *pcurvestmp;
size_t num_curves = 0, i; size_t num_curves = 0, i;
...@@ -183,7 +178,7 @@ int tls_construct_client_supported_groups(SSL *s, WPACKET *pkt, int *al) ...@@ -183,7 +178,7 @@ int tls_construct_client_supported_groups(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_client_session_ticket(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt, int *al)
{ {
size_t ticklen; size_t ticklen;
...@@ -222,7 +217,7 @@ int tls_construct_client_session_ticket(SSL *s, WPACKET *pkt, int *al) ...@@ -222,7 +217,7 @@ int tls_construct_client_session_ticket(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt, int *al)
{ {
size_t salglen; size_t salglen;
const unsigned char *salg; const unsigned char *salg;
...@@ -231,7 +226,6 @@ int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al) ...@@ -231,7 +226,6 @@ int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
salglen = tls12_get_psigalgs(s, &salg); salglen = tls12_get_psigalgs(s, &salg);
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_signature_algorithms) if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_signature_algorithms)
/* Sub-packet for sig-algs extension */ /* Sub-packet for sig-algs extension */
|| !WPACKET_start_sub_packet_u16(pkt) || !WPACKET_start_sub_packet_u16(pkt)
...@@ -248,7 +242,7 @@ int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al) ...@@ -248,7 +242,7 @@ int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_status_request(SSL *s, WPACKET *pkt, int *al)
{ {
int i; int i;
...@@ -266,11 +260,9 @@ int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al) ...@@ -266,11 +260,9 @@ int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al)
} }
for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) {
unsigned char *idbytes; unsigned char *idbytes;
int idlen; OCSP_RESPID *id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);
OCSP_RESPID *id; int idlen = i2d_OCSP_RESPID(id, NULL);
id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);
idlen = i2d_OCSP_RESPID(id, NULL);
if (idlen <= 0 if (idlen <= 0
/* Sub-packet for an individual id */ /* Sub-packet for an individual id */
|| !WPACKET_sub_allocate_bytes_u16(pkt, idlen, &idbytes) || !WPACKET_sub_allocate_bytes_u16(pkt, idlen, &idbytes)
...@@ -312,7 +304,7 @@ int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al) ...@@ -312,7 +304,7 @@ int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al)
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_construct_client_npn(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_npn(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->ctx->next_proto_select_cb == NULL || s->s3->tmp.finish_md_len != 0) if (s->ctx->next_proto_select_cb == NULL || s->s3->tmp.finish_md_len != 0)
return 1; return 1;
...@@ -331,7 +323,7 @@ int tls_construct_client_npn(SSL *s, WPACKET *pkt, int *al) ...@@ -331,7 +323,7 @@ int tls_construct_client_npn(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_client_alpn(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, int *al)
{ {
s->s3->alpn_sent = 0; s->s3->alpn_sent = 0;
...@@ -359,11 +351,10 @@ int tls_construct_client_alpn(SSL *s, WPACKET *pkt, int *al) ...@@ -359,11 +351,10 @@ int tls_construct_client_alpn(SSL *s, WPACKET *pkt, int *al)
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, int *al)
{ {
STACK_OF(SRTP_PROTECTION_PROFILE) *clnt = SSL_get_srtp_profiles(s); STACK_OF(SRTP_PROTECTION_PROFILE) *clnt = SSL_get_srtp_profiles(s);
SRTP_PROTECTION_PROFILE *prof; int i, end;
int i, ct;
if (clnt == NULL) if (clnt == NULL)
return 1; return 1;
...@@ -376,9 +367,12 @@ int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al) ...@@ -376,9 +367,12 @@ int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al)
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_USE_SRTP, ERR_R_INTERNAL_ERROR); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_USE_SRTP, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
ct = sk_SRTP_PROTECTION_PROFILE_num(clnt);
for (i = 0; i < ct; i++) { end = sk_SRTP_PROTECTION_PROFILE_num(clnt);
prof = sk_SRTP_PROTECTION_PROFILE_value(clnt, i); for (i = 0; i < end; i++) {
const SRTP_PROTECTION_PROFILE *prof =
sk_SRTP_PROTECTION_PROFILE_value(clnt, i);
if (prof == NULL || !WPACKET_put_bytes_u16(pkt, prof->id)) { if (prof == NULL || !WPACKET_put_bytes_u16(pkt, prof->id)) {
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_USE_SRTP, ERR_R_INTERNAL_ERROR); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_USE_SRTP, ERR_R_INTERNAL_ERROR);
return 0; return 0;
...@@ -396,7 +390,7 @@ int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al) ...@@ -396,7 +390,7 @@ int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_client_etm(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_etm(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->options & SSL_OP_NO_ENCRYPT_THEN_MAC) if (s->options & SSL_OP_NO_ENCRYPT_THEN_MAC)
return 1; return 1;
...@@ -411,7 +405,7 @@ int tls_construct_client_etm(SSL *s, WPACKET *pkt, int *al) ...@@ -411,7 +405,7 @@ int tls_construct_client_etm(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_CT #ifndef OPENSSL_NO_CT
int tls_construct_client_sct(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_sct(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->ct_validation_callback == NULL) if (s->ct_validation_callback == NULL)
return 1; return 1;
...@@ -426,7 +420,7 @@ int tls_construct_client_sct(SSL *s, WPACKET *pkt, int *al) ...@@ -426,7 +420,7 @@ int tls_construct_client_sct(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_client_ems(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_ems(SSL *s, WPACKET *pkt, int *al)
{ {
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_extended_master_secret) if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_extended_master_secret)
|| !WPACKET_put_bytes_u16(pkt, 0)) { || !WPACKET_put_bytes_u16(pkt, 0)) {
...@@ -437,7 +431,7 @@ int tls_construct_client_ems(SSL *s, WPACKET *pkt, int *al) ...@@ -437,7 +431,7 @@ int tls_construct_client_ems(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_client_supported_versions(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt, int *al)
{ {
int currv, min_version, max_version, reason; int currv, min_version, max_version, reason;
...@@ -484,7 +478,7 @@ int tls_construct_client_supported_versions(SSL *s, WPACKET *pkt, int *al) ...@@ -484,7 +478,7 @@ int tls_construct_client_supported_versions(SSL *s, WPACKET *pkt, int *al)
} }
int tls_construct_client_key_share(SSL *s, WPACKET *pkt, int *al) int tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, int *al)
{ {
size_t i, sharessent = 0, num_curves = 0; size_t i, sharessent = 0, num_curves = 0;
const unsigned char *pcurves = NULL; const unsigned char *pcurves = NULL;
...@@ -569,7 +563,10 @@ int tls_construct_client_key_share(SSL *s, WPACKET *pkt, int *al) ...@@ -569,7 +563,10 @@ int tls_construct_client_key_share(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al) #define F5_WORKAROUND_MIN_MSG_LEN 0xff
#define F5_WORKAROUND_MAX_MSG_LEN 0x200
int tls_construct_ctos_padding(SSL *s, WPACKET *pkt, int *al)
{ {
unsigned char *padbytes; unsigned char *padbytes;
size_t hlen; size_t hlen;
...@@ -580,7 +577,7 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al) ...@@ -580,7 +577,7 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al)
/* /*
* Add padding to workaround bugs in F5 terminators. See * Add padding to workaround bugs in F5 terminators. See
* https://tools.ietf.org/html/draft-agl-tls-padding-03 NB: because this * https://tools.ietf.org/html/draft-agl-tls-padding-03 NB: because this
* code works out the length of all existing extensions it MUST always * code calculates the length of all existing extensions it MUST always
* appear last. * appear last.
*/ */
if (!WPACKET_get_total_written(pkt, &hlen)) { if (!WPACKET_get_total_written(pkt, &hlen)) {
...@@ -588,8 +585,14 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al) ...@@ -588,8 +585,14 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al)
return 0; return 0;
} }
if (hlen > 0xff && hlen < 0x200) { if (hlen > F5_WORKAROUND_MIN_MSG_LEN && hlen < F5_WORKAROUND_MAX_MSG_LEN) {
hlen = 0x200 - hlen; /* Calculate the amond of padding we need to add */
hlen = F5_WORKAROUND_MAX_MSG_LEN - hlen;
/*
* Take off the size of extension header itself (2 bytes for type and
* 2 bytes for length bytes)
*/
if (hlen >= 4) if (hlen >= 4)
hlen -= 4; hlen -= 4;
else else
...@@ -609,7 +612,7 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al) ...@@ -609,7 +612,7 @@ int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al)
/* /*
* Parse the server's renegotiation binding and abort if it's not right * Parse the server's renegotiation binding and abort if it's not right
*/ */
int tls_parse_server_renegotiate(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, int *al)
{ {
size_t expected_len = s->s3->previous_client_finished_len size_t expected_len = s->s3->previous_client_finished_len
+ s->s3->previous_server_finished_len; + s->s3->previous_server_finished_len;
...@@ -666,7 +669,7 @@ int tls_parse_server_renegotiate(SSL *s, PACKET *pkt, int *al) ...@@ -666,7 +669,7 @@ int tls_parse_server_renegotiate(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
int tls_parse_server_server_name(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, int *al)
{ {
if (s->tlsext_hostname == NULL || PACKET_remaining(pkt) > 0) { if (s->tlsext_hostname == NULL || PACKET_remaining(pkt) > 0) {
*al = SSL_AD_UNRECOGNIZED_NAME; *al = SSL_AD_UNRECOGNIZED_NAME;
...@@ -689,7 +692,7 @@ int tls_parse_server_server_name(SSL *s, PACKET *pkt, int *al) ...@@ -689,7 +692,7 @@ int tls_parse_server_server_name(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_parse_server_ec_pt_formats(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, int *al)
{ {
unsigned int ecpointformatlist_length; unsigned int ecpointformatlist_length;
PACKET ecptformatlist; PACKET ecptformatlist;
...@@ -724,26 +727,28 @@ int tls_parse_server_ec_pt_formats(SSL *s, PACKET *pkt, int *al) ...@@ -724,26 +727,28 @@ int tls_parse_server_ec_pt_formats(SSL *s, PACKET *pkt, int *al)
} }
#endif #endif
int tls_parse_server_session_ticket(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, int *al)
{ {
if (s->tls_session_ticket_ext_cb && if (s->tls_session_ticket_ext_cb != NULL &&
!s->tls_session_ticket_ext_cb(s, PACKET_data(pkt), !s->tls_session_ticket_ext_cb(s, PACKET_data(pkt),
PACKET_remaining(pkt), PACKET_remaining(pkt),
s->tls_session_ticket_ext_cb_arg)) { s->tls_session_ticket_ext_cb_arg)) {
*al = SSL_AD_INTERNAL_ERROR; *al = SSL_AD_INTERNAL_ERROR;
return 0; return 0;
} }
if (!tls_use_ticket(s) || PACKET_remaining(pkt) > 0) { if (!tls_use_ticket(s) || PACKET_remaining(pkt) > 0) {
*al = SSL_AD_UNSUPPORTED_EXTENSION; *al = SSL_AD_UNSUPPORTED_EXTENSION;
return 0; return 0;
} }
s->tlsext_ticket_expected = 1; s->tlsext_ticket_expected = 1;
return 1; return 1;
} }
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_parse_server_status_request(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, int *al)
{ {
/* /*
* MUST be empty and only sent if we've requested a status * MUST be empty and only sent if we've requested a status
...@@ -762,7 +767,7 @@ int tls_parse_server_status_request(SSL *s, PACKET *pkt, int *al) ...@@ -762,7 +767,7 @@ int tls_parse_server_status_request(SSL *s, PACKET *pkt, int *al)
#ifndef OPENSSL_NO_CT #ifndef OPENSSL_NO_CT
int tls_parse_server_sct(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_sct(SSL *s, PACKET *pkt, int *al)
{ {
/* /*
* Only take it if we asked for it - i.e if there is no CT validation * Only take it if we asked for it - i.e if there is no CT validation
...@@ -773,10 +778,9 @@ int tls_parse_server_sct(SSL *s, PACKET *pkt, int *al) ...@@ -773,10 +778,9 @@ int tls_parse_server_sct(SSL *s, PACKET *pkt, int *al)
size_t size = PACKET_remaining(pkt); size_t size = PACKET_remaining(pkt);
/* Simply copy it off for later processing */ /* Simply copy it off for later processing */
if (s->tlsext_scts != NULL) {
OPENSSL_free(s->tlsext_scts); OPENSSL_free(s->tlsext_scts);
s->tlsext_scts = NULL; s->tlsext_scts = NULL;
}
s->tlsext_scts_len = size; s->tlsext_scts_len = size;
if (size > 0) { if (size > 0) {
s->tlsext_scts = OPENSSL_malloc(size); s->tlsext_scts = OPENSSL_malloc(size);
...@@ -816,12 +820,13 @@ static int ssl_next_proto_validate(PACKET *pkt) ...@@ -816,12 +820,13 @@ static int ssl_next_proto_validate(PACKET *pkt)
return 1; return 1;
} }
int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_npn(SSL *s, PACKET *pkt, int *al)
{ {
unsigned char *selected; unsigned char *selected;
unsigned char selected_len; unsigned char selected_len;
PACKET tmppkt; PACKET tmppkt;
/* Check if we are in a renegotiation. If so ignore this extension */
if (s->s3->tmp.finish_md_len != 0) if (s->s3->tmp.finish_md_len != 0)
return 1; return 1;
...@@ -830,6 +835,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al) ...@@ -830,6 +835,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al)
*al = SSL_AD_UNSUPPORTED_EXTENSION; *al = SSL_AD_UNSUPPORTED_EXTENSION;
return 0; return 0;
} }
/* The data must be valid */ /* The data must be valid */
tmppkt = *pkt; tmppkt = *pkt;
if (!ssl_next_proto_validate(&tmppkt)) { if (!ssl_next_proto_validate(&tmppkt)) {
...@@ -844,6 +850,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al) ...@@ -844,6 +850,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al)
*al = SSL_AD_INTERNAL_ERROR; *al = SSL_AD_INTERNAL_ERROR;
return 0; return 0;
} }
/* /*
* Could be non-NULL if server has sent multiple NPN extensions in * Could be non-NULL if server has sent multiple NPN extensions in
* a single Serverhello * a single Serverhello
...@@ -863,7 +870,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al) ...@@ -863,7 +870,7 @@ int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al)
} }
#endif #endif
int tls_parse_server_alpn(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, int *al)
{ {
size_t len; size_t len;
...@@ -900,15 +907,15 @@ int tls_parse_server_alpn(SSL *s, PACKET *pkt, int *al) ...@@ -900,15 +907,15 @@ int tls_parse_server_alpn(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, int *al)
{ {
unsigned int id, ct, mki; unsigned int id, ct, mki;
int i; int i;
STACK_OF(SRTP_PROTECTION_PROFILE) *clnt; STACK_OF(SRTP_PROTECTION_PROFILE) *clnt;
SRTP_PROTECTION_PROFILE *prof; SRTP_PROTECTION_PROFILE *prof;
if (!PACKET_get_net_2(pkt, &ct) if (!PACKET_get_net_2(pkt, &ct) || ct != 2
|| ct != 2 || !PACKET_get_net_2(pkt, &id) || !PACKET_get_net_2(pkt, &id)
|| !PACKET_get_1(pkt, &mki) || !PACKET_get_1(pkt, &mki)
|| PACKET_remaining(pkt) != 0) { || PACKET_remaining(pkt) != 0) {
SSLerr(SSL_F_TLS_PARSE_SERVER_USE_SRTP, SSLerr(SSL_F_TLS_PARSE_SERVER_USE_SRTP,
...@@ -924,9 +931,8 @@ int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -924,9 +931,8 @@ int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al)
return 0; return 0;
} }
clnt = SSL_get_srtp_profiles(s);
/* Throw an error if the server gave us an unsolicited extension */ /* Throw an error if the server gave us an unsolicited extension */
clnt = SSL_get_srtp_profiles(s);
if (clnt == NULL) { if (clnt == NULL) {
SSLerr(SSL_F_TLS_PARSE_SERVER_USE_SRTP, SSL_R_NO_SRTP_PROFILES); SSLerr(SSL_F_TLS_PARSE_SERVER_USE_SRTP, SSL_R_NO_SRTP_PROFILES);
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
...@@ -954,7 +960,7 @@ int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -954,7 +960,7 @@ int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al)
} }
#endif #endif
int tls_parse_server_etm(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_etm(SSL *s, PACKET *pkt, int *al)
{ {
/* Ignore if inappropriate ciphersuite */ /* Ignore if inappropriate ciphersuite */
if (!(s->options & SSL_OP_NO_ENCRYPT_THEN_MAC) if (!(s->options & SSL_OP_NO_ENCRYPT_THEN_MAC)
...@@ -965,7 +971,7 @@ int tls_parse_server_etm(SSL *s, PACKET *pkt, int *al) ...@@ -965,7 +971,7 @@ int tls_parse_server_etm(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
int tls_parse_server_ems(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_ems(SSL *s, PACKET *pkt, int *al)
{ {
s->s3->flags |= TLS1_FLAGS_RECEIVED_EXTMS; s->s3->flags |= TLS1_FLAGS_RECEIVED_EXTMS;
if (!s->hit) if (!s->hit)
...@@ -974,7 +980,7 @@ int tls_parse_server_ems(SSL *s, PACKET *pkt, int *al) ...@@ -974,7 +980,7 @@ int tls_parse_server_ems(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
int tls_parse_server_key_share(SSL *s, PACKET *pkt, int *al) int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, int *al)
{ {
unsigned int group_id; unsigned int group_id;
PACKET encoded_pt; PACKET encoded_pt;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* /*
* Parse the client's renegotiation binding and abort if it's not right * Parse the client's renegotiation binding and abort if it's not right
*/ */
int tls_parse_client_renegotiate(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, int *al)
{ {
unsigned int ilen; unsigned int ilen;
const unsigned char *data; const unsigned char *data;
...@@ -49,12 +49,7 @@ int tls_parse_client_renegotiate(SSL *s, PACKET *pkt, int *al) ...@@ -49,12 +49,7 @@ int tls_parse_client_renegotiate(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al) /*-
{
unsigned int servname_type;
PACKET sni, hostname;
/*-
* The servername extension is treated as follows: * The servername extension is treated as follows:
* *
* - Only the hostname type is supported with a maximum length of 255. * - Only the hostname type is supported with a maximum length of 255.
...@@ -76,8 +71,12 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al) ...@@ -76,8 +71,12 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al)
* session, i.e. when the session has been established with a servername * session, i.e. when the session has been established with a servername
* extension. * extension.
* - On session reconnect, the servername extension may be absent. * - On session reconnect, the servername extension may be absent.
*
*/ */
int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, int *al)
{
unsigned int servname_type;
PACKET sni, hostname;
if (!PACKET_as_length_prefixed_2(pkt, &sni) if (!PACKET_as_length_prefixed_2(pkt, &sni)
/* ServerNameList must be at least 1 byte long. */ /* ServerNameList must be at least 1 byte long. */
|| PACKET_remaining(&sni) == 0) { || PACKET_remaining(&sni) == 0) {
...@@ -88,7 +87,7 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al) ...@@ -88,7 +87,7 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al)
/* /*
* Although the server_name extension was intended to be * Although the server_name extension was intended to be
* extensible to new name types, RFC 4366 defined the * extensible to new name types, RFC 4366 defined the
* syntax inextensibility and OpenSSL 1.0.x parses it as * syntax inextensibly and OpenSSL 1.0.x parses it as
* such. * such.
* RFC 6066 corrected the mistake but adding new name types * RFC 6066 corrected the mistake but adding new name types
* is nevertheless no longer feasible, so act as if no other * is nevertheless no longer feasible, so act as if no other
...@@ -135,7 +134,7 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al) ...@@ -135,7 +134,7 @@ int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_SRP #ifndef OPENSSL_NO_SRP
int tls_parse_client_srp(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_srp(SSL *s, PACKET *pkt, int *al)
{ {
PACKET srp_I; PACKET srp_I;
...@@ -159,7 +158,7 @@ int tls_parse_client_srp(SSL *s, PACKET *pkt, int *al) ...@@ -159,7 +158,7 @@ int tls_parse_client_srp(SSL *s, PACKET *pkt, int *al)
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_parse_client_ec_pt_formats(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, int *al)
{ {
PACKET ec_point_format_list; PACKET ec_point_format_list;
...@@ -182,7 +181,7 @@ int tls_parse_client_ec_pt_formats(SSL *s, PACKET *pkt, int *al) ...@@ -182,7 +181,7 @@ int tls_parse_client_ec_pt_formats(SSL *s, PACKET *pkt, int *al)
} }
#endif /* OPENSSL_NO_EC */ #endif /* OPENSSL_NO_EC */
int tls_parse_client_session_ticket(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, int *al)
{ {
if (s->tls_session_ticket_ext_cb && if (s->tls_session_ticket_ext_cb &&
!s->tls_session_ticket_ext_cb(s, PACKET_data(pkt), !s->tls_session_ticket_ext_cb(s, PACKET_data(pkt),
...@@ -195,7 +194,7 @@ int tls_parse_client_session_ticket(SSL *s, PACKET *pkt, int *al) ...@@ -195,7 +194,7 @@ int tls_parse_client_session_ticket(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
int tls_parse_client_sig_algs(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, int *al)
{ {
PACKET supported_sig_algs; PACKET supported_sig_algs;
...@@ -216,16 +215,23 @@ int tls_parse_client_sig_algs(SSL *s, PACKET *pkt, int *al) ...@@ -216,16 +215,23 @@ int tls_parse_client_sig_algs(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, int *al)
{ {
PACKET responder_id_list, exts;
if (!PACKET_get_1(pkt, (unsigned int *)&s->tlsext_status_type)) { if (!PACKET_get_1(pkt, (unsigned int *)&s->tlsext_status_type)) {
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
return 0; return 0;
} }
if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { if (s->tlsext_status_type != TLSEXT_STATUSTYPE_ocsp) {
const unsigned char *ext_data; /*
PACKET responder_id_list, exts; * We don't know what to do with any other type so ignore it.
*/
s->tlsext_status_type = -1;
return 1;
}
if (!PACKET_get_length_prefixed_2 (pkt, &responder_id_list)) { if (!PACKET_get_length_prefixed_2 (pkt, &responder_id_list)) {
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
return 0; return 0;
...@@ -251,8 +257,7 @@ int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al) ...@@ -251,8 +257,7 @@ int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al)
PACKET responder_id; PACKET responder_id;
const unsigned char *id_data; const unsigned char *id_data;
if (!PACKET_get_length_prefixed_2(&responder_id_list, if (!PACKET_get_length_prefixed_2(&responder_id_list, &responder_id)
&responder_id)
|| PACKET_remaining(&responder_id) == 0) { || PACKET_remaining(&responder_id) == 0) {
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
return 0; return 0;
...@@ -287,33 +292,26 @@ int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al) ...@@ -287,33 +292,26 @@ int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al)
} }
if (PACKET_remaining(&exts) > 0) { if (PACKET_remaining(&exts) > 0) {
ext_data = PACKET_data(&exts); const unsigned char *ext_data = PACKET_data(&exts);
sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts,
X509_EXTENSION_free); X509_EXTENSION_free);
s->tlsext_ocsp_exts = s->tlsext_ocsp_exts =
d2i_X509_EXTENSIONS(NULL, &ext_data, d2i_X509_EXTENSIONS(NULL, &ext_data, (int)PACKET_remaining(&exts));
(int)PACKET_remaining(&exts));
if (s->tlsext_ocsp_exts == NULL || ext_data != PACKET_end(&exts)) { if (s->tlsext_ocsp_exts == NULL || ext_data != PACKET_end(&exts)) {
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
return 0; return 0;
} }
} }
} else {
/*
* We don't know what to do with any other type so ignore it.
*/
s->tlsext_status_type = -1;
}
return 1; return 1;
} }
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_parse_client_npn(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_npn(SSL *s, PACKET *pkt, int *al)
{ {
if (s->s3->tmp.finish_md_len == 0) { /*
/*-
* We shouldn't accept this extension on a * We shouldn't accept this extension on a
* renegotiation. * renegotiation.
* *
...@@ -330,20 +328,19 @@ int tls_parse_client_npn(SSL *s, PACKET *pkt, int *al) ...@@ -330,20 +328,19 @@ int tls_parse_client_npn(SSL *s, PACKET *pkt, int *al)
* in the Hello protocol round, well before a new * in the Hello protocol round, well before a new
* Finished message could have been computed.) * Finished message could have been computed.)
*/ */
if (s->s3->tmp.finish_md_len == 0)
s->s3->next_proto_neg_seen = 1; s->s3->next_proto_neg_seen = 1;
}
return 1; return 1;
} }
#endif #endif
/* /*
* Save the ALPN extension in a ClientHello. * Save the ALPN extension in a ClientHello.|pkt| holds the contents of the ALPN
* pkt: the contents of the ALPN extension, not including type and length. * extension, not including type and length. |al| is a pointer to the alert
* al: a pointer to the alert value to send in the event of a failure. * value to send in the event of a failure. Returns: 1 on success, 0 on error.
* returns: 1 on success, 0 on error.
*/ */
int tls_parse_client_alpn(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, int *al)
{ {
PACKET protocol_list, save_protocol_list, protocol; PACKET protocol_list, save_protocol_list, protocol;
...@@ -376,9 +373,8 @@ int tls_parse_client_alpn(SSL *s, PACKET *pkt, int *al) ...@@ -376,9 +373,8 @@ int tls_parse_client_alpn(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, int *al)
{ {
SRTP_PROTECTION_PROFILE *sprof;
STACK_OF(SRTP_PROTECTION_PROFILE) *srvr; STACK_OF(SRTP_PROTECTION_PROFILE) *srvr;
unsigned int ct, mki_len, id; unsigned int ct, mki_len, id;
int i, srtp_pref; int i, srtp_pref;
...@@ -389,8 +385,8 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -389,8 +385,8 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
/* Pull off the length of the cipher suite list and check it is even */ /* Pull off the length of the cipher suite list and check it is even */
if (!PACKET_get_net_2(pkt, &ct) if (!PACKET_get_net_2(pkt, &ct) || (ct & 1) != 0
|| (ct & 1) != 0 || !PACKET_get_sub_packet(pkt, &subpkt, ct)) { || !PACKET_get_sub_packet(pkt, &subpkt, ct)) {
SSLerr(SSL_F_TLS_PARSE_CLIENT_USE_SRTP, SSLerr(SSL_F_TLS_PARSE_CLIENT_USE_SRTP,
SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST);
*al = SSL_AD_DECODE_ERROR; *al = SSL_AD_DECODE_ERROR;
...@@ -417,7 +413,9 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -417,7 +413,9 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al)
* does nothing. * does nothing.
*/ */
for (i = 0; i < srtp_pref; i++) { for (i = 0; i < srtp_pref; i++) {
sprof = sk_SRTP_PROTECTION_PROFILE_value(srvr, i); const SRTP_PROTECTION_PROFILE *sprof =
sk_SRTP_PROTECTION_PROFILE_value(srvr, i);
if (sprof->id == id) { if (sprof->id == id) {
s->srtp_profile = sprof; s->srtp_profile = sprof;
srtp_pref = i; srtp_pref = i;
...@@ -426,9 +424,7 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -426,9 +424,7 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al)
} }
} }
/* /* Now extract the MKI value as a sanity check, but discard it for now */
* Now extract the MKI value as a sanity check, but discard it for now
*/
if (!PACKET_get_1(pkt, &mki_len)) { if (!PACKET_get_1(pkt, &mki_len)) {
SSLerr(SSL_F_TLS_PARSE_CLIENT_USE_SRTP, SSLerr(SSL_F_TLS_PARSE_CLIENT_USE_SRTP,
SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST);
...@@ -447,7 +443,7 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al) ...@@ -447,7 +443,7 @@ int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al)
} }
#endif #endif
int tls_parse_client_etm(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_etm(SSL *s, PACKET *pkt, int *al)
{ {
if (!(s->options & SSL_OP_NO_ENCRYPT_THEN_MAC)) if (!(s->options & SSL_OP_NO_ENCRYPT_THEN_MAC))
s->s3->flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC; s->s3->flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC;
...@@ -474,8 +470,8 @@ static int check_in_list(SSL *s, unsigned int group_id, ...@@ -474,8 +470,8 @@ static int check_in_list(SSL *s, unsigned int group_id,
unsigned int share_id = (groups[0] << 8) | (groups[1]); unsigned int share_id = (groups[0] << 8) | (groups[1]);
if (group_id == share_id if (group_id == share_id
&& (!checkallow || tls_curve_allowed(s, groups, && (!checkallow
SSL_SECOP_CURVE_CHECK))) { || tls_curve_allowed(s, groups, SSL_SECOP_CURVE_CHECK))) {
break; break;
} }
} }
...@@ -489,7 +485,7 @@ static int check_in_list(SSL *s, unsigned int group_id, ...@@ -489,7 +485,7 @@ static int check_in_list(SSL *s, unsigned int group_id,
* the raw PACKET data for the extension. Returns 1 on success or 0 on failure. * the raw PACKET data for the extension. Returns 1 on success or 0 on failure.
* If a failure occurs then |*al| is set to an appropriate alert value. * If a failure occurs then |*al| is set to an appropriate alert value.
*/ */
int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, int *al)
{ {
unsigned int group_id; unsigned int group_id;
PACKET key_share_list, encoded_pt; PACKET key_share_list, encoded_pt;
...@@ -585,6 +581,7 @@ int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al) ...@@ -585,6 +581,7 @@ int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al)
} else { } else {
/* Set up EVP_PKEY with named curve as parameters */ /* Set up EVP_PKEY with named curve as parameters */
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL); EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
if (pctx == NULL if (pctx == NULL
|| EVP_PKEY_paramgen_init(pctx) <= 0 || EVP_PKEY_paramgen_init(pctx) <= 0
|| EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, || EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx,
...@@ -615,7 +612,7 @@ int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al) ...@@ -615,7 +612,7 @@ int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_parse_client_supported_groups(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, int *al)
{ {
PACKET supported_groups_list; PACKET supported_groups_list;
...@@ -639,7 +636,7 @@ int tls_parse_client_supported_groups(SSL *s, PACKET *pkt, int *al) ...@@ -639,7 +636,7 @@ int tls_parse_client_supported_groups(SSL *s, PACKET *pkt, int *al)
} }
#endif #endif
int tls_parse_client_ems(SSL *s, PACKET *pkt, int *al) int tls_parse_ctos_ems(SSL *s, PACKET *pkt, int *al)
{ {
/* The extension must always be empty */ /* The extension must always be empty */
if (PACKET_remaining(pkt) != 0) { if (PACKET_remaining(pkt) != 0) {
...@@ -652,8 +649,10 @@ int tls_parse_client_ems(SSL *s, PACKET *pkt, int *al) ...@@ -652,8 +649,10 @@ int tls_parse_client_ems(SSL *s, PACKET *pkt, int *al)
return 1; return 1;
} }
/* Add the server's renegotiation binding */ /*
int tls_construct_server_renegotiate(SSL *s, WPACKET *pkt, int *al) * Add the server's renegotiation binding
*/
int tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt, int *al)
{ {
if (!s->s3->send_connection_binding) if (!s->s3->send_connection_binding)
return 1; return 1;
...@@ -674,7 +673,7 @@ int tls_construct_server_renegotiate(SSL *s, WPACKET *pkt, int *al) ...@@ -674,7 +673,7 @@ int tls_construct_server_renegotiate(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_server_server_name(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_server_name(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->hit || s->servername_done != 1 if (s->hit || s->servername_done != 1
|| s->session->tlsext_hostname == NULL) || s->session->tlsext_hostname == NULL)
...@@ -690,7 +689,7 @@ int tls_construct_server_server_name(SSL *s, WPACKET *pkt, int *al) ...@@ -690,7 +689,7 @@ int tls_construct_server_server_name(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
{ {
unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth; unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth;
...@@ -703,7 +702,6 @@ int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) ...@@ -703,7 +702,6 @@ int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
tls1_get_formatlist(s, &plist, &plistlen); tls1_get_formatlist(s, &plist, &plistlen);
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_ec_point_formats) if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_ec_point_formats)
|| !WPACKET_start_sub_packet_u16(pkt) || !WPACKET_start_sub_packet_u16(pkt)
|| !WPACKET_sub_memcpy_u8(pkt, plist, plistlen) || !WPACKET_sub_memcpy_u8(pkt, plist, plistlen)
...@@ -716,7 +714,7 @@ int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al) ...@@ -716,7 +714,7 @@ int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_server_session_ticket(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt, int *al)
{ {
if (!s->tlsext_ticket_expected || !tls_use_ticket(s)) { if (!s->tlsext_ticket_expected || !tls_use_ticket(s)) {
s->tlsext_ticket_expected = 0; s->tlsext_ticket_expected = 0;
...@@ -733,7 +731,7 @@ int tls_construct_server_session_ticket(SSL *s, WPACKET *pkt, int *al) ...@@ -733,7 +731,7 @@ int tls_construct_server_session_ticket(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_construct_server_status_request(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_status_request(SSL *s, WPACKET *pkt, int *al)
{ {
if (!s->tlsext_status_expected) if (!s->tlsext_status_expected)
return 1; return 1;
...@@ -750,7 +748,7 @@ int tls_construct_server_status_request(SSL *s, WPACKET *pkt, int *al) ...@@ -750,7 +748,7 @@ int tls_construct_server_status_request(SSL *s, WPACKET *pkt, int *al)
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_construct_server_next_proto_neg(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt, int *al)
{ {
const unsigned char *npa; const unsigned char *npa;
unsigned int npalen; unsigned int npalen;
...@@ -777,7 +775,7 @@ int tls_construct_server_next_proto_neg(SSL *s, WPACKET *pkt, int *al) ...@@ -777,7 +775,7 @@ int tls_construct_server_next_proto_neg(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_server_alpn(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->s3->alpn_selected == NULL) if (s->s3->alpn_selected == NULL)
return 1; return 1;
...@@ -798,7 +796,7 @@ int tls_construct_server_alpn(SSL *s, WPACKET *pkt, int *al) ...@@ -798,7 +796,7 @@ int tls_construct_server_alpn(SSL *s, WPACKET *pkt, int *al)
} }
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_construct_server_use_srtp(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, int *al)
{ {
if (s->srtp_profile == NULL) if (s->srtp_profile == NULL)
return 1; return 1;
...@@ -817,7 +815,7 @@ int tls_construct_server_use_srtp(SSL *s, WPACKET *pkt, int *al) ...@@ -817,7 +815,7 @@ int tls_construct_server_use_srtp(SSL *s, WPACKET *pkt, int *al)
} }
#endif #endif
int tls_construct_server_etm(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_etm(SSL *s, WPACKET *pkt, int *al)
{ {
if ((s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC) == 0) if ((s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC) == 0)
return 1; return 1;
...@@ -843,7 +841,7 @@ int tls_construct_server_etm(SSL *s, WPACKET *pkt, int *al) ...@@ -843,7 +841,7 @@ int tls_construct_server_etm(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_server_ems(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_ems(SSL *s, WPACKET *pkt, int *al)
{ {
if ((s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) == 0) if ((s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) == 0)
return 1; return 1;
...@@ -857,7 +855,7 @@ int tls_construct_server_ems(SSL *s, WPACKET *pkt, int *al) ...@@ -857,7 +855,7 @@ int tls_construct_server_ems(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_server_key_share(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_key_share(SSL *s, WPACKET *pkt, int *al)
{ {
unsigned char *encodedPoint; unsigned char *encodedPoint;
size_t encoded_pt_len = 0; size_t encoded_pt_len = 0;
...@@ -911,7 +909,7 @@ int tls_construct_server_key_share(SSL *s, WPACKET *pkt, int *al) ...@@ -911,7 +909,7 @@ int tls_construct_server_key_share(SSL *s, WPACKET *pkt, int *al)
return 1; return 1;
} }
int tls_construct_server_cryptopro_bug(SSL *s, WPACKET *pkt, int *al) int tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt, int *al)
{ {
const unsigned char cryptopro_ext[36] = { const unsigned char cryptopro_ext[36] = {
0xfd, 0xe8, /* 65000 */ 0xfd, 0xe8, /* 65000 */
......
...@@ -1132,7 +1132,7 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) ...@@ -1132,7 +1132,7 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
* server wants to resume. * server wants to resume.
*/ */
if (s->version >= TLS1_VERSION && !SSL_IS_TLS13(s) if (s->version >= TLS1_VERSION && !SSL_IS_TLS13(s)
&& s->tls_session_secret_cb && s->session->tlsext_tick) { && s->tls_session_secret_cb != NULL && s->session->tlsext_tick) {
const SSL_CIPHER *pref_cipher = NULL; const SSL_CIPHER *pref_cipher = NULL;
/* /*
* s->session->master_key_length is a size_t, but this is an int for * s->session->master_key_length is a size_t, but this is an int for
...@@ -3112,7 +3112,8 @@ static MSG_PROCESS_RETURN tls_process_encrypted_extensions(SSL *s, PACKET *pkt) ...@@ -3112,7 +3112,8 @@ static MSG_PROCESS_RETURN tls_process_encrypted_extensions(SSL *s, PACKET *pkt)
*/ */
if (!tls_collect_extensions(s, &extensions, if (!tls_collect_extensions(s, &extensions,
EXT_TLS1_3_ENCRYPTED_EXTENSIONS EXT_TLS1_3_ENCRYPTED_EXTENSIONS
| EXT_TLS1_3_CERTIFICATE, &rawexts, &al) | EXT_TLS1_3_CERTIFICATE,
&rawexts, &al)
|| !tls_parse_all_extensions(s, || !tls_parse_all_extensions(s,
EXT_TLS1_3_ENCRYPTED_EXTENSIONS EXT_TLS1_3_ENCRYPTED_EXTENSIONS
| EXT_TLS1_3_CERTIFICATE, | EXT_TLS1_3_CERTIFICATE,
......
...@@ -163,106 +163,106 @@ __owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context, ...@@ -163,106 +163,106 @@ __owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context,
int *al); int *al);
/* Server Extension processing */ /* Server Extension processing */
int tls_parse_client_renegotiate(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, int *al);
int tls_parse_client_server_name(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRP #ifndef OPENSSL_NO_SRP
int tls_parse_client_srp(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_srp(SSL *s, PACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_parse_client_ec_pt_formats(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, int *al);
int tls_parse_client_supported_groups(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_client_session_ticket(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, int *al);
int tls_parse_client_sig_algs(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_parse_client_status_request(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_parse_client_npn(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_npn(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_client_alpn(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_parse_client_use_srtp(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_client_etm(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_etm(SSL *s, PACKET *pkt, int *al);
int tls_parse_client_key_share(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, int *al);
int tls_parse_client_ems(SSL *s, PACKET *pkt, int *al); int tls_parse_ctos_ems(SSL *s, PACKET *pkt, int *al);
int tls_construct_server_renegotiate(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt, int *al);
int tls_construct_server_server_name(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_server_name(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_construct_server_ec_pt_formats(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_server_session_ticket(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_construct_server_status_request(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_status_request(SSL *s, WPACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_construct_server_next_proto_neg(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_server_alpn(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_construct_server_use_srtp(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_server_etm(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_etm(SSL *s, WPACKET *pkt, int *al);
int tls_construct_server_ems(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_ems(SSL *s, WPACKET *pkt, int *al);
int tls_construct_server_key_share(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_key_share(SSL *s, WPACKET *pkt, int *al);
/* /*
* Not in public headers as this is not an official extension. Only used when * Not in public headers as this is not an official extension. Only used when
* SSL_OP_CRYPTOPRO_TLSEXT_BUG is set. * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set.
*/ */
#define TLSEXT_TYPE_cryptopro_bug 0xfde8 #define TLSEXT_TYPE_cryptopro_bug 0xfde8
int tls_construct_server_cryptopro_bug(SSL *s, WPACKET *pkt, int *al); int tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt, int *al);
/* Client Extension processing */ /* Client Extension processing */
int tls_construct_client_renegotiate(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_server_name(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRP #ifndef OPENSSL_NO_SRP
int tls_construct_client_srp(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_srp(SSL *s, WPACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_construct_client_ec_pt_formats(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_supported_groups(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_client_session_ticket(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_sig_algs(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_construct_client_status_request(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_status_request(SSL *s, WPACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_construct_client_npn(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_npn(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_client_alpn(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_construct_client_use_srtp(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_client_etm(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_etm(SSL *s, WPACKET *pkt, int *al);
#ifndef OPENSSL_NO_CT #ifndef OPENSSL_NO_CT
int tls_construct_client_sct(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_sct(SSL *s, WPACKET *pkt, int *al);
#endif #endif
int tls_construct_client_ems(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_ems(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_supported_versions(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_key_share(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, int *al);
int tls_construct_client_padding(SSL *s, WPACKET *pkt, int *al); int tls_construct_ctos_padding(SSL *s, WPACKET *pkt, int *al);
int tls_parse_server_renegotiate(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, int *al);
int tls_parse_server_server_name(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
int tls_parse_server_ec_pt_formats(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_server_session_ticket(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_OCSP #ifndef OPENSSL_NO_OCSP
int tls_parse_server_status_request(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_CT #ifndef OPENSSL_NO_CT
int tls_parse_server_sct(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_sct(SSL *s, PACKET *pkt, int *al);
#endif #endif
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
int tls_parse_server_npn(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_npn(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_server_alpn(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, int *al);
#ifndef OPENSSL_NO_SRTP #ifndef OPENSSL_NO_SRTP
int tls_parse_server_use_srtp(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, int *al);
#endif #endif
int tls_parse_server_etm(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_etm(SSL *s, PACKET *pkt, int *al);
int tls_parse_server_ems(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_ems(SSL *s, PACKET *pkt, int *al);
int tls_parse_server_key_share(SSL *s, PACKET *pkt, int *al); int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, int *al);
...@@ -1078,10 +1078,6 @@ int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt) ...@@ -1078,10 +1078,6 @@ int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt)
*/ */
static void ssl_check_for_safari(SSL *s, const CLIENTHELLO_MSG *hello) static void ssl_check_for_safari(SSL *s, const CLIENTHELLO_MSG *hello)
{ {
unsigned int type;
PACKET sni, tmppkt;
size_t ext_len;
static const unsigned char kSafariExtensionsBlock[] = { static const unsigned char kSafariExtensionsBlock[] = {
0x00, 0x0a, /* elliptic_curves extension */ 0x00, 0x0a, /* elliptic_curves extension */
0x00, 0x08, /* 8 bytes */ 0x00, 0x08, /* 8 bytes */
...@@ -1104,9 +1100,11 @@ static void ssl_check_for_safari(SSL *s, const CLIENTHELLO_MSG *hello) ...@@ -1104,9 +1100,11 @@ static void ssl_check_for_safari(SSL *s, const CLIENTHELLO_MSG *hello)
0x04, 0x03, /* SHA-256/ECDSA */ 0x04, 0x03, /* SHA-256/ECDSA */
0x02, 0x03, /* SHA-1/ECDSA */ 0x02, 0x03, /* SHA-1/ECDSA */
}; };
/* Length of the common prefix (first two extensions). */ /* Length of the common prefix (first two extensions). */
static const size_t kSafariCommonExtensionsLength = 18; static const size_t kSafariCommonExtensionsLength = 18;
unsigned int type;
PACKET sni, tmppkt;
size_t ext_len;
tmppkt = hello->extensions; tmppkt = hello->extensions;
...@@ -1694,7 +1692,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt) ...@@ -1694,7 +1692,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt)
/* /*
* Call the status request callback if needed. Upon success, returns 1. * Call the status request callback if needed. Upon success, returns 1.
* Upon failure, returns 0 and sets |al| to the appropriate fatal alert. * Upon failure, returns 0 and sets |*al| to the appropriate fatal alert.
*/ */
static int tls_handle_status_request(SSL *s, int *al) static int tls_handle_status_request(SSL *s, int *al)
{ {
...@@ -1706,10 +1704,11 @@ static int tls_handle_status_request(SSL *s, int *al) ...@@ -1706,10 +1704,11 @@ static int tls_handle_status_request(SSL *s, int *al)
* and must be called after the cipher has been chosen because this may * and must be called after the cipher has been chosen because this may
* influence which certificate is sent * influence which certificate is sent
*/ */
if ((s->tlsext_status_type != -1) && s->ctx && s->ctx->tlsext_status_cb) { if (s->tlsext_status_type != -1 && s->ctx != NULL
&& s->ctx->tlsext_status_cb != NULL) {
int ret; int ret;
CERT_PKEY *certpkey; CERT_PKEY *certpkey = ssl_get_server_send_pkey(s);
certpkey = ssl_get_server_send_pkey(s);
/* If no certificate can't return certificate status */ /* If no certificate can't return certificate status */
if (certpkey != NULL) { if (certpkey != NULL) {
/* /*
......
...@@ -593,6 +593,7 @@ static int ssl_print_version(BIO *bio, int indent, const char *name, ...@@ -593,6 +593,7 @@ static int ssl_print_version(BIO *bio, int indent, const char *name,
unsigned int *version) unsigned int *version)
{ {
int vers; int vers;
if (*pmsglen < 2) if (*pmsglen < 2)
return 0; return 0;
vers = ((*pmsg)[0] << 8) | (*pmsg)[1]; vers = ((*pmsg)[0] << 8) | (*pmsg)[1];
...@@ -867,6 +868,7 @@ static int ssl_print_server_hello(BIO *bio, int indent, ...@@ -867,6 +868,7 @@ static int ssl_print_server_hello(BIO *bio, int indent,
{ {
unsigned int cs; unsigned int cs;
unsigned int vers; unsigned int vers;
if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen, &vers)) if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen, &vers))
return 0; return 0;
if (!ssl_print_random(bio, indent, &msg, &msglen)) if (!ssl_print_random(bio, indent, &msg, &msglen))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册