OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/quic_crypto_server_config.h" | 5 #include "net/quic/crypto/quic_crypto_server_config.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 private: | 140 private: |
141 ValidateClientHelloResultCallback::Result* result_; | 141 ValidateClientHelloResultCallback::Result* result_; |
142 ValidateClientHelloResultCallback* done_cb_; | 142 ValidateClientHelloResultCallback* done_cb_; |
143 | 143 |
144 DISALLOW_COPY_AND_ASSIGN(VerifyNonceIsValidAndUniqueCallback); | 144 DISALLOW_COPY_AND_ASSIGN(VerifyNonceIsValidAndUniqueCallback); |
145 }; | 145 }; |
146 | 146 |
147 // static | 147 // static |
148 const char QuicCryptoServerConfig::TESTING[] = "secret string for testing"; | 148 const char QuicCryptoServerConfig::TESTING[] = "secret string for testing"; |
149 | 149 |
| 150 PrimaryConfigChangedCallback::PrimaryConfigChangedCallback() { |
| 151 } |
| 152 |
| 153 PrimaryConfigChangedCallback::~PrimaryConfigChangedCallback() { |
| 154 } |
150 | 155 |
151 ValidateClientHelloResultCallback::ValidateClientHelloResultCallback() { | 156 ValidateClientHelloResultCallback::ValidateClientHelloResultCallback() { |
152 } | 157 } |
153 | 158 |
154 ValidateClientHelloResultCallback::~ValidateClientHelloResultCallback() { | 159 ValidateClientHelloResultCallback::~ValidateClientHelloResultCallback() { |
155 } | 160 } |
156 | 161 |
157 void ValidateClientHelloResultCallback::Run(const Result* result) { | 162 void ValidateClientHelloResultCallback::Run(const Result* result) { |
158 RunImpl(result->client_hello, *result); | 163 RunImpl(result->client_hello, *result); |
159 delete result; | 164 delete result; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 790 |
786 if (primary_config_.get()) { | 791 if (primary_config_.get()) { |
787 primary_config_->is_primary = false; | 792 primary_config_->is_primary = false; |
788 } | 793 } |
789 primary_config_ = new_primary; | 794 primary_config_ = new_primary; |
790 new_primary->is_primary = true; | 795 new_primary->is_primary = true; |
791 DVLOG(1) << "New primary config. orbit: " | 796 DVLOG(1) << "New primary config. orbit: " |
792 << base::HexEncode( | 797 << base::HexEncode( |
793 reinterpret_cast<const char*>(primary_config_->orbit), | 798 reinterpret_cast<const char*>(primary_config_->orbit), |
794 kOrbitSize); | 799 kOrbitSize); |
| 800 if (primary_config_changed_cb_.get() != NULL) { |
| 801 primary_config_changed_cb_->Run(primary_config_->id); |
| 802 } |
795 | 803 |
796 return; | 804 return; |
797 } | 805 } |
798 | 806 |
799 // All config's primary times are in the past. We should make the most recent | 807 // All config's primary times are in the past. We should make the most recent |
800 // most recent and highest priority candidate primary. | 808 // most recent and highest priority candidate primary. |
801 scoped_refptr<Config> new_primary(best_candidate); | 809 scoped_refptr<Config> new_primary(best_candidate); |
802 if (primary_config_.get()) { | 810 if (primary_config_.get()) { |
803 primary_config_->is_primary = false; | 811 primary_config_->is_primary = false; |
804 } | 812 } |
805 primary_config_ = new_primary; | 813 primary_config_ = new_primary; |
806 new_primary->is_primary = true; | 814 new_primary->is_primary = true; |
807 DVLOG(1) << "New primary config. orbit: " | 815 DVLOG(1) << "New primary config. orbit: " |
808 << base::HexEncode( | 816 << base::HexEncode( |
809 reinterpret_cast<const char*>(primary_config_->orbit), | 817 reinterpret_cast<const char*>(primary_config_->orbit), |
810 kOrbitSize); | 818 kOrbitSize); |
811 next_config_promotion_time_ = QuicWallTime::Zero(); | 819 next_config_promotion_time_ = QuicWallTime::Zero(); |
| 820 if (primary_config_changed_cb_.get() != NULL) { |
| 821 primary_config_changed_cb_->Run(primary_config_->id); |
| 822 } |
812 } | 823 } |
813 | 824 |
814 void QuicCryptoServerConfig::EvaluateClientHello( | 825 void QuicCryptoServerConfig::EvaluateClientHello( |
815 const uint8* primary_orbit, | 826 const uint8* primary_orbit, |
816 ValidateClientHelloResultCallback::Result* client_hello_state, | 827 ValidateClientHelloResultCallback::Result* client_hello_state, |
817 ValidateClientHelloResultCallback* done_cb) const { | 828 ValidateClientHelloResultCallback* done_cb) const { |
818 ValidateClientHelloHelper helper(client_hello_state, done_cb); | 829 ValidateClientHelloHelper helper(client_hello_state, done_cb); |
819 | 830 |
820 const CryptoHandshakeMessage& client_hello = | 831 const CryptoHandshakeMessage& client_hello = |
821 client_hello_state->client_hello; | 832 client_hello_state->client_hello; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 DCHECK(!server_nonce_strike_register_.get()); | 1196 DCHECK(!server_nonce_strike_register_.get()); |
1186 server_nonce_strike_register_max_entries_ = max_entries; | 1197 server_nonce_strike_register_max_entries_ = max_entries; |
1187 } | 1198 } |
1188 | 1199 |
1189 void QuicCryptoServerConfig::set_server_nonce_strike_register_window_secs( | 1200 void QuicCryptoServerConfig::set_server_nonce_strike_register_window_secs( |
1190 uint32 window_secs) { | 1201 uint32 window_secs) { |
1191 DCHECK(!server_nonce_strike_register_.get()); | 1202 DCHECK(!server_nonce_strike_register_.get()); |
1192 server_nonce_strike_register_window_secs_ = window_secs; | 1203 server_nonce_strike_register_window_secs_ = window_secs; |
1193 } | 1204 } |
1194 | 1205 |
| 1206 void QuicCryptoServerConfig::AcquirePrimaryConfigChangedCb( |
| 1207 PrimaryConfigChangedCallback* cb) { |
| 1208 base::AutoLock locked(configs_lock_); |
| 1209 primary_config_changed_cb_.reset(cb); |
| 1210 } |
| 1211 |
1195 string QuicCryptoServerConfig::NewSourceAddressToken( | 1212 string QuicCryptoServerConfig::NewSourceAddressToken( |
1196 const IPEndPoint& ip, | 1213 const IPEndPoint& ip, |
1197 QuicRandom* rand, | 1214 QuicRandom* rand, |
1198 QuicWallTime now) const { | 1215 QuicWallTime now) const { |
1199 SourceAddressToken source_address_token; | 1216 SourceAddressToken source_address_token; |
1200 source_address_token.set_ip(IPAddressToPackedString(ip.address())); | 1217 source_address_token.set_ip(IPAddressToPackedString(ip.address())); |
1201 source_address_token.set_timestamp(now.ToUNIXSeconds()); | 1218 source_address_token.set_timestamp(now.ToUNIXSeconds()); |
1202 | 1219 |
1203 return source_address_token_boxer_.Box( | 1220 return source_address_token_boxer_.Box( |
1204 rand, source_address_token.SerializeAsString()); | 1221 rand, source_address_token.SerializeAsString()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 | 1327 |
1311 QuicCryptoServerConfig::Config::Config() | 1328 QuicCryptoServerConfig::Config::Config() |
1312 : channel_id_enabled(false), | 1329 : channel_id_enabled(false), |
1313 is_primary(false), | 1330 is_primary(false), |
1314 primary_time(QuicWallTime::Zero()), | 1331 primary_time(QuicWallTime::Zero()), |
1315 priority(0) {} | 1332 priority(0) {} |
1316 | 1333 |
1317 QuicCryptoServerConfig::Config::~Config() { STLDeleteElements(&key_exchanges); } | 1334 QuicCryptoServerConfig::Config::~Config() { STLDeleteElements(&key_exchanges); } |
1318 | 1335 |
1319 } // namespace net | 1336 } // namespace net |
OLD | NEW |