OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/crypto/crypto_handshake.h" | 5 #include "net/quic/crypto/crypto_handshake.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 423 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
424 } | 424 } |
425 | 425 |
426 if (now.ToUNIXSeconds() >= expiry_seconds) { | 426 if (now.ToUNIXSeconds() >= expiry_seconds) { |
427 *error_details = "SCFG has expired"; | 427 *error_details = "SCFG has expired"; |
428 return QUIC_CRYPTO_SERVER_CONFIG_EXPIRED; | 428 return QUIC_CRYPTO_SERVER_CONFIG_EXPIRED; |
429 } | 429 } |
430 | 430 |
431 if (!matches_existing) { | 431 if (!matches_existing) { |
432 server_config_ = server_config.as_string(); | 432 server_config_ = server_config.as_string(); |
433 server_config_valid_ = false; | 433 SetProofInvalid(); |
434 ++generation_counter_; | |
435 scfg_.reset(new_scfg_storage.release()); | 434 scfg_.reset(new_scfg_storage.release()); |
436 } | 435 } |
437 return QUIC_NO_ERROR; | 436 return QUIC_NO_ERROR; |
438 } | 437 } |
439 | 438 |
440 void QuicCryptoClientConfig::CachedState::InvalidateServerConfig() { | 439 void QuicCryptoClientConfig::CachedState::InvalidateServerConfig() { |
441 server_config_.clear(); | 440 server_config_.clear(); |
442 scfg_.reset(); | 441 scfg_.reset(); |
443 server_config_valid_ = false; | 442 SetProofInvalid(); |
444 ++generation_counter_; | |
445 } | 443 } |
446 | 444 |
447 void QuicCryptoClientConfig::CachedState::SetProof(const vector<string>& certs, | 445 void QuicCryptoClientConfig::CachedState::SetProof(const vector<string>& certs, |
448 StringPiece signature) { | 446 StringPiece signature) { |
449 bool has_changed = | 447 bool has_changed = |
450 signature != server_config_sig_ || certs_.size() != certs.size(); | 448 signature != server_config_sig_ || certs_.size() != certs.size(); |
451 | 449 |
452 if (!has_changed) { | 450 if (!has_changed) { |
453 for (size_t i = 0; i < certs_.size(); i++) { | 451 for (size_t i = 0; i < certs_.size(); i++) { |
454 if (certs_[i] != certs[i]) { | 452 if (certs_[i] != certs[i]) { |
455 has_changed = true; | 453 has_changed = true; |
456 break; | 454 break; |
457 } | 455 } |
458 } | 456 } |
459 } | 457 } |
460 | 458 |
461 if (!has_changed) { | 459 if (!has_changed) { |
462 return; | 460 return; |
463 } | 461 } |
464 | 462 |
465 // If the proof has changed then it needs to be revalidated. | 463 // If the proof has changed then it needs to be revalidated. |
466 server_config_valid_ = false; | 464 SetProofInvalid(); |
467 ++generation_counter_; | |
468 certs_ = certs; | 465 certs_ = certs; |
469 server_config_sig_ = signature.as_string(); | 466 server_config_sig_ = signature.as_string(); |
470 } | 467 } |
471 | 468 |
472 void QuicCryptoClientConfig::CachedState::SetProofValid() { | 469 void QuicCryptoClientConfig::CachedState::SetProofValid() { |
473 server_config_valid_ = true; | 470 server_config_valid_ = true; |
474 } | 471 } |
475 | 472 |
| 473 void QuicCryptoClientConfig::CachedState::SetProofInvalid() { |
| 474 server_config_valid_ = false; |
| 475 ++generation_counter_; |
| 476 } |
| 477 |
476 const string& QuicCryptoClientConfig::CachedState::server_config() const { | 478 const string& QuicCryptoClientConfig::CachedState::server_config() const { |
477 return server_config_; | 479 return server_config_; |
478 } | 480 } |
479 | 481 |
480 const string& | 482 const string& |
481 QuicCryptoClientConfig::CachedState::source_address_token() const { | 483 QuicCryptoClientConfig::CachedState::source_address_token() const { |
482 return source_address_token_; | 484 return source_address_token_; |
483 } | 485 } |
484 | 486 |
485 const vector<string>& QuicCryptoClientConfig::CachedState::certs() const { | 487 const vector<string>& QuicCryptoClientConfig::CachedState::certs() const { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 856 |
855 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { | 857 ChannelIDSigner* QuicCryptoClientConfig::channel_id_signer() const { |
856 return channel_id_signer_.get(); | 858 return channel_id_signer_.get(); |
857 } | 859 } |
858 | 860 |
859 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { | 861 void QuicCryptoClientConfig::SetChannelIDSigner(ChannelIDSigner* signer) { |
860 channel_id_signer_.reset(signer); | 862 channel_id_signer_.reset(signer); |
861 } | 863 } |
862 | 864 |
863 } // namespace net | 865 } // namespace net |
OLD | NEW |