| 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/path_builder.h" | 5 #include "net/cert/internal/path_builder.h" |
| 6 | 6 |
| 7 #include "net/cert/internal/cert_issuer_source_static.h" | 7 #include "net/cert/internal/cert_issuer_source_static.h" |
| 8 #include "net/cert/internal/signature_policy.h" | 8 #include "net/cert/internal/signature_policy.h" |
| 9 #include "net/cert/internal/trust_store_in_memory.h" | 9 #include "net/cert/internal/trust_store_in_memory.h" |
| 10 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h" | 10 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 TrustStoreInMemory trust_store; | 23 TrustStoreInMemory trust_store; |
| 24 | 24 |
| 25 switch (test.last_cert_trust.type) { | 25 switch (test.last_cert_trust.type) { |
| 26 case CertificateTrustType::TRUSTED_ANCHOR: | 26 case CertificateTrustType::TRUSTED_ANCHOR: |
| 27 trust_store.AddTrustAnchor(test.chain.back()); | 27 trust_store.AddTrustAnchor(test.chain.back()); |
| 28 break; | 28 break; |
| 29 case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS: | 29 case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS: |
| 30 trust_store.AddTrustAnchorWithConstraints(test.chain.back()); | 30 trust_store.AddTrustAnchorWithConstraints(test.chain.back()); |
| 31 break; | 31 break; |
| 32 case CertificateTrustType::UNSPECIFIED: | 32 case CertificateTrustType::UNSPECIFIED: |
| 33 LOG(ERROR) << "Unexpected CertificateTrustType"; | 33 trust_store.AddCertificateWithUnspecifiedTrust(test.chain.back()); |
| 34 break; | 34 break; |
| 35 case CertificateTrustType::DISTRUSTED: | 35 case CertificateTrustType::DISTRUSTED: |
| 36 trust_store.AddDistrustedCertificateForTest(test.chain.back()); | 36 trust_store.AddDistrustedCertificateForTest(test.chain.back()); |
| 37 break; | 37 break; |
| 38 } | 38 } |
| 39 | 39 |
| 40 CertIssuerSourceStatic intermediate_cert_issuer_source; | 40 CertIssuerSourceStatic intermediate_cert_issuer_source; |
| 41 for (size_t i = 1; i < test.chain.size(); ++i) | 41 for (size_t i = 1; i < test.chain.size(); ++i) |
| 42 intermediate_cert_issuer_source.AddCert(test.chain[i]); | 42 intermediate_cert_issuer_source.AddCert(test.chain[i]); |
| 43 | 43 |
| 44 CertPathBuilder::Result result; | 44 CertPathBuilder::Result result; |
| 45 // First cert in the |chain| is the target. | 45 // First cert in the |chain| is the target. |
| 46 CertPathBuilder path_builder(test.chain.front(), &trust_store, | 46 CertPathBuilder path_builder(test.chain.front(), &trust_store, |
| 47 &signature_policy, test.time, test.key_purpose, | 47 &signature_policy, test.time, test.key_purpose, |
| 48 &result); | 48 &result); |
| 49 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); | 49 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); |
| 50 | 50 |
| 51 path_builder.Run(); | 51 path_builder.Run(); |
| 52 EXPECT_EQ(!test.HasHighSeverityErrors(), result.HasValidPath()); | 52 EXPECT_EQ(!test.HasHighSeverityErrors(), result.HasValidPath()); |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, | 58 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, |
| 59 VerifyCertificateChainSingleRootTest, | 59 VerifyCertificateChainSingleRootTest, |
| 60 PathBuilderDelegate); | 60 PathBuilderDelegate); |
| 61 | 61 |
| 62 } // namespace net | 62 } // namespace net |
| OLD | NEW |