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:
@@ -2,33 +2,31 @@
|
|||||||
// source code may only be used and distributed under the Widevine
|
// source code may only be used and distributed under the Widevine
|
||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
|
#include "FuzzedDataProvider.h"
|
||||||
#include "OEMCryptoCENC.h"
|
#include "OEMCryptoCENC.h"
|
||||||
#include "oemcrypto_fuzz_helper.h"
|
#include "oemcrypto_fuzz_helper.h"
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
wvoec::RedirectStdoutToFile();
|
wvoec::RedirectStdoutToFile();
|
||||||
|
|
||||||
if (size < sizeof(ODK_ParsedLicense) + sizeof(wvoec::MessageData)) {
|
wvoec::SessionFuzz session_fuzz;
|
||||||
return 0;
|
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;
|
OEMCrypto_RemoveEntitledKeySession(key_session);
|
||||||
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();
|
|
||||||
|
|
||||||
uint32_t key_session_id;
|
session_fuzz.Terminate();
|
||||||
OEMCrypto_CreateEntitledKeySession(license_api_fuzz.session_id(),
|
|
||||||
&key_session_id);
|
|
||||||
|
|
||||||
OEMCrypto_RemoveEntitledKeySession(key_session_id);
|
|
||||||
|
|
||||||
license_api_fuzz.Terminate();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user