Add OEMCrypto_QueryKeyControl fuzzer
Merged from https://widevine-internal-review.googlesource.com/177111 Merged from https://widevine-internal-review.googlesource.com/177117 Change-Id: Iea28155a369f71557a32cc34da7bd328f78e2413
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// 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);
|
||||
|
||||
// key_control_block and key_control_block_length parameters
|
||||
size_t key_control_block_length_data =
|
||||
fuzzed_data.ConsumeIntegralInRange<size_t>(0,
|
||||
wvoec::MAX_FUZZ_OUTPUT_LENGTH);
|
||||
std::vector<uint8_t> key_control_block(key_control_block_length_data);
|
||||
size_t* const key_control_block_length =
|
||||
fuzzed_data.ConsumeBool() ? &key_control_block_length_data : nullptr;
|
||||
|
||||
const std::vector<uint8_t> content_key_id =
|
||||
fuzzed_data.ConsumeRemainingBytes<uint8_t>();
|
||||
|
||||
OEMCrypto_QueryKeyControl(license_api_fuzz.session().session_id(),
|
||||
content_key_id.data(), content_key_id.size(),
|
||||
key_control_block.data(), key_control_block_length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user