Add OEMCrypto_GetBootCertificateChain fuzzer
Merged from https://widevine-internal-review.googlesource.com/168818 Merged from https://widevine-internal-review.googlesource.com/169890 Change-Id: I2530555a1cf94726c82511504e480b843b244c7b
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
// 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 <vector>
|
||||||
|
|
||||||
|
#include "FuzzedDataProvider.h"
|
||||||
|
#include "OEMCryptoCENC.h"
|
||||||
|
#include "oemcrypto_fuzz_helper.h"
|
||||||
|
|
||||||
|
using namespace wvoec;
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
|
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||||
|
// reduce noise
|
||||||
|
RedirectStdoutToFile();
|
||||||
|
|
||||||
|
static InitializeFuzz initialize_fuzz;
|
||||||
|
FuzzedDataProvider fuzzed_data(data, size);
|
||||||
|
|
||||||
|
// bcc and bcc_length parameters
|
||||||
|
size_t bcc_length_data =
|
||||||
|
fuzzed_data.ConsumeIntegralInRange<size_t>(0, MAX_FUZZ_OUTPUT_LENGTH);
|
||||||
|
std::vector<uint8_t> bcc(bcc_length_data);
|
||||||
|
size_t* const bcc_length =
|
||||||
|
fuzzed_data.ConsumeBool() ? &bcc_length_data : nullptr;
|
||||||
|
|
||||||
|
// additional_signature and additional_signature_length parameters
|
||||||
|
size_t additional_signature_length_data =
|
||||||
|
fuzzed_data.ConsumeIntegralInRange<size_t>(0, MAX_FUZZ_OUTPUT_LENGTH);
|
||||||
|
std::vector<uint8_t> additional_signature(additional_signature_length_data);
|
||||||
|
size_t* const additional_signature_length =
|
||||||
|
fuzzed_data.ConsumeBool() ? &additional_signature_length_data : nullptr;
|
||||||
|
|
||||||
|
OEMCrypto_GetBootCertificateChain(bcc.data(), bcc_length,
|
||||||
|
additional_signature.data(),
|
||||||
|
additional_signature_length);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user