Files
ce_cdm/oemcrypto/test/fuzz_tests/oemcrypto_select_key_fuzz.cc
John "Juce" Bruce 2baa7c6e2b Source release 17.1.2
2023-06-23 15:37:42 -07:00

39 lines
1.1 KiB
C++

// 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<uint8_t> content_key_id =
fuzzed_data.ConsumeRemainingBytes<uint8_t>();
OEMCrypto_SelectKey(license_api_fuzz.session().session_id(),
content_key_id.data(), content_key_id.size(),
cipher_mode);
return 0;
}