Index: net/quic/quic_crypto_server_stream.cc |
diff --git a/net/quic/quic_crypto_server_stream.cc b/net/quic/quic_crypto_server_stream.cc |
index 1dab72f6be44e99028edc0a814d52fe6869db204..57c10763689a919ff1f4cf29c0a77a2020331b88 100644 |
--- a/net/quic/quic_crypto_server_stream.cc |
+++ b/net/quic/quic_crypto_server_stream.cc |
@@ -40,54 +40,60 @@ void QuicCryptoServerStream::OnHandshakeMessage( |
string error_details; |
CryptoHandshakeMessage reply; |
- crypto_config_.ProcessClientHello( |
+ QuicErrorCode error = crypto_config_.ProcessClientHello( |
message, session()->connection()->guid(), |
session()->connection()->peer_address(), |
- session()->connection()->clock()->NowAsDeltaSinceUnixEpoch(), |
+ session()->connection()->clock(), |
session()->connection()->random_generator(), |
&crypto_negotiated_params_, &reply, &error_details); |
- if (reply.tag() == kSHLO) { |
- // If we are returning a SHLO then we accepted the handshake. |
- QuicErrorCode error = config_.ProcessFinalPeerHandshake( |
- message, CryptoUtils::LOCAL_PRIORITY, &negotiated_params_, |
- &error_details); |
- if (error != QUIC_NO_ERROR) { |
- CloseConnectionWithDetails(error, error_details); |
- return; |
- } |
+ if (error != QUIC_NO_ERROR) { |
+ CloseConnectionWithDetails(error, error_details); |
+ return; |
+ } |
+ |
+ if (reply.tag() != kSHLO) { |
+ SendHandshakeMessage(reply); |
+ return; |
+ } |
- // Receiving a full CHLO implies the client is prepared to decrypt with |
- // the new server write key. We can start to encrypt with the new server |
- // write key. |
- // |
- // NOTE: the SHLO will be encrypted with the new server write key. |
- session()->connection()->SetEncrypter( |
- ENCRYPTION_INITIAL, |
- crypto_negotiated_params_.encrypter.release()); |
- session()->connection()->SetDefaultEncryptionLevel( |
- ENCRYPTION_INITIAL); |
- // Set the decrypter immediately so that we no longer accept unencrypted |
- // packets. |
- session()->connection()->SetDecrypter( |
- crypto_negotiated_params_.decrypter.release()); |
- encryption_established_ = true; |
- handshake_confirmed_ = true; |
- session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
+ // If we are returning a SHLO then we accepted the handshake. |
+ error = config_.ProcessFinalPeerHandshake( |
+ message, CryptoUtils::LOCAL_PRIORITY, &negotiated_params_, |
+ &error_details); |
+ if (error != QUIC_NO_ERROR) { |
+ CloseConnectionWithDetails(error, error_details); |
+ return; |
} |
+ // Receiving a full CHLO implies the client is prepared to decrypt with |
+ // the new server write key. We can start to encrypt with the new server |
+ // write key. |
+ // |
+ // NOTE: the SHLO will be encrypted with the new server write key. |
+ session()->connection()->SetEncrypter( |
+ ENCRYPTION_INITIAL, |
+ crypto_negotiated_params_.initial_crypters.encrypter.release()); |
+ session()->connection()->SetDefaultEncryptionLevel( |
+ ENCRYPTION_INITIAL); |
+ // Set the decrypter immediately so that we no longer accept unencrypted |
+ // packets. |
+ session()->connection()->SetDecrypter( |
+ crypto_negotiated_params_.initial_crypters.decrypter.release()); |
SendHandshakeMessage(reply); |
- return; |
-} |
-const QuicNegotiatedParameters& |
-QuicCryptoServerStream::negotiated_params() const { |
- return negotiated_params_; |
-} |
+ session()->connection()->SetEncrypter( |
+ ENCRYPTION_FORWARD_SECURE, |
+ crypto_negotiated_params_.forward_secure_crypters.encrypter.release()); |
+ session()->connection()->SetDefaultEncryptionLevel( |
+ ENCRYPTION_FORWARD_SECURE); |
+ session()->connection()->SetAlternativeDecrypter( |
+ crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), |
+ false /* don't latch */); |
-const QuicCryptoNegotiatedParameters& |
-QuicCryptoServerStream::crypto_negotiated_params() const { |
- return crypto_negotiated_params_; |
+ encryption_established_ = true; |
+ handshake_confirmed_ = true; |
+ session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
} |
} // namespace net |