| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // * THe Extended Key Usage must includ TLS Client Auth | 170 // * THe Extended Key Usage must includ TLS Client Auth |
| 171 // * May have the policy 1.3.6.1.4.1.11129.2.5.2 to indicate it | 171 // * May have the policy 1.3.6.1.4.1.11129.2.5.2 to indicate it |
| 172 // is an audio-only device. | 172 // is an audio-only device. |
| 173 WARN_UNUSED_RESULT bool CheckTargetCertificate( | 173 WARN_UNUSED_RESULT bool CheckTargetCertificate( |
| 174 const net::der::Input& cert_der, | 174 const net::der::Input& cert_der, |
| 175 std::unique_ptr<CertVerificationContext>* context, | 175 std::unique_ptr<CertVerificationContext>* context, |
| 176 CastDeviceCertPolicy* policy) { | 176 CastDeviceCertPolicy* policy) { |
| 177 // TODO(eroman): Simplify this. The certificate chain verification | 177 // TODO(eroman): Simplify this. The certificate chain verification |
| 178 // function already parses this stuff, awkward to re-do it here. | 178 // function already parses this stuff, awkward to re-do it here. |
| 179 | 179 |
| 180 net::ParsedCertificate cert; | 180 net::der::Input tbs_certificate_tlv; |
| 181 if (!net::ParseCertificate(cert_der, &cert)) | 181 net::der::Input signature_algorithm_tlv; |
| 182 net::der::BitString signature_value; |
| 183 if (!net::ParseCertificate(cert_der, &tbs_certificate_tlv, |
| 184 &signature_algorithm_tlv, &signature_value)) |
| 182 return false; | 185 return false; |
| 183 | 186 |
| 184 net::ParsedTbsCertificate tbs; | 187 net::ParsedTbsCertificate tbs; |
| 185 if (!net::ParseTbsCertificate(cert.tbs_certificate_tlv, &tbs)) | 188 if (!net::ParseTbsCertificate(tbs_certificate_tlv, &tbs)) |
| 186 return false; | 189 return false; |
| 187 | 190 |
| 188 // Get the extensions. | 191 // Get the extensions. |
| 189 if (!tbs.has_extensions) | 192 if (!tbs.has_extensions) |
| 190 return false; | 193 return false; |
| 191 ExtensionsMap extensions; | 194 ExtensionsMap extensions; |
| 192 if (!net::ParseExtensions(tbs.extensions_tlv, &extensions)) | 195 if (!net::ParseExtensions(tbs.extensions_tlv, &extensions)) |
| 193 return false; | 196 return false; |
| 194 | 197 |
| 195 net::der::Input extension_value; | 198 net::der::Input extension_value; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 return base::WrapUnique( | 291 return base::WrapUnique( |
| 289 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); | 292 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); |
| 290 } | 293 } |
| 291 | 294 |
| 292 bool AddTrustAnchorForTest(const uint8_t* data, size_t length) { | 295 bool AddTrustAnchorForTest(const uint8_t* data, size_t length) { |
| 293 return CastTrustStore::Get().AddTrustedCertificateWithoutCopying(data, | 296 return CastTrustStore::Get().AddTrustedCertificateWithoutCopying(data, |
| 294 length); | 297 length); |
| 295 } | 298 } |
| 296 | 299 |
| 297 } // namespace cast_certificate | 300 } // namespace cast_certificate |
| OLD | NEW |