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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 public: | 83 public: |
84 ValidateClientHelloHelper(ValidateClientHelloResultCallback::Result* result, | 84 ValidateClientHelloHelper(ValidateClientHelloResultCallback::Result* result, |
85 ValidateClientHelloResultCallback* done_cb) | 85 ValidateClientHelloResultCallback* done_cb) |
86 : result_(result), done_cb_(done_cb) {} | 86 : result_(result), done_cb_(done_cb) {} |
87 | 87 |
88 ~ValidateClientHelloHelper() { | 88 ~ValidateClientHelloHelper() { |
89 QUIC_BUG_IF(done_cb_ != nullptr) | 89 QUIC_BUG_IF(done_cb_ != nullptr) |
90 << "Deleting ValidateClientHelloHelper with a pending callback."; | 90 << "Deleting ValidateClientHelloHelper with a pending callback."; |
91 } | 91 } |
92 | 92 |
93 void ValidationComplete(QuicErrorCode error_code, const char* error_details) { | 93 void ValidationComplete( |
| 94 QuicErrorCode error_code, |
| 95 const char* error_details, |
| 96 std::unique_ptr<ProofSource::Details> proof_source_details) { |
94 result_->error_code = error_code; | 97 result_->error_code = error_code; |
95 result_->error_details = error_details; | 98 result_->error_details = error_details; |
96 done_cb_->Run(result_); | 99 done_cb_->Run(result_, std::move(proof_source_details)); |
97 DetachCallback(); | 100 DetachCallback(); |
98 } | 101 } |
99 | 102 |
100 void DetachCallback() { | 103 void DetachCallback() { |
101 QUIC_BUG_IF(done_cb_ == nullptr) << "Callback already detached."; | 104 QUIC_BUG_IF(done_cb_ == nullptr) << "Callback already detached."; |
102 done_cb_ = nullptr; | 105 done_cb_ = nullptr; |
103 } | 106 } |
104 | 107 |
105 private: | 108 private: |
106 ValidateClientHelloResultCallback::Result* result_; | 109 ValidateClientHelloResultCallback::Result* result_; |
107 ValidateClientHelloResultCallback* done_cb_; | 110 ValidateClientHelloResultCallback* done_cb_; |
108 | 111 |
109 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloHelper); | 112 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloHelper); |
110 }; | 113 }; |
111 | 114 |
112 class VerifyNonceIsValidAndUniqueCallback | 115 class VerifyNonceIsValidAndUniqueCallback |
113 : public StrikeRegisterClient::ResultCallback { | 116 : public StrikeRegisterClient::ResultCallback { |
114 public: | 117 public: |
115 VerifyNonceIsValidAndUniqueCallback( | 118 VerifyNonceIsValidAndUniqueCallback( |
116 ValidateClientHelloResultCallback::Result* result, | 119 ValidateClientHelloResultCallback::Result* result, |
| 120 std::unique_ptr<ProofSource::Details> proof_source_details, |
117 ValidateClientHelloResultCallback* done_cb) | 121 ValidateClientHelloResultCallback* done_cb) |
118 : result_(result), done_cb_(done_cb) {} | 122 : result_(result), |
| 123 proof_source_details_(std::move(proof_source_details)), |
| 124 done_cb_(done_cb) {} |
119 | 125 |
120 protected: | 126 protected: |
121 void RunImpl(bool nonce_is_valid_and_unique, | 127 void RunImpl(bool nonce_is_valid_and_unique, |
122 InsertStatus nonce_error) override { | 128 InsertStatus nonce_error) override { |
123 DVLOG(1) << "Using client nonce, unique: " << nonce_is_valid_and_unique | 129 DVLOG(1) << "Using client nonce, unique: " << nonce_is_valid_and_unique |
124 << " nonce_error: " << nonce_error; | 130 << " nonce_error: " << nonce_error; |
125 if (!nonce_is_valid_and_unique) { | 131 if (!nonce_is_valid_and_unique) { |
126 HandshakeFailureReason client_nonce_error; | 132 HandshakeFailureReason client_nonce_error; |
127 switch (nonce_error) { | 133 switch (nonce_error) { |
128 case NONCE_INVALID_FAILURE: | 134 case NONCE_INVALID_FAILURE: |
(...skipping 18 matching lines...) Expand all Loading... |
147 client_nonce_error = CLIENT_NONCE_UNKNOWN_FAILURE; | 153 client_nonce_error = CLIENT_NONCE_UNKNOWN_FAILURE; |
148 break; | 154 break; |
149 case NONCE_OK: | 155 case NONCE_OK: |
150 default: | 156 default: |
151 QUIC_BUG << "Unexpected client nonce error: " << nonce_error; | 157 QUIC_BUG << "Unexpected client nonce error: " << nonce_error; |
152 client_nonce_error = CLIENT_NONCE_UNKNOWN_FAILURE; | 158 client_nonce_error = CLIENT_NONCE_UNKNOWN_FAILURE; |
153 break; | 159 break; |
154 } | 160 } |
155 result_->info.reject_reasons.push_back(client_nonce_error); | 161 result_->info.reject_reasons.push_back(client_nonce_error); |
156 } | 162 } |
157 done_cb_->Run(result_); | 163 done_cb_->Run(result_, std::move(proof_source_details_)); |
158 } | 164 } |
159 | 165 |
160 private: | 166 private: |
161 ValidateClientHelloResultCallback::Result* result_; | 167 ValidateClientHelloResultCallback::Result* result_; |
| 168 std::unique_ptr<ProofSource::Details> proof_source_details_; |
162 ValidateClientHelloResultCallback* done_cb_; | 169 ValidateClientHelloResultCallback* done_cb_; |
163 | 170 |
164 DISALLOW_COPY_AND_ASSIGN(VerifyNonceIsValidAndUniqueCallback); | 171 DISALLOW_COPY_AND_ASSIGN(VerifyNonceIsValidAndUniqueCallback); |
165 }; | 172 }; |
166 | 173 |
167 // static | 174 // static |
168 const char QuicCryptoServerConfig::TESTING[] = "secret string for testing"; | 175 const char QuicCryptoServerConfig::TESTING[] = "secret string for testing"; |
169 | 176 |
170 ClientHelloInfo::ClientHelloInfo(const IPAddress& in_client_ip, | 177 ClientHelloInfo::ClientHelloInfo(const IPAddress& in_client_ip, |
171 QuicWallTime in_now) | 178 QuicWallTime in_now) |
(...skipping 12 matching lines...) Expand all Loading... |
184 : client_hello(in_client_hello), | 191 : client_hello(in_client_hello), |
185 info(in_client_ip, in_now), | 192 info(in_client_ip, in_now), |
186 error_code(QUIC_NO_ERROR) {} | 193 error_code(QUIC_NO_ERROR) {} |
187 | 194 |
188 ValidateClientHelloResultCallback::Result::~Result() {} | 195 ValidateClientHelloResultCallback::Result::~Result() {} |
189 | 196 |
190 ValidateClientHelloResultCallback::ValidateClientHelloResultCallback() {} | 197 ValidateClientHelloResultCallback::ValidateClientHelloResultCallback() {} |
191 | 198 |
192 ValidateClientHelloResultCallback::~ValidateClientHelloResultCallback() {} | 199 ValidateClientHelloResultCallback::~ValidateClientHelloResultCallback() {} |
193 | 200 |
194 void ValidateClientHelloResultCallback::Run(const Result* result) { | 201 void ValidateClientHelloResultCallback::Run( |
195 RunImpl(result->client_hello, *result); | 202 const Result* result, |
| 203 std::unique_ptr<ProofSource::Details> details) { |
| 204 RunImpl(result->client_hello, *result, std::move(details)); |
196 delete result; | 205 delete result; |
197 delete this; | 206 delete this; |
198 } | 207 } |
199 | 208 |
200 QuicCryptoServerConfig::ConfigOptions::ConfigOptions() | 209 QuicCryptoServerConfig::ConfigOptions::ConfigOptions() |
201 : expiry_time(QuicWallTime::Zero()), | 210 : expiry_time(QuicWallTime::Zero()), |
202 channel_id_enabled(false), | 211 channel_id_enabled(false), |
203 token_binding_enabled(false), | 212 token_binding_enabled(false), |
204 p256(false) {} | 213 p256(false) {} |
205 | 214 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 if (FLAGS_quic_refresh_proof && version > QUIC_VERSION_30) { | 541 if (FLAGS_quic_refresh_proof && version > QUIC_VERSION_30) { |
533 // QUIC v31 and above require a new proof for each CHLO so clear the | 542 // QUIC v31 and above require a new proof for each CHLO so clear the |
534 // existing proof, if any. | 543 // existing proof, if any. |
535 crypto_proof->chain = nullptr; | 544 crypto_proof->chain = nullptr; |
536 crypto_proof->signature = ""; | 545 crypto_proof->signature = ""; |
537 crypto_proof->cert_sct = ""; | 546 crypto_proof->cert_sct = ""; |
538 } | 547 } |
539 EvaluateClientHello(server_ip, version, primary_orbit, requested_config, | 548 EvaluateClientHello(server_ip, version, primary_orbit, requested_config, |
540 primary_config, crypto_proof, result, done_cb); | 549 primary_config, crypto_proof, result, done_cb); |
541 } else { | 550 } else { |
542 done_cb->Run(result); | 551 done_cb->Run(result, nullptr /* proof_source_details */); |
543 } | 552 } |
544 } | 553 } |
545 | 554 |
546 QuicErrorCode QuicCryptoServerConfig::ProcessClientHello( | 555 QuicErrorCode QuicCryptoServerConfig::ProcessClientHello( |
547 const ValidateClientHelloResultCallback::Result& validate_chlo_result, | 556 const ValidateClientHelloResultCallback::Result& validate_chlo_result, |
548 bool reject_only, | 557 bool reject_only, |
549 QuicConnectionId connection_id, | 558 QuicConnectionId connection_id, |
550 const IPAddress& server_ip, | 559 const IPAddress& server_ip, |
551 const IPEndPoint& client_address, | 560 const IPEndPoint& client_address, |
552 QuicVersion version, | 561 QuicVersion version, |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 primary_orbit_(primary_orbit), | 1011 primary_orbit_(primary_orbit), |
1003 requested_config_(std::move(requested_config)), | 1012 requested_config_(std::move(requested_config)), |
1004 primary_config_(std::move(primary_config)), | 1013 primary_config_(std::move(primary_config)), |
1005 crypto_proof_(crypto_proof), | 1014 crypto_proof_(crypto_proof), |
1006 client_hello_state_(client_hello_state), | 1015 client_hello_state_(client_hello_state), |
1007 done_cb_(done_cb) {} | 1016 done_cb_(done_cb) {} |
1008 | 1017 |
1009 void Run(bool ok, | 1018 void Run(bool ok, |
1010 const scoped_refptr<ProofSource::Chain>& chain, | 1019 const scoped_refptr<ProofSource::Chain>& chain, |
1011 const string& signature, | 1020 const string& signature, |
1012 const string& leaf_cert_sct) override { | 1021 const string& leaf_cert_sct, |
| 1022 std::unique_ptr<ProofSource::Details> details) override { |
1013 if (ok) { | 1023 if (ok) { |
1014 crypto_proof_->chain = chain; | 1024 crypto_proof_->chain = chain; |
1015 crypto_proof_->signature = signature; | 1025 crypto_proof_->signature = signature; |
1016 crypto_proof_->cert_sct = leaf_cert_sct; | 1026 crypto_proof_->cert_sct = leaf_cert_sct; |
1017 } | 1027 } |
1018 config_.EvaluateClientHelloAfterGetProof( | 1028 config_.EvaluateClientHelloAfterGetProof( |
1019 found_error_, server_ip_, version_, primary_orbit_, requested_config_, | 1029 found_error_, server_ip_, version_, primary_orbit_, requested_config_, |
1020 primary_config_, crypto_proof_, !ok, client_hello_state_, done_cb_); | 1030 primary_config_, crypto_proof_, std::move(details), !ok, |
| 1031 client_hello_state_, done_cb_); |
1021 } | 1032 } |
1022 | 1033 |
1023 private: | 1034 private: |
1024 const QuicCryptoServerConfig& config_; | 1035 const QuicCryptoServerConfig& config_; |
1025 const bool found_error_; | 1036 const bool found_error_; |
1026 const IPAddress& server_ip_; | 1037 const IPAddress& server_ip_; |
1027 const QuicVersion version_; | 1038 const QuicVersion version_; |
1028 const uint8_t* primary_orbit_; | 1039 const uint8_t* primary_orbit_; |
1029 const scoped_refptr<QuicCryptoServerConfig::Config> requested_config_; | 1040 const scoped_refptr<QuicCryptoServerConfig::Config> requested_config_; |
1030 const scoped_refptr<QuicCryptoServerConfig::Config> primary_config_; | 1041 const scoped_refptr<QuicCryptoServerConfig::Config> primary_config_; |
(...skipping 11 matching lines...) Expand all Loading... |
1042 QuicCryptoProof* crypto_proof, | 1053 QuicCryptoProof* crypto_proof, |
1043 ValidateClientHelloResultCallback::Result* client_hello_state, | 1054 ValidateClientHelloResultCallback::Result* client_hello_state, |
1044 ValidateClientHelloResultCallback* done_cb) const { | 1055 ValidateClientHelloResultCallback* done_cb) const { |
1045 ValidateClientHelloHelper helper(client_hello_state, done_cb); | 1056 ValidateClientHelloHelper helper(client_hello_state, done_cb); |
1046 | 1057 |
1047 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; | 1058 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; |
1048 ClientHelloInfo* info = &(client_hello_state->info); | 1059 ClientHelloInfo* info = &(client_hello_state->info); |
1049 | 1060 |
1050 if (client_hello.size() < kClientHelloMinimumSize) { | 1061 if (client_hello.size() < kClientHelloMinimumSize) { |
1051 helper.ValidationComplete(QUIC_CRYPTO_INVALID_VALUE_LENGTH, | 1062 helper.ValidationComplete(QUIC_CRYPTO_INVALID_VALUE_LENGTH, |
1052 "Client hello too small"); | 1063 "Client hello too small", nullptr); |
1053 return; | 1064 return; |
1054 } | 1065 } |
1055 | 1066 |
1056 if (client_hello.GetStringPiece(kSNI, &info->sni) && | 1067 if (client_hello.GetStringPiece(kSNI, &info->sni) && |
1057 !CryptoUtils::IsValidSNI(info->sni)) { | 1068 !CryptoUtils::IsValidSNI(info->sni)) { |
1058 helper.ValidationComplete(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, | 1069 helper.ValidationComplete(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, |
1059 "Invalid SNI name"); | 1070 "Invalid SNI name", nullptr); |
1060 return; | 1071 return; |
1061 } | 1072 } |
1062 | 1073 |
1063 client_hello.GetStringPiece(kUAID, &info->user_agent_id); | 1074 client_hello.GetStringPiece(kUAID, &info->user_agent_id); |
1064 | 1075 |
1065 HandshakeFailureReason source_address_token_error = MAX_FAILURE_REASON; | 1076 HandshakeFailureReason source_address_token_error = MAX_FAILURE_REASON; |
1066 StringPiece srct; | 1077 StringPiece srct; |
1067 if (client_hello.GetStringPiece(kSourceAddressTokenTag, &srct)) { | 1078 if (client_hello.GetStringPiece(kSourceAddressTokenTag, &srct)) { |
1068 Config& config = requested_config ? *requested_config : *primary_config; | 1079 Config& config = requested_config ? *requested_config : *primary_config; |
1069 source_address_token_error = | 1080 source_address_token_error = |
(...skipping 11 matching lines...) Expand all Loading... |
1081 } | 1092 } |
1082 | 1093 |
1083 if (!requested_config.get()) { | 1094 if (!requested_config.get()) { |
1084 StringPiece requested_scid; | 1095 StringPiece requested_scid; |
1085 if (client_hello.GetStringPiece(kSCID, &requested_scid)) { | 1096 if (client_hello.GetStringPiece(kSCID, &requested_scid)) { |
1086 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); | 1097 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); |
1087 } else { | 1098 } else { |
1088 info->reject_reasons.push_back(SERVER_CONFIG_INCHOATE_HELLO_FAILURE); | 1099 info->reject_reasons.push_back(SERVER_CONFIG_INCHOATE_HELLO_FAILURE); |
1089 } | 1100 } |
1090 // No server config with the requested ID. | 1101 // No server config with the requested ID. |
1091 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1102 helper.ValidationComplete(QUIC_NO_ERROR, "", nullptr); |
1092 return; | 1103 return; |
1093 } | 1104 } |
1094 | 1105 |
1095 if (!client_hello.GetStringPiece(kNONC, &info->client_nonce)) { | 1106 if (!client_hello.GetStringPiece(kNONC, &info->client_nonce)) { |
1096 info->reject_reasons.push_back(SERVER_CONFIG_INCHOATE_HELLO_FAILURE); | 1107 info->reject_reasons.push_back(SERVER_CONFIG_INCHOATE_HELLO_FAILURE); |
1097 // Report no client nonce as INCHOATE_HELLO_FAILURE. | 1108 // Report no client nonce as INCHOATE_HELLO_FAILURE. |
1098 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1109 helper.ValidationComplete(QUIC_NO_ERROR, "", nullptr); |
1099 return; | 1110 return; |
1100 } | 1111 } |
1101 | 1112 |
1102 bool found_error = false; | 1113 bool found_error = false; |
1103 if (source_address_token_error != HANDSHAKE_OK) { | 1114 if (source_address_token_error != HANDSHAKE_OK) { |
1104 info->reject_reasons.push_back(source_address_token_error); | 1115 info->reject_reasons.push_back(source_address_token_error); |
1105 // No valid source address token. | 1116 // No valid source address token. |
1106 found_error = true; | 1117 found_error = true; |
1107 } | 1118 } |
1108 | 1119 |
(...skipping 27 matching lines...) Expand all Loading... |
1136 | 1147 |
1137 // No need to get a new proof if one was already generated. | 1148 // No need to get a new proof if one was already generated. |
1138 if (need_proof && | 1149 if (need_proof && |
1139 !proof_source_->GetProof( | 1150 !proof_source_->GetProof( |
1140 server_ip, info->sni.as_string(), serialized_config, version, | 1151 server_ip, info->sni.as_string(), serialized_config, version, |
1141 chlo_hash, x509_ecdsa_supported, &crypto_proof->chain, | 1152 chlo_hash, x509_ecdsa_supported, &crypto_proof->chain, |
1142 &crypto_proof->signature, &crypto_proof->cert_sct)) { | 1153 &crypto_proof->signature, &crypto_proof->cert_sct)) { |
1143 get_proof_failed = true; | 1154 get_proof_failed = true; |
1144 } | 1155 } |
1145 | 1156 |
| 1157 // Details are null because the synchronous version of GetProof does not |
| 1158 // return any stats. Eventually the synchronous codepath will be eliminated. |
1146 EvaluateClientHelloAfterGetProof( | 1159 EvaluateClientHelloAfterGetProof( |
1147 found_error, server_ip, version, primary_orbit, requested_config, | 1160 found_error, server_ip, version, primary_orbit, requested_config, |
1148 primary_config, crypto_proof, get_proof_failed, client_hello_state, | 1161 primary_config, crypto_proof, nullptr /* proof_source_details */, |
1149 done_cb); | 1162 get_proof_failed, client_hello_state, done_cb); |
1150 helper.DetachCallback(); | 1163 helper.DetachCallback(); |
1151 } | 1164 } |
1152 | 1165 |
1153 void QuicCryptoServerConfig::EvaluateClientHelloAfterGetProof( | 1166 void QuicCryptoServerConfig::EvaluateClientHelloAfterGetProof( |
1154 bool found_error, | 1167 bool found_error, |
1155 const IPAddress& server_ip, | 1168 const IPAddress& server_ip, |
1156 QuicVersion version, | 1169 QuicVersion version, |
1157 const uint8_t* primary_orbit, | 1170 const uint8_t* primary_orbit, |
1158 scoped_refptr<Config> requested_config, | 1171 scoped_refptr<Config> requested_config, |
1159 scoped_refptr<Config> primary_config, | 1172 scoped_refptr<Config> primary_config, |
1160 QuicCryptoProof* crypto_proof, | 1173 QuicCryptoProof* crypto_proof, |
| 1174 std::unique_ptr<ProofSource::Details> proof_source_details, |
1161 bool get_proof_failed, | 1175 bool get_proof_failed, |
1162 ValidateClientHelloResultCallback::Result* client_hello_state, | 1176 ValidateClientHelloResultCallback::Result* client_hello_state, |
1163 ValidateClientHelloResultCallback* done_cb) const { | 1177 ValidateClientHelloResultCallback* done_cb) const { |
1164 ValidateClientHelloHelper helper(client_hello_state, done_cb); | 1178 ValidateClientHelloHelper helper(client_hello_state, done_cb); |
1165 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; | 1179 const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; |
1166 ClientHelloInfo* info = &(client_hello_state->info); | 1180 ClientHelloInfo* info = &(client_hello_state->info); |
1167 | 1181 |
1168 if (get_proof_failed) { | 1182 if (get_proof_failed) { |
1169 found_error = true; | 1183 found_error = true; |
1170 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); | 1184 info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); |
(...skipping 16 matching lines...) Expand all Loading... |
1187 client_hello.GetStringPiece(kServerNonceTag, &info->server_nonce); | 1201 client_hello.GetStringPiece(kServerNonceTag, &info->server_nonce); |
1188 | 1202 |
1189 if (version > QUIC_VERSION_32) { | 1203 if (version > QUIC_VERSION_32) { |
1190 DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher."; | 1204 DVLOG(1) << "No 0-RTT replay protection in QUIC_VERSION_33 and higher."; |
1191 // If the server nonce is empty and we're requiring handshake confirmation | 1205 // If the server nonce is empty and we're requiring handshake confirmation |
1192 // for DoS reasons then we must reject the CHLO. | 1206 // for DoS reasons then we must reject the CHLO. |
1193 if (FLAGS_quic_require_handshake_confirmation && | 1207 if (FLAGS_quic_require_handshake_confirmation && |
1194 info->server_nonce.empty()) { | 1208 info->server_nonce.empty()) { |
1195 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); | 1209 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); |
1196 } | 1210 } |
1197 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1211 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1212 std::move(proof_source_details)); |
1198 return; | 1213 return; |
1199 } | 1214 } |
1200 | 1215 |
1201 if (!replay_protection_) { | 1216 if (!replay_protection_) { |
1202 DVLOG(1) << "No replay protection."; | 1217 DVLOG(1) << "No replay protection."; |
1203 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1218 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1219 std::move(proof_source_details)); |
1204 return; | 1220 return; |
1205 } | 1221 } |
1206 | 1222 |
1207 if (!info->server_nonce.empty()) { | 1223 if (!info->server_nonce.empty()) { |
1208 // If the server nonce is present, use it to establish uniqueness. | 1224 // If the server nonce is present, use it to establish uniqueness. |
1209 HandshakeFailureReason server_nonce_error = | 1225 HandshakeFailureReason server_nonce_error = |
1210 ValidateServerNonce(info->server_nonce, info->now); | 1226 ValidateServerNonce(info->server_nonce, info->now); |
1211 bool is_unique = server_nonce_error == HANDSHAKE_OK; | 1227 bool is_unique = server_nonce_error == HANDSHAKE_OK; |
1212 if (!is_unique) { | 1228 if (!is_unique) { |
1213 info->reject_reasons.push_back(server_nonce_error); | 1229 info->reject_reasons.push_back(server_nonce_error); |
1214 } | 1230 } |
1215 DVLOG(1) << "Using server nonce, unique: " << is_unique; | 1231 DVLOG(1) << "Using server nonce, unique: " << is_unique; |
1216 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1232 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1233 std::move(proof_source_details)); |
1217 return; | 1234 return; |
1218 } | 1235 } |
1219 // If we hit this block, the server nonce was empty. If we're requiring | 1236 // If we hit this block, the server nonce was empty. If we're requiring |
1220 // handshake confirmation for DoS reasons and there's no server nonce present, | 1237 // handshake confirmation for DoS reasons and there's no server nonce present, |
1221 // reject the CHLO. | 1238 // reject the CHLO. |
1222 if (FLAGS_quic_require_handshake_confirmation || | 1239 if (FLAGS_quic_require_handshake_confirmation || |
1223 FLAGS_quic_require_handshake_confirmation_pre33) { | 1240 FLAGS_quic_require_handshake_confirmation_pre33) { |
1224 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); | 1241 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); |
1225 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1242 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1243 std::move(proof_source_details)); |
1226 return; | 1244 return; |
1227 } | 1245 } |
1228 | 1246 |
1229 // We want to contact strike register only if there are no errors because it | 1247 // We want to contact strike register only if there are no errors because it |
1230 // is a RPC call and is expensive. | 1248 // is a RPC call and is expensive. |
1231 if (found_error) { | 1249 if (found_error) { |
1232 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1250 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1251 std::move(proof_source_details)); |
1233 return; | 1252 return; |
1234 } | 1253 } |
1235 | 1254 |
1236 // Use the client nonce to establish uniqueness. | 1255 // Use the client nonce to establish uniqueness. |
1237 StrikeRegisterClient* strike_register_client; | 1256 StrikeRegisterClient* strike_register_client; |
1238 { | 1257 { |
1239 base::AutoLock locked(strike_register_client_lock_); | 1258 base::AutoLock locked(strike_register_client_lock_); |
1240 strike_register_client = strike_register_client_.get(); | 1259 strike_register_client = strike_register_client_.get(); |
1241 } | 1260 } |
1242 | 1261 |
1243 if (!strike_register_client) { | 1262 if (!strike_register_client) { |
1244 // Either a valid server nonces or a strike register is required. | 1263 // Either a valid server nonces or a strike register is required. |
1245 // Since neither are present, reject the handshake which will send a | 1264 // Since neither are present, reject the handshake which will send a |
1246 // server nonce to the client. | 1265 // server nonce to the client. |
1247 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); | 1266 info->reject_reasons.push_back(SERVER_NONCE_REQUIRED_FAILURE); |
1248 helper.ValidationComplete(QUIC_NO_ERROR, ""); | 1267 helper.ValidationComplete(QUIC_NO_ERROR, "", |
| 1268 std::move(proof_source_details)); |
1249 return; | 1269 return; |
1250 } | 1270 } |
1251 | 1271 |
1252 strike_register_client->VerifyNonceIsValidAndUnique( | 1272 strike_register_client->VerifyNonceIsValidAndUnique( |
1253 info->client_nonce, info->now, | 1273 info->client_nonce, info->now, |
1254 new VerifyNonceIsValidAndUniqueCallback(client_hello_state, done_cb)); | 1274 new VerifyNonceIsValidAndUniqueCallback( |
| 1275 client_hello_state, std::move(proof_source_details), done_cb)); |
1255 helper.DetachCallback(); | 1276 helper.DetachCallback(); |
1256 } | 1277 } |
1257 | 1278 |
1258 bool QuicCryptoServerConfig::BuildServerConfigUpdateMessage( | 1279 bool QuicCryptoServerConfig::BuildServerConfigUpdateMessage( |
1259 QuicVersion version, | 1280 QuicVersion version, |
1260 StringPiece chlo_hash, | 1281 StringPiece chlo_hash, |
1261 const SourceAddressTokens& previous_source_address_tokens, | 1282 const SourceAddressTokens& previous_source_address_tokens, |
1262 const IPAddress& server_ip, | 1283 const IPAddress& server_ip, |
1263 const IPAddress& client_ip, | 1284 const IPAddress& client_ip, |
1264 const QuicClock* clock, | 1285 const QuicClock* clock, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 client_common_set_hashes_(params.client_common_set_hashes), | 1388 client_common_set_hashes_(params.client_common_set_hashes), |
1368 client_cached_cert_hashes_(params.client_cached_cert_hashes), | 1389 client_cached_cert_hashes_(params.client_cached_cert_hashes), |
1369 sct_supported_by_client_(params.sct_supported_by_client), | 1390 sct_supported_by_client_(params.sct_supported_by_client), |
1370 message_(std::move(message)), | 1391 message_(std::move(message)), |
1371 cb_(std::move(cb)) {} | 1392 cb_(std::move(cb)) {} |
1372 | 1393 |
1373 void QuicCryptoServerConfig::BuildServerConfigUpdateMessageProofSourceCallback:: | 1394 void QuicCryptoServerConfig::BuildServerConfigUpdateMessageProofSourceCallback:: |
1374 Run(bool ok, | 1395 Run(bool ok, |
1375 const scoped_refptr<ProofSource::Chain>& chain, | 1396 const scoped_refptr<ProofSource::Chain>& chain, |
1376 const string& signature, | 1397 const string& signature, |
1377 const string& leaf_cert_sct) { | 1398 const string& leaf_cert_sct, |
| 1399 std::unique_ptr<ProofSource::Details> details) { |
1378 config_->FinishBuildServerConfigUpdateMessage( | 1400 config_->FinishBuildServerConfigUpdateMessage( |
1379 version_, compressed_certs_cache_, common_cert_sets_, | 1401 version_, compressed_certs_cache_, common_cert_sets_, |
1380 client_common_set_hashes_, client_cached_cert_hashes_, | 1402 client_common_set_hashes_, client_cached_cert_hashes_, |
1381 sct_supported_by_client_, ok, chain, signature, leaf_cert_sct, | 1403 sct_supported_by_client_, ok, chain, signature, leaf_cert_sct, |
1382 std::move(message_), std::move(cb_)); | 1404 std::move(details), std::move(message_), std::move(cb_)); |
1383 } | 1405 } |
1384 | 1406 |
1385 void QuicCryptoServerConfig::FinishBuildServerConfigUpdateMessage( | 1407 void QuicCryptoServerConfig::FinishBuildServerConfigUpdateMessage( |
1386 QuicVersion version, | 1408 QuicVersion version, |
1387 QuicCompressedCertsCache* compressed_certs_cache, | 1409 QuicCompressedCertsCache* compressed_certs_cache, |
1388 const CommonCertSets* common_cert_sets, | 1410 const CommonCertSets* common_cert_sets, |
1389 const string& client_common_set_hashes, | 1411 const string& client_common_set_hashes, |
1390 const string& client_cached_cert_hashes, | 1412 const string& client_cached_cert_hashes, |
1391 bool sct_supported_by_client, | 1413 bool sct_supported_by_client, |
1392 bool ok, | 1414 bool ok, |
1393 const scoped_refptr<ProofSource::Chain>& chain, | 1415 const scoped_refptr<ProofSource::Chain>& chain, |
1394 const string& signature, | 1416 const string& signature, |
1395 const string& leaf_cert_sct, | 1417 const string& leaf_cert_sct, |
| 1418 std::unique_ptr<ProofSource::Details> details, |
1396 CryptoHandshakeMessage message, | 1419 CryptoHandshakeMessage message, |
1397 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const { | 1420 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const { |
1398 if (!ok) { | 1421 if (!ok) { |
1399 cb->Run(false, message); | 1422 cb->Run(false, message); |
1400 return; | 1423 return; |
1401 } | 1424 } |
1402 | 1425 |
1403 const string compressed = | 1426 const string compressed = |
1404 CompressChain(compressed_certs_cache, chain, client_common_set_hashes, | 1427 CompressChain(compressed_certs_cache, chain, client_common_set_hashes, |
1405 client_cached_cert_hashes, common_cert_sets); | 1428 client_cached_cert_hashes, common_cert_sets); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 priority(0), | 2057 priority(0), |
2035 source_address_token_boxer(nullptr) {} | 2058 source_address_token_boxer(nullptr) {} |
2036 | 2059 |
2037 QuicCryptoServerConfig::Config::~Config() { | 2060 QuicCryptoServerConfig::Config::~Config() { |
2038 STLDeleteElements(&key_exchanges); | 2061 STLDeleteElements(&key_exchanges); |
2039 } | 2062 } |
2040 | 2063 |
2041 QuicCryptoProof::QuicCryptoProof() {} | 2064 QuicCryptoProof::QuicCryptoProof() {} |
2042 QuicCryptoProof::~QuicCryptoProof() {} | 2065 QuicCryptoProof::~QuicCryptoProof() {} |
2043 } // namespace net | 2066 } // namespace net |
OLD | NEW |