diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_boot_certificate_chain_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_boot_certificate_chain_fuzz.cc new file mode 100644 index 00000000..3016ac46 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_boot_certificate_chain_fuzz.cc @@ -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 + +#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(0, MAX_FUZZ_OUTPUT_LENGTH); + std::vector 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(0, MAX_FUZZ_OUTPUT_LENGTH); + std::vector 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; +}