Integrate TLS 1.2 sigalg and cipher suite selection
In TLS 1.2, cipher suite negotiation is tied up with a ton of other
decisions. Even though both sides have an ECDHE_RSA cipher in common, it
may not work because there isn't a common ECDHE curve or sigalg. In that
case, ideally we would consider a non-ECDHE_RSA cipher suite, notably
one of the legacy RSA key exchange ciphers.
If there is no ECDHE curve common, we already did this. However, if
there was no sigalg in common, we would fail the connection rather than
consider RSA key exchange.
Giving this case a lifetime would normally be unimportant as RSA key
exchange is thoroughly deprecated, but the SSL_CREDENTIAL work will need
to consider signature algorithm matches, at which point we'll pick up
behavior like this anyway. So I'm implementing it separately here just
to get the behavior change out of the way.
Update-Note: TLS 1.2 servers will now consider RSA key exchange when the
signature algorithm portion of ECDHE_RSA fails. Previously, the
connection would just fail. This change will not impact any connections
that previously succeeded, only make some previously failing connections
start to succeed. It also changes the error returned in some cases from
NO_COMMON_SIGNATURE_ALGORITHMS to NO_SHARED_CIPHER.
Bug: 249
Change-Id: I4a70036756ea998f38ea155f208e8122bf9a5b44
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66368
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/ssl/handshake_server.cc b/ssl/handshake_server.cc
index cffa52d..7c84ef8 100644
--- a/ssl/handshake_server.cc
+++ b/ssl/handshake_server.cc
@@ -303,7 +303,11 @@
uint32_t mask_a = 0;
if (ssl_has_certificate(hs)) {
- mask_a |= ssl_cipher_auth_mask_for_key(hs->local_pubkey.get());
+ uint16_t unused;
+ bool sign_ok = tls1_choose_signature_algorithm(hs, &unused);
+ ERR_clear_error();
+
+ mask_a |= ssl_cipher_auth_mask_for_key(hs->local_pubkey.get(), sign_ok);
if (EVP_PKEY_id(hs->local_pubkey.get()) == EVP_PKEY_RSA) {
mask_k |= SSL_kRSA;
}