• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "../pki/cert_errors.h"
9 #include "../pki/parsed_certificate.h"
10 #include <openssl/base.h>
11 #include <openssl/pool.h>
12 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
14   bssl::CertErrors errors;
15   std::shared_ptr<const bssl::ParsedCertificate> cert =
16       bssl::ParsedCertificate::Create(
17           bssl::UniquePtr<CRYPTO_BUFFER>(
18               CRYPTO_BUFFER_new(data, size, nullptr)),
19           {}, &errors);
20 
21   // Severe errors must be provided iff the parsing failed.
22   BSSL_CHECK(errors.ContainsAnyErrorWithSeverity(
23                  bssl::CertError::SEVERITY_HIGH) == (cert == nullptr));
24 
25   return 0;
26 }
27