gfe-relnote: Use HandshakerDelegateInterface in QUIC handshakers. Abstract keys installation, keys discarding, default encryption level change and mark handshake complete to HandshakerDelegateInterface. Protected by gfe2_reloadable_flag_quic_use_handshaker_delegate.
The final goal is remove session pointer from handshakers.
PiperOrigin-RevId: 282826263
Change-Id: I9b379ccfcebd174df1850f7df45069d388460173
diff --git a/quic/core/tls_client_handshaker.cc b/quic/core/tls_client_handshaker.cc
index 85a278c..a65fefc 100644
--- a/quic/core/tls_client_handshaker.cc
+++ b/quic/core/tls_client_handshaker.cc
@@ -333,9 +333,9 @@
QUIC_DLOG(INFO) << "Client: server selected ALPN: '" << received_alpn_string
<< "'";
- session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
encryption_established_ = true;
handshake_confirmed_ = true;
+ delegate()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
// Fill crypto_negotiated_params_:
const SSL_CIPHER* cipher = SSL_get_current_cipher(ssl());
@@ -345,10 +345,9 @@
crypto_negotiated_params_->key_exchange_group = SSL_get_curve_id(ssl());
crypto_negotiated_params_->peer_signature_algorithm =
SSL_get_peer_signature_algorithm(ssl());
-
- session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_ESTABLISHED);
- session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
- session()->connection()->OnHandshakeComplete();
+ // TODO(fayang): Replace this with DiscardOldKeys(ENCRYPTION_HANDSHAKE) when
+ // handshake key discarding settles down.
+ delegate()->NeuterHandshakeData();
}
enum ssl_verify_result_t TlsClientHandshaker::VerifyCert(uint8_t* out_alert) {
@@ -414,4 +413,15 @@
session_cache_->Insert(server_id_, std::move(cache_state));
}
+void TlsClientHandshaker::WriteMessage(EncryptionLevel level,
+ QuicStringPiece data) {
+ if (level == ENCRYPTION_HANDSHAKE &&
+ state_ < STATE_ENCRYPTION_HANDSHAKE_DATA_SENT) {
+ state_ = STATE_ENCRYPTION_HANDSHAKE_DATA_SENT;
+ delegate()->DiscardOldEncryptionKey(ENCRYPTION_INITIAL);
+ delegate()->DiscardOldDecryptionKey(ENCRYPTION_INITIAL);
+ }
+ TlsHandshaker::WriteMessage(level, data);
+}
+
} // namespace quic