| 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/cert/multi_log_ct_verifier.h" | 5 #include "net/cert/multi_log_ct_verifier.h" |
| 6 | 6 |
| 7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 8 #include "net/cert/ct_log_verifier.h" | 8 #include "net/cert/ct_log_verifier.h" |
| 9 #include "net/cert/ct_objects_extractor.h" | 9 #include "net/cert/ct_objects_extractor.h" |
| 10 #include "net/cert/ct_serialization.h" | 10 #include "net/cert/ct_serialization.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 &precert_entry) && | 54 &precert_entry) && |
| 55 VerifySCTs( | 55 VerifySCTs( |
| 56 embedded_scts, | 56 embedded_scts, |
| 57 precert_entry, | 57 precert_entry, |
| 58 ct::SignedCertificateTimestamp::SCT_EMBEDDED, | 58 ct::SignedCertificateTimestamp::SCT_EMBEDDED, |
| 59 result); | 59 result); |
| 60 } | 60 } |
| 61 | 61 |
| 62 ct::LogEntry x509_entry; | 62 ct::LogEntry x509_entry; |
| 63 if (!ct::GetX509LogEntry(cert->os_cert_handle(), &x509_entry)) | 63 if (!ct::GetX509LogEntry(cert->os_cert_handle(), &x509_entry)) |
| 64 return has_verified_scts ? OK : ERR_FAILED; | 64 return has_verified_scts ? OK : ERR_CT_LOG_ENTRY_CREATION_FAILED; |
| 65 | 65 |
| 66 has_verified_scts |= VerifySCTs( | 66 has_verified_scts |= VerifySCTs( |
| 67 sct_list_from_ocsp, | 67 sct_list_from_ocsp, |
| 68 x509_entry, | 68 x509_entry, |
| 69 ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE, | 69 ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE, |
| 70 result); | 70 result); |
| 71 | 71 |
| 72 has_verified_scts |= VerifySCTs( | 72 has_verified_scts |= VerifySCTs( |
| 73 sct_list_from_tls_extension, | 73 sct_list_from_tls_extension, |
| 74 x509_entry, | 74 x509_entry, |
| 75 ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION, | 75 ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION, |
| 76 result); | 76 result); |
| 77 | 77 |
| 78 if (has_verified_scts) | 78 if (has_verified_scts) |
| 79 return OK; | 79 return OK; |
| 80 | 80 |
| 81 return ERR_FAILED; | 81 return ERR_NO_SCTS_VERIFIED_OK; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool MultiLogCTVerifier::VerifySCTs( | 84 bool MultiLogCTVerifier::VerifySCTs( |
| 85 const std::string& encoded_sct_list, | 85 const std::string& encoded_sct_list, |
| 86 const ct::LogEntry& expected_entry, | 86 const ct::LogEntry& expected_entry, |
| 87 ct::SignedCertificateTimestamp::Origin origin, | 87 ct::SignedCertificateTimestamp::Origin origin, |
| 88 ct::CTVerifyResult* result) { | 88 ct::CTVerifyResult* result) { |
| 89 if (logs_.empty()) | 89 if (logs_.empty()) |
| 90 return false; | 90 return false; |
| 91 | 91 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 | 112 |
| 113 return verified; | 113 return verified; |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool MultiLogCTVerifier::VerifySingleSCT( | 116 bool MultiLogCTVerifier::VerifySingleSCT( |
| 117 scoped_refptr<ct::SignedCertificateTimestamp> sct, | 117 scoped_refptr<ct::SignedCertificateTimestamp> sct, |
| 118 const ct::LogEntry& expected_entry, | 118 const ct::LogEntry& expected_entry, |
| 119 ct::CTVerifyResult* result) { | 119 ct::CTVerifyResult* result) { |
| 120 | 120 |
| 121 // Assume this SCT is untrusted until proven otherwise. | 121 // Assume this SCT is untrusted until proven otherwise. |
| 122 | |
| 123 IDToLogMap::iterator it = logs_.find(sct->log_id); | 122 IDToLogMap::iterator it = logs_.find(sct->log_id); |
| 124 if (it == logs_.end()) { | 123 if (it == logs_.end()) { |
| 125 DVLOG(1) << "SCT does not match any known log."; | 124 DVLOG(1) << "SCT does not match any known log."; |
| 126 result->unknown_logs_scts.push_back(sct); | 125 result->unknown_logs_scts.push_back(sct); |
| 127 return false; | 126 return false; |
| 128 } | 127 } |
| 129 | 128 |
| 130 if (!it->second->Verify(expected_entry, *sct)) { | 129 if (!it->second->Verify(expected_entry, *sct)) { |
| 131 DVLOG(1) << "Unable to verify SCT signature."; | 130 DVLOG(1) << "Unable to verify SCT signature."; |
| 132 result->unverified_scts.push_back(sct); | 131 result->unverified_scts.push_back(sct); |
| 133 return false; | 132 return false; |
| 134 } | 133 } |
| 135 | 134 |
| 136 // SCT verified ok, just make sure the timestamp is legitimate. | 135 // SCT verified ok, just make sure the timestamp is legitimate. |
| 137 if (sct->timestamp > base::Time::Now()) { | 136 if (sct->timestamp > base::Time::Now()) { |
| 138 DVLOG(1) << "SCT is from the future!"; | 137 DVLOG(1) << "SCT is from the future!"; |
| 139 result->unverified_scts.push_back(sct); | 138 result->unverified_scts.push_back(sct); |
| 140 return false; | 139 return false; |
| 141 } | 140 } |
| 142 | 141 |
| 143 result->verified_scts.push_back(sct); | 142 result->verified_scts.push_back(sct); |
| 144 return true; | 143 return true; |
| 145 } | 144 } |
| 146 | 145 |
| 147 } // namespace net | 146 } // namespace net |
| OLD | NEW |