| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "net/cert/internal/cert_errors.h" |
| 9 #include "net/cert/internal/certificate_policies.h" | 10 #include "net/cert/internal/certificate_policies.h" |
| 10 #include "net/cert/internal/extended_key_usage.h" | 11 #include "net/cert/internal/extended_key_usage.h" |
| 11 #include "net/cert/internal/name_constraints.h" | 12 #include "net/cert/internal/name_constraints.h" |
| 12 #include "net/cert/internal/parse_certificate.h" | 13 #include "net/cert/internal/parse_certificate.h" |
| 13 #include "net/cert/internal/parse_name.h" | 14 #include "net/cert/internal/parse_name.h" |
| 14 #include "net/cert/internal/signature_algorithm.h" | 15 #include "net/cert/internal/signature_algorithm.h" |
| 15 #include "net/cert/internal/signature_policy.h" | 16 #include "net/cert/internal/signature_policy.h" |
| 16 #include "net/cert/internal/verify_signed_data.h" | 17 #include "net/cert/internal/verify_signed_data.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 bool FindExtension(const der::Input& oid, | 22 bool FindExtension(const der::Input& oid, |
| 22 std::map<der::Input, ParsedExtension>* extensions, | 23 std::map<der::Input, ParsedExtension>* extensions, |
| 23 ParsedExtension* extension) { | 24 ParsedExtension* extension) { |
| 24 auto it = extensions->find(oid); | 25 auto it = extensions->find(oid); |
| 25 if (it == extensions->end()) | 26 if (it == extensions->end()) |
| 26 return false; | 27 return false; |
| 27 *extension = it->second; | 28 *extension = it->second; |
| 28 return true; | 29 return true; |
| 29 } | 30 } |
| 30 | 31 |
| 31 void ParseCertificateForFuzzer(const der::Input& in) { | 32 void ParseCertificateForFuzzer(const der::Input& in) { |
| 32 der::Input tbs_certificate_tlv; | 33 der::Input tbs_certificate_tlv; |
| 33 der::Input signature_algorithm_tlv; | 34 der::Input signature_algorithm_tlv; |
| 34 der::BitString signature_value; | 35 der::BitString signature_value; |
| 36 CertErrors errors; |
| 35 if (!ParseCertificate(in, &tbs_certificate_tlv, &signature_algorithm_tlv, | 37 if (!ParseCertificate(in, &tbs_certificate_tlv, &signature_algorithm_tlv, |
| 36 &signature_value)) | 38 &signature_value, &errors)) |
| 37 return; | 39 return; |
| 38 std::unique_ptr<SignatureAlgorithm> sig_alg( | 40 std::unique_ptr<SignatureAlgorithm> sig_alg( |
| 39 SignatureAlgorithm::CreateFromDer(signature_algorithm_tlv)); | 41 SignatureAlgorithm::CreateFromDer(signature_algorithm_tlv)); |
| 40 | 42 |
| 41 ParsedTbsCertificate tbs; | 43 ParsedTbsCertificate tbs; |
| 42 if (!ParseTbsCertificate(tbs_certificate_tlv, {}, &tbs)) | 44 if (!ParseTbsCertificate(tbs_certificate_tlv, {}, &tbs)) |
| 43 return; | 45 return; |
| 44 | 46 |
| 45 RDNSequence subject; | 47 RDNSequence subject; |
| 46 ignore_result(ParseName(tbs.subject_tlv, &subject)); | 48 ignore_result(ParseName(tbs.subject_tlv, &subject)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 } | 73 } |
| 72 | 74 |
| 73 } // namespace | 75 } // namespace |
| 74 } // namespace net | 76 } // namespace net |
| 75 | 77 |
| 76 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 78 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 77 net::der::Input in(data, size); | 79 net::der::Input in(data, size); |
| 78 net::ParseCertificateForFuzzer(in); | 80 net::ParseCertificateForFuzzer(in); |
| 79 return 0; | 81 return 0; |
| 80 } | 82 } |
| OLD | NEW |