提交 71728dd8 编写于 作者: M Matt Caswell

Send and Receive a TLSv1.3 format ServerHello

There are some minor differences in the format of a ServerHello in TLSv1.3.

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>
上级 c901bcce
...@@ -1089,17 +1089,22 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) ...@@ -1089,17 +1089,22 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
s->hit = 0; s->hit = 0;
/* Get the session-id. */ /* Get the session-id. */
if (!PACKET_get_length_prefixed_1(pkt, &session_id)) { if (!SSL_IS_TLS13(s)) {
al = SSL_AD_DECODE_ERROR; if (!PACKET_get_length_prefixed_1(pkt, &session_id)) {
SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); al = SSL_AD_DECODE_ERROR;
goto f_err; SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);
} goto f_err;
session_id_len = PACKET_remaining(&session_id); }
if (session_id_len > sizeof s->session->session_id session_id_len = PACKET_remaining(&session_id);
|| session_id_len > SSL3_SESSION_ID_SIZE) { if (session_id_len > sizeof s->session->session_id
al = SSL_AD_ILLEGAL_PARAMETER; || session_id_len > SSL3_SESSION_ID_SIZE) {
SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG); al = SSL_AD_ILLEGAL_PARAMETER;
goto f_err; SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,
SSL_R_SSL3_SESSION_ID_TOO_LONG);
goto f_err;
}
} else {
session_id_len = 0;
} }
if (!PACKET_get_bytes(pkt, &cipherchars, TLS_CIPHER_LEN)) { if (!PACKET_get_bytes(pkt, &cipherchars, TLS_CIPHER_LEN)) {
...@@ -1120,8 +1125,8 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) ...@@ -1120,8 +1125,8 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
* we can resume, and later peek at the next handshake message to see if the * we can resume, and later peek at the next handshake message to see if the
* server wants to resume. * server wants to resume.
*/ */
if (s->version >= TLS1_VERSION && s->tls_session_secret_cb && if (s->version >= TLS1_VERSION && !SSL_IS_TLS13(s)
s->session->tlsext_tick) { && s->tls_session_secret_cb && 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
...@@ -1235,11 +1240,16 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) ...@@ -1235,11 +1240,16 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
s->s3->tmp.new_cipher = c; s->s3->tmp.new_cipher = c;
/* lets get the compression algorithm */ /* lets get the compression algorithm */
/* COMPRESSION */ /* COMPRESSION */
if (!PACKET_get_1(pkt, &compression)) { if (!SSL_IS_TLS13(s)) {
SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); if (!PACKET_get_1(pkt, &compression)) {
al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);
goto f_err; al = SSL_AD_DECODE_ERROR;
goto f_err;
}
} else {
compression = 0;
} }
#ifdef OPENSSL_NO_COMP #ifdef OPENSSL_NO_COMP
if (compression != 0) { if (compression != 0) {
al = SSL_AD_ILLEGAL_PARAMETER; al = SSL_AD_ILLEGAL_PARAMETER;
......
...@@ -1773,9 +1773,11 @@ int tls_construct_server_hello(SSL *s, WPACKET *pkt) ...@@ -1773,9 +1773,11 @@ int tls_construct_server_hello(SSL *s, WPACKET *pkt)
compm = s->s3->tmp.new_compression->id; compm = s->s3->tmp.new_compression->id;
#endif #endif
if (!WPACKET_sub_memcpy_u8(pkt, s->session->session_id, sl) if ((!SSL_IS_TLS13(s)
&& !WPACKET_sub_memcpy_u8(pkt, s->session->session_id, sl))
|| !s->method->put_cipher_by_char(s->s3->tmp.new_cipher, pkt, &len) || !s->method->put_cipher_by_char(s->s3->tmp.new_cipher, pkt, &len)
|| !WPACKET_put_bytes_u8(pkt, compm) || (!SSL_IS_TLS13(s)
&& !WPACKET_put_bytes_u8(pkt, compm))
|| !ssl_prepare_serverhello_tlsext(s) || !ssl_prepare_serverhello_tlsext(s)
|| !ssl_add_serverhello_tlsext(s, pkt, &al)) { || !ssl_add_serverhello_tlsext(s, pkt, &al)) {
SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, ERR_R_INTERNAL_ERROR); SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, ERR_R_INTERNAL_ERROR);
......
...@@ -588,12 +588,17 @@ static int ssl_print_hexbuf(BIO *bio, int indent, ...@@ -588,12 +588,17 @@ static int ssl_print_hexbuf(BIO *bio, int indent,
} }
static int ssl_print_version(BIO *bio, int indent, const char *name, static int ssl_print_version(BIO *bio, int indent, const char *name,
const unsigned char **pmsg, size_t *pmsglen) const unsigned char **pmsg, size_t *pmsglen,
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];
if (version != NULL) {
/* TODO(TLS1.3): Remove the draft conditional here before release */
*version = (vers == TLS1_3_VERSION_DRAFT) ? TLS1_3_VERSION : vers;
}
BIO_indent(bio, indent, 80); BIO_indent(bio, indent, 80);
BIO_printf(bio, "%s=0x%x (%s)\n", BIO_printf(bio, "%s=0x%x (%s)\n",
name, vers, ssl_trace_str(vers, ssl_version_tbl)); name, vers, ssl_trace_str(vers, ssl_version_tbl));
...@@ -796,7 +801,7 @@ static int ssl_print_client_hello(BIO *bio, SSL *ssl, int indent, ...@@ -796,7 +801,7 @@ static int ssl_print_client_hello(BIO *bio, SSL *ssl, int indent,
{ {
size_t len; size_t len;
unsigned int cs; unsigned int cs;
if (!ssl_print_version(bio, indent, "client_version", &msg, &msglen)) if (!ssl_print_version(bio, indent, "client_version", &msg, &msglen, NULL))
return 0; return 0;
if (!ssl_print_random(bio, indent, &msg, &msglen)) if (!ssl_print_random(bio, indent, &msg, &msglen))
return 0; return 0;
...@@ -849,7 +854,7 @@ static int ssl_print_client_hello(BIO *bio, SSL *ssl, int indent, ...@@ -849,7 +854,7 @@ static int ssl_print_client_hello(BIO *bio, SSL *ssl, int indent,
static int dtls_print_hello_vfyrequest(BIO *bio, int indent, static int dtls_print_hello_vfyrequest(BIO *bio, int indent,
const unsigned char *msg, size_t msglen) const unsigned char *msg, size_t msglen)
{ {
if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen)) if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen, NULL))
return 0; return 0;
if (!ssl_print_hexbuf(bio, indent, "cookie", 1, &msg, &msglen)) if (!ssl_print_hexbuf(bio, indent, "cookie", 1, &msg, &msglen))
return 0; return 0;
...@@ -860,11 +865,13 @@ static int ssl_print_server_hello(BIO *bio, int indent, ...@@ -860,11 +865,13 @@ static int ssl_print_server_hello(BIO *bio, int indent,
const unsigned char *msg, size_t msglen) const unsigned char *msg, size_t msglen)
{ {
unsigned int cs; unsigned int cs;
if (!ssl_print_version(bio, indent, "server_version", &msg, &msglen)) unsigned int 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))
return 0; return 0;
if (!ssl_print_hexbuf(bio, indent, "session_id", 1, &msg, &msglen)) if (vers != TLS1_3_VERSION
&& !ssl_print_hexbuf(bio, indent, "session_id", 1, &msg, &msglen))
return 0; return 0;
if (msglen < 2) if (msglen < 2)
return 0; return 0;
...@@ -874,13 +881,15 @@ static int ssl_print_server_hello(BIO *bio, int indent, ...@@ -874,13 +881,15 @@ static int ssl_print_server_hello(BIO *bio, int indent,
msg[0], msg[1], ssl_trace_str(cs, ssl_ciphers_tbl)); msg[0], msg[1], ssl_trace_str(cs, ssl_ciphers_tbl));
msg += 2; msg += 2;
msglen -= 2; msglen -= 2;
if (msglen < 1) if (vers != TLS1_3_VERSION) {
return 0; if (msglen < 1)
BIO_indent(bio, indent, 80); return 0;
BIO_printf(bio, "compression_method: %s (0x%02X)\n", BIO_indent(bio, indent, 80);
ssl_trace_str(msg[0], ssl_comp_tbl), msg[0]); BIO_printf(bio, "compression_method: %s (0x%02X)\n",
msg++; ssl_trace_str(msg[0], ssl_comp_tbl), msg[0]);
msglen--; msg++;
msglen--;
}
if (!ssl_print_extensions(bio, indent, 1, msg, msglen)) if (!ssl_print_extensions(bio, indent, 1, msg, msglen))
return 0; return 0;
return 1; return 1;
......
...@@ -60,17 +60,18 @@ sub checkmessages($$); ...@@ -60,17 +60,18 @@ sub checkmessages($$);
#Test 1: Check we get all the right messages for a default handshake #Test 1: Check we get all the right messages for a default handshake
(undef, my $session) = tempfile(); (undef, my $session) = tempfile();
$proxy->serverconnects(2); #$proxy->serverconnects(2);
$proxy->clientflags("-sess_out ".$session); $proxy->clientflags("-sess_out ".$session);
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
plan tests => 4; plan tests => 3;
checkmessages(DEFAULT_HANDSHAKE, "Default handshake test"); checkmessages(DEFAULT_HANDSHAKE, "Default handshake test");
#TODO(TLS1.3): Test temporarily disabled until we implement TLS1.3 resumption
#Test 2: Resumption handshake #Test 2: Resumption handshake
$proxy->clearClient(); #$proxy->clearClient();
$proxy->clientflags("-sess_in ".$session); #$proxy->clientflags("-sess_in ".$session);
$proxy->clientstart(); #$proxy->clientstart();
checkmessages(RESUME_HANDSHAKE, "Resumption handshake test"); #checkmessages(RESUME_HANDSHAKE, "Resumption handshake test");
unlink $session; unlink $session;
#Test 3: A default handshake, but with a CertificateStatus message #Test 3: A default handshake, but with a CertificateStatus message
......
...@@ -383,6 +383,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -383,6 +383,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[10-alpn-simple-resumption-client] [10-alpn-simple-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -425,6 +426,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -425,6 +426,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[11-alpn-server-switch-resumption-client] [11-alpn-server-switch-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -465,11 +467,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -465,11 +467,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[12-alpn-client-switch-resumption-client] [12-alpn-client-switch-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
[12-alpn-client-switch-resumption-resume-client] [12-alpn-client-switch-resumption-resume-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -515,6 +519,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -515,6 +519,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[13-alpn-alert-on-mismatch-resumption-client] [13-alpn-alert-on-mismatch-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -560,6 +565,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -560,6 +565,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[14-alpn-no-server-support-resumption-client] [14-alpn-no-server-support-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -595,11 +601,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -595,11 +601,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[15-alpn-no-client-support-resumption-client] [15-alpn-no-client-support-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
[15-alpn-no-client-support-resumption-resume-client] [15-alpn-no-client-support-resumption-resume-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
......
...@@ -204,6 +204,8 @@ our @tests = ( ...@@ -204,6 +204,8 @@ our @tests = (
}, },
}, },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo", "ALPNProtocols" => "foo",
}, },
...@@ -227,6 +229,8 @@ our @tests = ( ...@@ -227,6 +229,8 @@ our @tests = (
}, },
}, },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo,bar,baz", "ALPNProtocols" => "foo,bar,baz",
}, },
...@@ -245,11 +249,15 @@ our @tests = ( ...@@ -245,11 +249,15 @@ our @tests = (
}, },
}, },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo,baz", "ALPNProtocols" => "foo,baz",
}, },
}, },
resume_client => { resume_client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "bar,baz", "ALPNProtocols" => "bar,baz",
}, },
...@@ -273,6 +281,8 @@ our @tests = ( ...@@ -273,6 +281,8 @@ our @tests = (
}, },
}, },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo,bar", "ALPNProtocols" => "foo,bar",
}, },
...@@ -292,6 +302,8 @@ our @tests = ( ...@@ -292,6 +302,8 @@ our @tests = (
}, },
resume_server => { }, resume_server => { },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo", "ALPNProtocols" => "foo",
}, },
...@@ -310,11 +322,16 @@ our @tests = ( ...@@ -310,11 +322,16 @@ our @tests = (
}, },
}, },
client => { client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2",
extra => { extra => {
"ALPNProtocols" => "foo", "ALPNProtocols" => "foo",
}, },
}, },
resume_client => { }, resume_client => {
#TODO(TLS1.3): Temporary until we support TLSv1.3 resumption
MaxProtocol => "TLSv1.2"
},
test => { test => {
"HandshakeMode" => "Resume", "HandshakeMode" => "Resume",
"ResumptionExpected" => "Yes", "ResumptionExpected" => "Yes",
......
...@@ -79,6 +79,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -79,6 +79,7 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[2-ct-permissive-resumption-client] [2-ct-permissive-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
...@@ -111,11 +112,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem ...@@ -111,11 +112,13 @@ PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
[3-ct-strict-resumption-client] [3-ct-strict-resumption-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
[3-ct-strict-resumption-resume-client] [3-ct-strict-resumption-resume-client]
CipherString = DEFAULT CipherString = DEFAULT
MaxProtocol = TLSv1.2
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
VerifyMode = Peer VerifyMode = Peer
......
...@@ -18,63 +18,72 @@ package ssltests; ...@@ -18,63 +18,72 @@ package ssltests;
our @tests = ( our @tests = (
# Currently only have tests for certs without SCTs. # Currently only have tests for certs without SCTs.
{ {
name => "ct-permissive", name => "ct-permissive",
server => { }, server => { },
client => { client => {
extra => { extra => {
"CTValidation" => "Permissive", "CTValidation" => "Permissive",
}, },
}, },
test => { test => {
"ExpectedResult" => "Success", "ExpectedResult" => "Success",
}, },
}, },
{ {
name => "ct-strict", name => "ct-strict",
server => { }, server => { },
client => { client => {
extra => { extra => {
"CTValidation" => "Strict", "CTValidation" => "Strict",
}, },
}, },
test => { test => {
"ExpectedResult" => "ClientFail", "ExpectedResult" => "ClientFail",
"ExpectedClientAlert" => "HandshakeFailure", "ExpectedClientAlert" => "HandshakeFailure",
}, },
}, },
{ {
name => "ct-permissive-resumption", name => "ct-permissive-resumption",
server => { }, server => { },
client => { client => {
extra => { #TODO(TLS1.3): Temporarily set to TLSv1.2 until we implement TLS1.3
"CTValidation" => "Permissive", # resumption
}, MaxProtocol => "TLSv1.2",
}, extra => {
test => { "CTValidation" => "Permissive",
"HandshakeMode" => "Resume", },
"ResumptionExpected" => "Yes", },
"ExpectedResult" => "Success", test => {
}, "HandshakeMode" => "Resume",
"ResumptionExpected" => "Yes",
"ExpectedResult" => "Success",
},
}, },
{ {
name => "ct-strict-resumption", name => "ct-strict-resumption",
server => { }, server => { },
client => { client => {
extra => { #TODO(TLS1.3): Temporarily set to TLSv1.2 until we implement TLS1.3
"CTValidation" => "Permissive", # resumption
}, MaxProtocol => "TLSv1.2",
}, extra => {
# SCTs are not present during resumption, so the resumption "CTValidation" => "Permissive",
# should succeed. },
resume_client => { },
extra => { # SCTs are not present during resumption, so the resumption
"CTValidation" => "Strict", # should succeed.
}, resume_client => {
}, #TODO(TLS1.3): Temporarily set to TLSv1.2 until we implement TLS1.3
test => { # resumption
"HandshakeMode" => "Resume", MaxProtocol => "TLSv1.2",
"ResumptionExpected" => "Yes", extra => {
"ExpectedResult" => "Success", "CTValidation" => "Strict",
}, },
},
test => {
"HandshakeMode" => "Resume",
"ResumptionExpected" => "Yes",
"ExpectedResult" => "Success",
},
}, },
); );
...@@ -135,6 +135,22 @@ sub generate_resumption_tests { ...@@ -135,6 +135,22 @@ sub generate_resumption_tests {
# Don't write the redundant "Method = TLS" into the configuration. # Don't write the redundant "Method = TLS" into the configuration.
undef $method if !$dtls; undef $method if !$dtls;
#TODO(TLS1.3): This is temporary code while we do not have support for
# TLS1.3 resumption. We recalculate min_tls_enabled and
# max_tls_enabled, ignoring TLS1.3
foreach my $i (0..($#tls_protocols - 1)) {
if (!$is_tls_disabled[$i]) {
$min_tls_enabled = $i;
last;
}
}
foreach my $i (0..($#tls_protocols - 1)) {
if (!$is_tls_disabled[$i]) {
$max_tls_enabled = $i;
}
}
my @protocols = $dtls ? @dtls_protocols : @tls_protocols; my @protocols = $dtls ? @dtls_protocols : @tls_protocols;
my $min_enabled = $dtls ? $min_dtls_enabled : $min_tls_enabled; my $min_enabled = $dtls ? $min_dtls_enabled : $min_tls_enabled;
my $max_enabled = $dtls ? $max_dtls_enabled : $max_tls_enabled; my $max_enabled = $dtls ? $max_dtls_enabled : $max_tls_enabled;
......
...@@ -430,6 +430,12 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix) ...@@ -430,6 +430,12 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)
SSL_CTX_set_min_proto_version(cctx, TLS1_2_VERSION); SSL_CTX_set_min_proto_version(cctx, TLS1_2_VERSION);
#endif #endif
/*
* TODO(TLS1.3): Test temporarily disabled for TLS1.3 until we've
* implemented session resumption.
*/
SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION);
/* Set up session cache */ /* Set up session cache */
if (fix.use_ext_cache) { if (fix.use_ext_cache) {
SSL_CTX_sess_set_new_cb(cctx, new_session_cb); SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
......
...@@ -45,16 +45,30 @@ sub parse ...@@ -45,16 +45,30 @@ sub parse
my $self = shift; my $self = shift;
my $ptr = 2; my $ptr = 2;
my ($server_version) = unpack('n', $self->data); my ($server_version) = unpack('n', $self->data);
# TODO(TLS1.3): Replace this reference to draft version before release
if ($server_version == TLSProxy::Record::VERS_TLS_1_3_DRAFT) {
$server_version = TLSProxy::Record::VERS_TLS_1_3;
TLSProxy::Proxy->is_tls13(1);
}
my $random = substr($self->data, $ptr, 32); my $random = substr($self->data, $ptr, 32);
$ptr += 32; $ptr += 32;
my $session_id_len = unpack('C', substr($self->data, $ptr)); my $session_id_len = 0;
$ptr++; my $session = "";
my $session = substr($self->data, $ptr, $session_id_len); if (!TLSProxy::Proxy->is_tls13()) {
$ptr += $session_id_len; $session_id_len = unpack('C', substr($self->data, $ptr));
$ptr++;
$session = substr($self->data, $ptr, $session_id_len);
$ptr += $session_id_len;
}
my $ciphersuite = unpack('n', substr($self->data, $ptr)); my $ciphersuite = unpack('n', substr($self->data, $ptr));
$ptr += 2; $ptr += 2;
my $comp_meth = unpack('C', substr($self->data, $ptr)); my $comp_meth = 0;
$ptr++; if (!TLSProxy::Proxy->is_tls13()) {
$comp_meth = unpack('C', substr($self->data, $ptr));
$ptr++;
}
my $extensions_len = unpack('n', substr($self->data, $ptr)); my $extensions_len = unpack('n', substr($self->data, $ptr));
if (!defined $extensions_len) { if (!defined $extensions_len) {
$extensions_len = 0; $extensions_len = 0;
...@@ -94,11 +108,9 @@ sub parse ...@@ -94,11 +108,9 @@ sub parse
$self->process_data(); $self->process_data();
# TODO(TLS1.3): Replace this reference to draft version before release if (TLSProxy::Proxy->is_tls13()) {
if ($server_version == TLSProxy::Record::VERS_TLS_1_3_DRAFT) {
TLSProxy::Record->server_encrypting(1); TLSProxy::Record->server_encrypting(1);
TLSProxy::Record->client_encrypting(1); TLSProxy::Record->client_encrypting(1);
TLSProxy::Proxy->is_tls13(1);
} }
print " Server Version:".$server_version."\n"; print " Server Version:".$server_version."\n";
...@@ -125,10 +137,14 @@ sub set_message_contents ...@@ -125,10 +137,14 @@ sub set_message_contents
$data = pack('n', $self->server_version); $data = pack('n', $self->server_version);
$data .= $self->random; $data .= $self->random;
$data .= pack('C', $self->session_id_len); if (!TLSProxy::Proxy->is_tls13()) {
$data .= $self->session; $data .= pack('C', $self->session_id_len);
$data .= $self->session;
}
$data .= pack('n', $self->ciphersuite); $data .= pack('n', $self->ciphersuite);
$data .= pack('C', $self->comp_meth); if (!TLSProxy::Proxy->is_tls13()) {
$data .= pack('C', $self->comp_meth);
}
foreach my $key (keys %{$self->extension_data}) { foreach my $key (keys %{$self->extension_data}) {
my $extdata = ${$self->extension_data}{$key}; my $extdata = ${$self->extension_data}{$key};
...@@ -152,9 +168,9 @@ sub server_version ...@@ -152,9 +168,9 @@ sub server_version
{ {
my $self = shift; my $self = shift;
if (@_) { if (@_) {
$self->{client_version} = shift; $self->{server_version} = shift;
} }
return $self->{client_version}; return $self->{server_version};
} }
sub random sub random
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册