crl_set_fuzzer.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <fuzzer/FuzzedDataProvider.h>
  7. #include "net/cert/crl_set.h"
  8. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  9. if (size < 32 + 32 + 20)
  10. return 0;
  11. FuzzedDataProvider data_provider(data, size);
  12. std::string spki_hash = data_provider.ConsumeBytesAsString(32);
  13. std::string issuer_hash = data_provider.ConsumeBytesAsString(32);
  14. size_t serial_length = data_provider.ConsumeIntegralInRange(4, 19);
  15. std::string serial = data_provider.ConsumeBytesAsString(serial_length);
  16. std::string crlset_data = data_provider.ConsumeRemainingBytesAsString();
  17. scoped_refptr<net::CRLSet> out_crl_set;
  18. net::CRLSet::Parse(crlset_data, &out_crl_set);
  19. if (out_crl_set) {
  20. out_crl_set->CheckSPKI(spki_hash);
  21. out_crl_set->CheckSerial(serial, issuer_hash);
  22. out_crl_set->IsExpired();
  23. }
  24. return 0;
  25. }