| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/internal/verify_certificate_chain.h" | 5 #include "net/cert/internal/verify_certificate_chain.h" |
| 6 | 6 |
| 7 #include "net/cert/internal/parsed_certificate.h" | 7 #include "net/cert/internal/parsed_certificate.h" |
| 8 #include "net/cert/internal/signature_policy.h" | 8 #include "net/cert/internal/signature_policy.h" |
| 9 #include "net/cert/internal/trust_store.h" | 9 #include "net/cert/internal/trust_store.h" |
| 10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 public: | 48 public: |
| 49 static bool Verify(std::vector<std::string> cert_ders, | 49 static bool Verify(std::vector<std::string> cert_ders, |
| 50 std::vector<std::string> crl_ders) { | 50 std::vector<std::string> crl_ders) { |
| 51 if (cert_ders.empty()) { | 51 if (cert_ders.empty()) { |
| 52 ADD_FAILURE() << "cert_ders is empty"; | 52 ADD_FAILURE() << "cert_ders is empty"; |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 // First entry in the PKITS chain is the trust anchor. | 55 // First entry in the PKITS chain is the trust anchor. |
| 56 TrustStore trust_store; | 56 TrustStore trust_store; |
| 57 scoped_refptr<ParsedCertificate> anchor( | 57 scoped_refptr<ParsedCertificate> anchor( |
| 58 ParsedCertificate::CreateFromCertificateCopy(cert_ders[0])); | 58 ParsedCertificate::CreateFromCertificateCopy(cert_ders[0], {})); |
| 59 EXPECT_TRUE(anchor); | 59 EXPECT_TRUE(anchor); |
| 60 if (anchor) | 60 if (anchor) |
| 61 trust_store.AddTrustedCertificate(std::move(anchor)); | 61 trust_store.AddTrustedCertificate(std::move(anchor)); |
| 62 | 62 |
| 63 // PKITS lists chains from trust anchor to target, VerifyCertificateChain | 63 // PKITS lists chains from trust anchor to target, VerifyCertificateChain |
| 64 // takes them starting with the target and not including the trust anchor. | 64 // takes them starting with the target and not including the trust anchor. |
| 65 std::vector<scoped_refptr<net::ParsedCertificate>> input_chain; | 65 std::vector<scoped_refptr<net::ParsedCertificate>> input_chain; |
| 66 for (size_t i = cert_ders.size() - 1; i > 0; --i) { | 66 for (size_t i = cert_ders.size() - 1; i > 0; --i) { |
| 67 if (!net::ParsedCertificate::CreateAndAddToVector( | 67 if (!net::ParsedCertificate::CreateAndAddToVector( |
| 68 reinterpret_cast<const uint8_t*>(cert_ders[i].data()), | 68 reinterpret_cast<const uint8_t*>(cert_ders[i].data()), |
| 69 cert_ders[i].size(), | 69 cert_ders[i].size(), |
| 70 net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, | 70 net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, {}, |
| 71 &input_chain)) { | 71 &input_chain)) { |
| 72 ADD_FAILURE() << "cert " << i << " failed to parse"; | 72 ADD_FAILURE() << "cert " << i << " failed to parse"; |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 SimpleSignaturePolicy signature_policy(1024); | 77 SimpleSignaturePolicy signature_policy(1024); |
| 78 | 78 |
| 79 // Run all tests at the time the PKITS was published. | 79 // Run all tests at the time the PKITS was published. |
| 80 der::GeneralizedTime time = {2011, 4, 15, 0, 0, 0}; | 80 der::GeneralizedTime time = {2011, 4, 15, 0, 0, 0}; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 // TODO(mattm): CRL support: PkitsTest04BasicCertificateRevocationTests, | 210 // TODO(mattm): CRL support: PkitsTest04BasicCertificateRevocationTests, |
| 211 // PkitsTest05VerifyingPathswithSelfIssuedCertificates, | 211 // PkitsTest05VerifyingPathswithSelfIssuedCertificates, |
| 212 // PkitsTest14DistributionPoints, PkitsTest15DeltaCRLs | 212 // PkitsTest14DistributionPoints, PkitsTest15DeltaCRLs |
| 213 | 213 |
| 214 // TODO(mattm): Certificate Policies support: PkitsTest08CertificatePolicies, | 214 // TODO(mattm): Certificate Policies support: PkitsTest08CertificatePolicies, |
| 215 // PkitsTest09RequireExplicitPolicy PkitsTest10PolicyMappings, | 215 // PkitsTest09RequireExplicitPolicy PkitsTest10PolicyMappings, |
| 216 // PkitsTest11InhibitPolicyMapping, PkitsTest12InhibitAnyPolicy | 216 // PkitsTest11InhibitPolicyMapping, PkitsTest12InhibitAnyPolicy |
| 217 | 217 |
| 218 } // namespace net | 218 } // namespace net |
| OLD | NEW |