Add OEMCrypto_GetRandom fuzzer

Merged from https://widevine-internal-review.googlesource.com/174771
Merged from https://widevine-internal-review.googlesource.com/174854

Change-Id: Ia654123bcbe8fa2e7daadaab79c1149ff3cde6b0
This commit is contained in:
Ian Benz
2023-05-09 20:16:54 +00:00
committed by Robert Shih
parent 76cf1cd985
commit 8a4160bf8a

View File

@@ -0,0 +1,24 @@
// 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"
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
wvoec::RedirectStdoutToFile();
wvoec::SessionUtil session_util;
wvoec::InitializeFuzz(session_util);
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
std::vector<uint8_t> random_data(
FuzzedDataProvider(data, size)
.ConsumeIntegralInRange<size_t>(0, wvoec::MAX_FUZZ_OUTPUT_LENGTH));
OEMCrypto_GetRandom(random_data.data(), random_data.size());
return 0;
}