json_web_key_fuzzer.cc 1021 B

123456789101112131415161718192021222324252627282930313233343536
  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 "media/cdm/json_web_key.h"
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. #include <string>
  8. #include "base/logging.h"
  9. // For disabling noisy logging.
  10. struct Environment {
  11. Environment() { logging::SetMinLogLevel(logging::LOG_FATAL); }
  12. };
  13. Environment* env = new Environment();
  14. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  15. std::vector<uint8_t> license(data, data + size);
  16. std::vector<uint8_t> first_key;
  17. media::ExtractFirstKeyIdFromLicenseRequest(license, &first_key);
  18. std::string input(reinterpret_cast<const char*>(data), size);
  19. media::KeyIdAndKeyPairs keys;
  20. media::CdmSessionType session_type;
  21. media::ExtractKeysFromJWKSet(input, &keys, &session_type);
  22. media::KeyIdList key_ids;
  23. std::string error_message;
  24. media::ExtractKeyIdsFromKeyIdsInitData(input, &key_ids, &error_message);
  25. return 0;
  26. }