Chromium Code Reviews| Index: net/quic/crypto/quic_crypto_server_config.cc |
| diff --git a/net/quic/crypto/quic_crypto_server_config.cc b/net/quic/crypto/quic_crypto_server_config.cc |
| index ad4544963830c29668a3db48409c963621034749..4e7e18af342dbac3de1c1fae3e3d5c96cf3cd1b8 100644 |
| --- a/net/quic/crypto/quic_crypto_server_config.cc |
| +++ b/net/quic/crypto/quic_crypto_server_config.cc |
| @@ -148,13 +148,40 @@ class VerifyNonceIsValidAndUniqueCallback |
| } |
| protected: |
| - virtual void RunImpl(bool nonce_is_valid_and_unique) OVERRIDE { |
| - DVLOG(1) << "Using client nonce, unique: " << nonce_is_valid_and_unique; |
| + virtual void RunImpl(bool nonce_is_valid_and_unique, |
| + InsertStatus nonce_error) OVERRIDE { |
| + DVLOG(1) << "Using client nonce, unique: " << nonce_is_valid_and_unique |
| + << " nonce_error: " << nonce_error; |
| result_->info.unique = nonce_is_valid_and_unique; |
| - // TODO(rtenneti): Implement capturing of error from strike register. |
| - // Temporarily treat them as CLIENT_NONCE_INVALID_FAILURE. |
| if (!nonce_is_valid_and_unique) { |
| - result_->info.reject_reasons.push_back(CLIENT_NONCE_INVALID_FAILURE); |
| + HandshakeFailureReason client_nonce_error; |
| + switch (nonce_error) { |
| + case NONCE_INVALID_FAILURE: |
| + client_nonce_error = CLIENT_NONCE_INVALID_FAILURE; |
| + break; |
| + case NONCE_NOT_UNIQUE_FAILURE: |
| + client_nonce_error = CLIENT_NONCE_NOT_UNIQUE_FAILURE; |
| + break; |
| + case NONCE_INVALID_ORBIT_FAILURE: |
| + client_nonce_error = CLIENT_NONCE_INVALID_ORBIT_FAILURE; |
| + break; |
| + case NONCE_INVALID_TIME_FAILURE: |
| + client_nonce_error = CLIENT_NONCE_INVALID_TIME_FAILURE; |
| + break; |
| + case STRIKE_REGISTER_TIMEOUT: |
| + client_nonce_error = CLIENT_NONCE_STRIKE_REGISTER_TIMEOUT; |
| + break; |
| + case STRIKE_REGISTER_FAILURE: |
| + client_nonce_error = CLIENT_NONCE_STRIKE_REGISTER_FAILURE; |
| + break; |
| + case NONCE_OK: |
| + case NONCE_UNKNOWN_FAILURE: |
| + default: |
| + LOG(WARNING) << "Unexpected nonce error: " << nonce_error; |
| + client_nonce_error = CLIENT_NONCE_UNKNOWN_FAILURE; |
| + break; |
| + } |
| + result_->info.reject_reasons.push_back(client_nonce_error); |
| } |
| done_cb_->Run(result_); |
| } |
| @@ -1440,7 +1467,7 @@ HandshakeFailureReason QuicCryptoServerConfig::ValidateServerNonce( |
| COMPILE_ASSERT(4 + sizeof(server_nonce_orbit_) + 20 == sizeof(server_nonce), |
| bad_nonce_buffer_length); |
| - bool is_unique; |
| + InsertStatus nonce_error; |
| { |
| base::AutoLock auto_lock(server_nonce_strike_register_lock_); |
| if (server_nonce_strike_register_.get() == NULL) { |
| @@ -1450,11 +1477,30 @@ HandshakeFailureReason QuicCryptoServerConfig::ValidateServerNonce( |
| server_nonce_strike_register_window_secs_, server_nonce_orbit_, |
| StrikeRegister::NO_STARTUP_PERIOD_NEEDED)); |
| } |
| - is_unique = server_nonce_strike_register_->Insert( |
| + nonce_error = server_nonce_strike_register_->Insert( |
| server_nonce, static_cast<uint32>(now.ToUNIXSeconds())); |
| } |
| - return is_unique ? HANDSHAKE_OK : SERVER_NONCE_NOT_UNIQUE_FAILURE; |
| + if (nonce_error == NONCE_OK) { |
| + return HANDSHAKE_OK; |
| + } |
| + switch (nonce_error) { |
| + case NONCE_INVALID_FAILURE: |
| + return SERVER_NONCE_INVALID_FAILURE; |
| + case NONCE_NOT_UNIQUE_FAILURE: |
| + return SERVER_NONCE_NOT_UNIQUE_FAILURE; |
| + case NONCE_INVALID_TIME_FAILURE: |
| + return SERVER_NONCE_INVALID_TIME_FAILURE; |
| + case NONCE_OK: |
|
wtc
2014/07/14 21:52:28
This case cannot happen because of the check and e
ramant (doing other things)
2014/07/14 22:16:06
Thanks much.
Done.
|
| + case NONCE_UNKNOWN_FAILURE: |
| + case NONCE_INVALID_ORBIT_FAILURE: |
| + case STRIKE_REGISTER_TIMEOUT: |
| + case STRIKE_REGISTER_FAILURE: |
| + default: |
| + LOG(WARNING) << "Unexpected nonce error: " << nonce_error; |
| + return SERVER_NONCE_NOT_UNIQUE_FAILURE; |
| + } |
| + return SERVER_NONCE_NOT_UNIQUE_FAILURE; |
|
wtc
2014/07/14 21:52:28
Because of the "default" case in the switch statem
ramant (doing other things)
2014/07/14 22:16:06
Done.
|
| } |
| QuicCryptoServerConfig::Config::Config() |