Simplify and enable create and remove entitled key session fuzzer

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

Change-Id: Iebddae2412c66dbaf5bac042518aea58f9b0c315
This commit is contained in:
Ian Benz
2023-05-10 14:00:36 +00:00
committed by Robert Shih
parent 708670c98b
commit 76cf1cd985

View File

@@ -2,33 +2,31 @@
// source code may only be used and distributed under the Widevine
// License Agreement.
#include "FuzzedDataProvider.h"
#include "OEMCryptoCENC.h"
#include "oemcrypto_fuzz_helper.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
wvoec::RedirectStdoutToFile();
if (size < sizeof(ODK_ParsedLicense) + sizeof(wvoec::MessageData)) {
return 0;
wvoec::SessionFuzz session_fuzz;
session_fuzz.Initialize();
FuzzedDataProvider fuzzed_data(data, size);
uint32_t key_session;
uint32_t* const key_session_ptr =
fuzzed_data.ConsumeBool() ? &key_session : nullptr;
OEMCrypto_CreateEntitledKeySession(session_fuzz.session().session_id(),
key_session_ptr);
if (key_session_ptr == nullptr || fuzzed_data.ConsumeBool()) {
key_session = fuzzed_data.ConsumeIntegral<uint32_t>();
}
wvoec::OEMCryptoLicenseAPIFuzz license_api_fuzz;
license_api_fuzz.Initialize();
license_api_fuzz.license_messages().set_license_type(
OEMCrypto_EntitlementLicense);
license_api_fuzz.license_messages().SignAndVerifyRequest();
// Interpreting input fuzz data as unencrypted (core_response + license
// message data) from license server.
license_api_fuzz.license_messages().InjectFuzzedResponseData(data, size);
license_api_fuzz.license_messages().EncryptAndSignResponse();
license_api_fuzz.license_messages().LoadResponse();
OEMCrypto_RemoveEntitledKeySession(key_session);
uint32_t key_session_id;
OEMCrypto_CreateEntitledKeySession(license_api_fuzz.session_id(),
&key_session_id);
OEMCrypto_RemoveEntitledKeySession(key_session_id);
license_api_fuzz.Terminate();
session_fuzz.Terminate();
return 0;
}