// Copyright 2023 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 "OEMCryptoCENC.h" #include "oemcrypto_fuzz_helper.h" namespace { // Avoid calling non-trivial destructor. wvoec::OEMCryptoLicenseAPIFuzz& license_api_fuzz = *new wvoec::OEMCryptoLicenseAPIFuzz; } // namespace extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { wvoec::RedirectStdoutToFile(); license_api_fuzz.Initialize(); license_api_fuzz.LoadLicense(); return 0; } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { FuzzedDataProvider fuzzed_data(data, size); const OEMCryptoCipherMode cipher_mode = wvoec::ConvertDataToValidEnum(fuzzed_data, OEMCrypto_CipherMode_MaxValue); const std::vector content_key_id = fuzzed_data.ConsumeRemainingBytes(); OEMCrypto_SelectKey(license_api_fuzz.session().session_id(), content_key_id.data(), content_key_id.size(), cipher_mode); return 0; }