// Copyright 2020 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 "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_Renewal_Response_Fuzz and rest of message // into encrypted license_renewal_response. wvoec::OEMCrypto_Renewal_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 renewal_response = fuzzed_data.ConsumeRemainingBytes(); wvoec::OEMCryptoRenewalAPIFuzz renewal_response_fuzz; renewal_response_fuzz.Initialize(); renewal_response_fuzz.license_messages().SignAndVerifyRequest(); renewal_response_fuzz.license_messages().CreateDefaultResponse(); // Inject timer limits from fuzzed input to timer_limits field from // core license response. renewal_response_fuzz.license_messages().InjectFuzzedTimerLimits( fuzzed_structure); renewal_response_fuzz.license_messages().EncryptAndSignResponse(); renewal_response_fuzz.license_messages().LoadResponse(); // Call renewal response API using fuzzed data. renewal_response_fuzz.renewal_messages().SignAndVerifyRequest(); renewal_response_fuzz.renewal_messages().InjectFuzzedResponseData( fuzzed_structure, renewal_response.data(), renewal_response.size()); renewal_response_fuzz.renewal_messages().LoadResponse(); renewal_response_fuzz.Terminate(); return 0; }