1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <stddef.h> 6 #include <stdint.h> 7 8 #include "net/cert/pki/cert_errors.h" 9 #include "net/cert/pki/parsed_certificate.h" 10 #include "net/cert/x509_util.h" 11 #include "third_party/boringssl/src/include/openssl/span.h" 12 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)13extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 14 net::CertErrors errors; 15 std::shared_ptr<const net::ParsedCertificate> cert = 16 net::ParsedCertificate::Create( 17 net::x509_util::CreateCryptoBuffer(base::make_span(data, size)), {}, 18 &errors); 19 20 // Severe errors must be provided iff the parsing failed. 21 CHECK_EQ(errors.ContainsAnyErrorWithSeverity(net::CertError::SEVERITY_HIGH), 22 cert == nullptr); 23 24 return 0; 25 } 26