Source release 16.3.0
This commit is contained in:
42
oemcrypto/test/fuzz_tests/oemcrypto_load_renewal_fuzz.cc
Normal file
42
oemcrypto/test/fuzz_tests/oemcrypto_load_renewal_fuzz.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
#include "oemcrypto_fuzz_structs.h"
|
||||
|
||||
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();
|
||||
if (size < sizeof(OEMCrypto_Renewal_Response_Fuzz)) {
|
||||
return 0;
|
||||
}
|
||||
// Copy input data to OEMCrypto_Renewal_Response_Fuzz and rest of message
|
||||
// into encrypted license_renewal_response.
|
||||
OEMCrypto_Renewal_Response_Fuzz fuzzed_data;
|
||||
memcpy(&fuzzed_data, data, sizeof(fuzzed_data));
|
||||
const uint8_t* renewal_response =
|
||||
data + sizeof(OEMCrypto_Renewal_Response_Fuzz);
|
||||
const size_t renewal_response_size =
|
||||
size - sizeof(OEMCrypto_Renewal_Response_Fuzz);
|
||||
|
||||
OEMCryptoLicenseAPIFuzz license_api_fuzz;
|
||||
license_api_fuzz.license_messages().SignAndVerifyRequest();
|
||||
license_api_fuzz.license_messages().CreateDefaultResponse();
|
||||
// Inject timer limits from fuzzed input to timer_limits field from
|
||||
// core license response.
|
||||
license_api_fuzz.license_messages().InjectFuzzedTimerLimits(fuzzed_data);
|
||||
license_api_fuzz.license_messages().EncryptAndSignResponse();
|
||||
license_api_fuzz.license_messages().LoadResponse();
|
||||
|
||||
OEMCryptoRenewalAPIFuzz renewal_response_fuzz;
|
||||
renewal_response_fuzz.renewal_messages().SignAndVerifyRequest();
|
||||
renewal_response_fuzz.renewal_messages().InjectFuzzedResponseData(
|
||||
fuzzed_data, renewal_response, renewal_response_size);
|
||||
renewal_response_fuzz.renewal_messages().LoadResponse();
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
Reference in New Issue
Block a user