| 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 "components/cast_certificate/cast_cert_validator.h" | 5 #include "components/cast_certificate/cast_cert_validator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Adds a trust anchor given a DER-encoded certificate from static | 66 // Adds a trust anchor given a DER-encoded certificate from static |
| 67 // storage. | 67 // storage. |
| 68 template <size_t N> | 68 template <size_t N> |
| 69 void AddAnchor(const uint8_t (&data)[N]) { | 69 void AddAnchor(const uint8_t (&data)[N]) { |
| 70 scoped_refptr<net::ParsedCertificate> cert = | 70 scoped_refptr<net::ParsedCertificate> cert = |
| 71 net::ParsedCertificate::CreateFromCertificateData( | 71 net::ParsedCertificate::CreateFromCertificateData( |
| 72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, | 72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, |
| 73 {}); | 73 {}); |
| 74 CHECK(cert); | 74 CHECK(cert); |
| 75 // TODO(crbug.com/635200): Support anchor constraints, and initialize the | 75 // Enforce pathlen constraints and policies defined on the root certificate. |
| 76 // anchor using constraints from the self-signed certificate. | |
| 77 scoped_refptr<net::TrustAnchor> anchor = | 76 scoped_refptr<net::TrustAnchor> anchor = |
| 78 net::TrustAnchor::CreateFromCertificateNoConstraints(std::move(cert)); | 77 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); |
| 79 store_.AddTrustAnchor(std::move(anchor)); | 78 store_.AddTrustAnchor(std::move(anchor)); |
| 80 } | 79 } |
| 81 | 80 |
| 82 net::TrustStore store_; | 81 net::TrustStore store_; |
| 83 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); | 82 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>; | 85 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>; |
| 87 | 86 |
| 88 // Helper that looks up an extension by OID given a map of extensions. | 87 // Helper that looks up an extension by OID given a map of extensions. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 350 |
| 352 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( | 351 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( |
| 353 const base::StringPiece& spki) { | 352 const base::StringPiece& spki) { |
| 354 // Use a bogus CommonName, since this is just exposed for testing signature | 353 // Use a bogus CommonName, since this is just exposed for testing signature |
| 355 // verification by unittests. | 354 // verification by unittests. |
| 356 return base::WrapUnique( | 355 return base::WrapUnique( |
| 357 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); | 356 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); |
| 358 } | 357 } |
| 359 | 358 |
| 360 } // namespace cast_certificate | 359 } // namespace cast_certificate |
| OLD | NEW |