OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cert/ct_policy_enforcer.h" | 5 #include "net/cert/ct_policy_enforcer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // a log was qualified or pending qualification at time of issuance (in the | 213 // a log was qualified or pending qualification at time of issuance (in the |
214 // case of embedded SCTs). It's acceptable to ignore the origin of the SCT, | 214 // case of embedded SCTs). It's acceptable to ignore the origin of the SCT, |
215 // because SCTs delivered via OCSP/TLS extension will cover the full | 215 // because SCTs delivered via OCSP/TLS extension will cover the full |
216 // certificate, which necessarily will exist only after the precertificate | 216 // certificate, which necessarily will exist only after the precertificate |
217 // has been logged and the actual certificate issued. | 217 // has been logged and the actual certificate issued. |
218 // Note: Here, issuance date is defined as the earliest of all SCTs, rather | 218 // Note: Here, issuance date is defined as the earliest of all SCTs, rather |
219 // than the latest of embedded SCTs, in order to give CAs the benefit of | 219 // than the latest of embedded SCTs, in order to give CAs the benefit of |
220 // the doubt in the event a log is revoked in the midst of processing | 220 // the doubt in the event a log is revoked in the midst of processing |
221 // a precertificate and issuing the certificate. | 221 // a precertificate and issuing the certificate. |
222 base::Time issuance_date = base::Time::Max(); | 222 base::Time issuance_date = base::Time::Max(); |
223 for (const auto& sct : verified_scts) { | 223 for (const auto& sct : verified_scts) |
224 base::Time unused; | |
225 if (ct::IsLogDisqualified(sct->log_id, &unused)) | |
226 continue; | |
227 issuance_date = std::min(sct->timestamp, issuance_date); | 224 issuance_date = std::min(sct->timestamp, issuance_date); |
228 } | |
229 | 225 |
230 bool has_valid_google_sct = false; | 226 bool has_valid_google_sct = false; |
231 bool has_valid_nongoogle_sct = false; | 227 bool has_valid_nongoogle_sct = false; |
232 bool has_valid_embedded_sct = false; | 228 bool has_valid_embedded_sct = false; |
233 bool has_valid_nonembedded_sct = false; | 229 bool has_valid_nonembedded_sct = false; |
234 bool has_embedded_google_sct = false; | 230 bool has_embedded_google_sct = false; |
235 bool has_embedded_nongoogle_sct = false; | 231 bool has_embedded_nongoogle_sct = false; |
236 std::vector<base::StringPiece> embedded_log_ids; | 232 std::vector<base::StringPiece> embedded_log_ids; |
237 for (const auto& sct : verified_scts) { | 233 for (const auto& sct : verified_scts) { |
238 base::Time disqualification_date; | |
239 bool is_disqualified = | |
240 ct::IsLogDisqualified(sct->log_id, &disqualification_date); | |
241 if (is_disqualified && | |
242 sct->origin != ct::SignedCertificateTimestamp::SCT_EMBEDDED) { | |
243 // For OCSP and TLS delivered SCTs, only SCTs that are valid at the | |
244 // time of check are accepted. | |
245 continue; | |
246 } | |
247 | |
248 if (ct::IsLogOperatedByGoogle(sct->log_id)) { | 234 if (ct::IsLogOperatedByGoogle(sct->log_id)) { |
249 has_valid_google_sct |= !is_disqualified; | 235 has_valid_google_sct = true; |
250 if (sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED) | 236 if (sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED) |
251 has_embedded_google_sct = true; | 237 has_embedded_google_sct = true; |
252 } else { | 238 } else { |
253 has_valid_nongoogle_sct |= !is_disqualified; | 239 has_valid_nongoogle_sct = true; |
254 if (sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED) | 240 if (sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED) |
255 has_embedded_nongoogle_sct = true; | 241 has_embedded_nongoogle_sct = true; |
256 } | 242 } |
257 if (sct->origin != ct::SignedCertificateTimestamp::SCT_EMBEDDED) { | 243 if (sct->origin != ct::SignedCertificateTimestamp::SCT_EMBEDDED) { |
258 has_valid_nonembedded_sct = true; | 244 has_valid_nonembedded_sct = true; |
259 } else { | 245 } else { |
260 has_valid_embedded_sct |= !is_disqualified; | 246 has_valid_embedded_sct = true; |
261 // If the log is disqualified, it only counts towards quorum if | 247 embedded_log_ids.push_back(sct->log_id); |
262 // the certificate was issued before the log was disqualified, and the | |
263 // SCT was obtained before the log was disqualified. | |
264 if (!is_disqualified || (issuance_date < disqualification_date && | |
265 sct->timestamp < disqualification_date)) { | |
266 embedded_log_ids.push_back(sct->log_id); | |
267 } | |
268 } | 248 } |
269 } | 249 } |
270 | 250 |
271 // Option 1: | 251 // Option 1: |
272 // An SCT presented via the TLS extension OR embedded within a stapled OCSP | 252 // An SCT presented via the TLS extension OR embedded within a stapled OCSP |
273 // response is from a log qualified at time of check; | 253 // response is from a log qualified at time of check; |
274 // AND there is at least one SCT from a Google Log that is qualified at | 254 // AND there is at least one SCT from a Google Log that is qualified at |
275 // time of check, presented via any method; | 255 // time of check, presented via any method; |
276 // AND there is at least one SCT from a non-Google Log that is qualified | 256 // AND there is at least one SCT from a non-Google Log that is qualified |
277 // at the time of check, presented via any method. | 257 // at the time of check, presented via any method. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 429 |
450 if (!details.build_timely) | 430 if (!details.build_timely) |
451 return ct::EVPolicyCompliance::EV_POLICY_BUILD_NOT_TIMELY; | 431 return ct::EVPolicyCompliance::EV_POLICY_BUILD_NOT_TIMELY; |
452 | 432 |
453 LogEVPolicyComplianceToUMA(details.status, ev_whitelist); | 433 LogEVPolicyComplianceToUMA(details.status, ev_whitelist); |
454 | 434 |
455 return details.status; | 435 return details.status; |
456 } | 436 } |
457 | 437 |
458 } // namespace net | 438 } // namespace net |
OLD | NEW |