Adding TLS 1.3 constants.
Constants representing TLS 1.3 are added to allow for future work to be
flagged on TLS1_3_VERSION. To prevent BoringSSL from negotiating the
non-existent TLS 1.3 version, it is explicitly disabled using
SSL_OP_NO_TLSv1_3.
Change-Id: Ie5258a916f4c19ef21646c4073d5b4a7974d6f3f
Reviewed-on: https://boringssl-review.googlesource.com/8041
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 86057d1..51a8a06 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -297,6 +297,9 @@
if (method->version != 0) {
SSL_CTX_set_max_version(ret, method->version);
SSL_CTX_set_min_version(ret, method->version);
+ } else if (!method->method->is_dtls) {
+ /* TODO(svaldez): Enable TLS 1.3 once implemented. */
+ SSL_CTX_set_max_version(ret, TLS1_2_VERSION);
}
return ret;
@@ -1788,6 +1791,9 @@
static const char *ssl_get_version(int version) {
switch (version) {
+ case TLS1_3_VERSION:
+ return "TLSv1.3";
+
case TLS1_2_VERSION:
return "TLSv1.2";
@@ -2298,7 +2304,7 @@
/* False Start only for TLS 1.2 with an ECDHE+AEAD cipher and ALPN or NPN. */
return !SSL_IS_DTLS(ssl) &&
- SSL_version(ssl) >= TLS1_2_VERSION &&
+ SSL_version(ssl) == TLS1_2_VERSION &&
(ssl->s3->alpn_selected || ssl->s3->next_proto_neg_seen) &&
cipher != NULL &&
cipher->algorithm_mkey == SSL_kECDHE &&
@@ -2313,6 +2319,7 @@
case TLS1_VERSION:
case TLS1_1_VERSION:
case TLS1_2_VERSION:
+ case TLS1_3_VERSION:
case DTLS1_VERSION:
case DTLS1_2_VERSION:
return &TLSv1_enc_data;
@@ -2337,7 +2344,10 @@
return 0;
}
- max_version = (ssl->max_version != 0) ? ssl->max_version : TLS1_2_VERSION;
+ max_version = (ssl->max_version != 0) ? ssl->max_version : TLS1_3_VERSION;
+ if (!(ssl->options & SSL_OP_NO_TLSv1_3) && TLS1_3_VERSION <= max_version) {
+ return TLS1_3_VERSION;
+ }
if (!(ssl->options & SSL_OP_NO_TLSv1_2) && TLS1_2_VERSION <= max_version) {
return TLS1_2_VERSION;
}
@@ -2381,8 +2391,11 @@
client_version = ssl->max_version;
}
- if (client_version >= TLS1_2_VERSION &&
- !(ssl->options & SSL_OP_NO_TLSv1_2)) {
+ if (client_version >= TLS1_3_VERSION &&
+ !(ssl->options & SSL_OP_NO_TLSv1_3)) {
+ version = TLS1_3_VERSION;
+ } else if (client_version >= TLS1_2_VERSION &&
+ !(ssl->options & SSL_OP_NO_TLSv1_2)) {
version = TLS1_2_VERSION;
} else if (client_version >= TLS1_1_VERSION &&
!(ssl->options & SSL_OP_NO_TLSv1_1)) {
@@ -2431,7 +2444,10 @@
version = ssl->max_version;
}
} else {
- if (!(options & SSL_OP_NO_TLSv1_2)) {
+ if (!(options & SSL_OP_NO_TLSv1_3)) {
+ version = TLS1_3_VERSION;
+ }
+ if (!(options & SSL_OP_NO_TLSv1_2) && (options & SSL_OP_NO_TLSv1_3)) {
version = TLS1_2_VERSION;
}
if (!(options & SSL_OP_NO_TLSv1_1) && (options & SSL_OP_NO_TLSv1_2)) {
@@ -2491,6 +2507,9 @@
case TLS1_2_VERSION:
return !(ssl->options & SSL_OP_NO_TLSv1_2);
+ case TLS1_3_VERSION:
+ return !(ssl->options & SSL_OP_NO_TLSv1_3);
+
default:
return 0;
}