Use WriteOrBufferDataAtLevel to send crypto data. Such that existing WriteOrBufferData is used to send application data. Change SendHandshakeMessage to take encryption level instead of using current default encryption level. Protected by FLAGS_quic_reloadable_flag_quic_use_write_or_buffer_data_at_level. PiperOrigin-RevId: 339927045 Change-Id: Ifa17962e5f70e6d4ed2d5aa8627150872f5dd69d
diff --git a/quic/core/quic_crypto_server_stream.cc b/quic/core/quic_crypto_server_stream.cc index 4c21e55..2bad8ec 100644 --- a/quic/core/quic_crypto_server_stream.cc +++ b/quic/core/quic_crypto_server_stream.cc
@@ -173,7 +173,8 @@ if (reply->tag() != kSHLO) { session()->connection()->set_fully_pad_crypto_handshake_packets( crypto_config_->pad_rej()); - SendHandshakeMessage(*reply); + // Send REJ in plaintext. + SendHandshakeMessage(*reply, ENCRYPTION_INITIAL); return; } @@ -213,7 +214,8 @@ session()->connection()->set_fully_pad_crypto_handshake_packets( crypto_config_->pad_shlo()); - SendHandshakeMessage(*reply); + // Send SHLO in ENCRYPTION_ZERO_RTT. + SendHandshakeMessage(*reply, ENCRYPTION_ZERO_RTT); delegate_->OnNewEncryptionKeyAvailable( ENCRYPTION_FORWARD_SECURE, std::move(crypto_negotiated_params_->forward_secure_crypters.encrypter)); @@ -284,12 +286,15 @@ QUIC_DVLOG(1) << "Server: Sending server config update: " << message.DebugString(); - if (!QuicVersionUsesCryptoFrames(transport_version())) { + + if (!session()->use_write_or_buffer_data_at_level() && + !QuicVersionUsesCryptoFrames(transport_version())) { const QuicData& data = message.GetSerialized(); WriteOrBufferData(absl::string_view(data.data(), data.length()), false, nullptr); } else { - SendHandshakeMessage(message); + // Send server config update in ENCRYPTION_FORWARD_SECURE. + SendHandshakeMessage(message, ENCRYPTION_FORWARD_SECURE); } ++num_server_config_update_messages_sent_;