| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 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 net::CertErrors errors; | 70 net::CertErrors errors; |
| 71 scoped_refptr<net::ParsedCertificate> cert = | 71 scoped_refptr<net::ParsedCertificate> cert = |
| 72 net::ParsedCertificate::CreateWithoutCopyingUnsafe(data, N, {}, | 72 net::ParsedCertificate::CreateWithoutCopyingUnsafe(data, N, {}, |
| 73 &errors); | 73 &errors); |
| 74 CHECK(cert) << errors.ToDebugString(); | 74 CHECK(cert); |
| 75 // Enforce pathlen constraints and policies defined on the root certificate. | 75 // Enforce pathlen constraints and policies defined on the root certificate. |
| 76 scoped_refptr<net::TrustAnchor> anchor = | 76 scoped_refptr<net::TrustAnchor> anchor = |
| 77 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); | 77 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); |
| 78 store_.AddTrustAnchor(std::move(anchor)); | 78 store_.AddTrustAnchor(std::move(anchor)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 net::TrustStoreInMemory store_; | 81 net::TrustStoreInMemory store_; |
| 82 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); | 82 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); |
| 83 }; | 83 }; |
| 84 | 84 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 336 |
| 337 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( | 337 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( |
| 338 const base::StringPiece& spki) { | 338 const base::StringPiece& spki) { |
| 339 // Use a bogus CommonName, since this is just exposed for testing signature | 339 // Use a bogus CommonName, since this is just exposed for testing signature |
| 340 // verification by unittests. | 340 // verification by unittests. |
| 341 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki), | 341 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki), |
| 342 "CommonName"); | 342 "CommonName"); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace cast_certificate | 345 } // namespace cast_certificate |
| OLD | NEW |