Files
ce_cdm/oemcrypto/test/fuzz_tests/oemcrypto_load_release_fuzz.cc
2024-06-25 14:03:53 -07:00

39 lines
1.3 KiB
C++

// Copyright 2024 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine
// License Agreement.
#include "FuzzedDataProvider.h"
#include "oec_session_util.h"
#include "oemcrypto_fuzz_helper.h"
#include "oemcrypto_fuzz_structs.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
wvoec::RedirectStdoutToFile();
// Copy input data to OEMCrypto_Release_Response_Fuzz and rest of message
// into encrypted license_release_response.
wvoec::OEMCrypto_Release_Response_Fuzz fuzzed_structure;
if (size < sizeof(fuzzed_structure)) {
return 0;
}
FuzzedDataProvider fuzzed_data(data, size);
fuzzed_data.ConsumeData(&fuzzed_structure, sizeof(fuzzed_structure));
const std::vector<uint8_t> release_response =
fuzzed_data.ConsumeRemainingBytes<uint8_t>();
wvoec::OEMCryptoLicenseAPIFuzz license_api_fuzz;
license_api_fuzz.Initialize();
license_api_fuzz.LoadLicense();
// Call release response API using fuzzed data.
wvoec::ReleaseRoundTrip release_messages(
&license_api_fuzz.license_messages());
release_messages.SignAndVerifyRequest();
release_messages.InjectFuzzedResponseData(
fuzzed_structure, release_response.data(), release_response.size());
release_messages.LoadResponse();
license_api_fuzz.Terminate();
return 0;
}