Updated policy_engine_fuzzer
Implemented google c++ code style changes for policy_engine_fuzzer execs/s: 71 Test: ./policy_engine_fuzzer Bug: 312374669 Change-Id: I8320f360f0c58c4fd3309a9f159ca49568da2abc
This commit is contained in:
@@ -22,7 +22,7 @@ using namespace wvcdm;
|
|||||||
using namespace wvcdm::metrics;
|
using namespace wvcdm::metrics;
|
||||||
using namespace video_widevine;
|
using namespace video_widevine;
|
||||||
|
|
||||||
static constexpr int32_t kLicenseIDVersion = 1;
|
static constexpr int32_t kLicenseIdVersion = 1;
|
||||||
static constexpr int32_t kMaxByte = 256;
|
static constexpr int32_t kMaxByte = 256;
|
||||||
static constexpr int32_t kMinResolution = 1;
|
static constexpr int32_t kMinResolution = 1;
|
||||||
static constexpr int32_t kMaxResolution = 1024;
|
static constexpr int32_t kMaxResolution = 1024;
|
||||||
@@ -42,304 +42,302 @@ class FuzzWvCdmEventListener : public WvCdmEventListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PolicyEngineFuzzer {
|
class PolicyEngineFuzzer {
|
||||||
public:
|
public:
|
||||||
PolicyEngineFuzzer(const uint8_t *data, size_t size) : mFdp(data, size){};
|
PolicyEngineFuzzer(const uint8_t *data, size_t size) : fdp_(data, size){};
|
||||||
void process();
|
void Process();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FuzzedDataProvider mFdp;
|
FuzzedDataProvider fdp_;
|
||||||
KeyId mKeyId;
|
KeyId key_id_;
|
||||||
License mLicense;
|
License license_;
|
||||||
void setUp();
|
void SetUp();
|
||||||
};
|
};
|
||||||
|
|
||||||
void policySetBool(std::function<void(bool)> function,
|
void PolicySetBool(std::function<void(bool)> function,
|
||||||
FuzzedDataProvider *fdp) {
|
FuzzedDataProvider *fdp) {
|
||||||
if (fdp->ConsumeBool()) {
|
if (fdp->ConsumeBool()) {
|
||||||
function(fdp->ConsumeBool());
|
function(fdp->ConsumeBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void policySetInt64(std::function<void(int64_t)> function,
|
void PolicySetInt64(std::function<void(int64_t)> function,
|
||||||
FuzzedDataProvider *fdp) {
|
FuzzedDataProvider *fdp) {
|
||||||
if (fdp->ConsumeBool()) {
|
if (fdp->ConsumeBool()) {
|
||||||
function(fdp->ConsumeIntegral<int64_t>());
|
function(fdp->ConsumeIntegral<int64_t>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolicyEngineFuzzer::setUp() {
|
void PolicyEngineFuzzer::SetUp() {
|
||||||
|
|
||||||
License::KeyContainer *key = mLicense.add_key();
|
License::KeyContainer *key = license_.add_key();
|
||||||
int32_t keyType = mFdp.ConsumeIntegralInRange<uint8_t>(
|
int32_t key_type = fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
License::KeyContainer::SIGNING, License::KeyContainer::ENTITLEMENT);
|
License::KeyContainer::SIGNING, License::KeyContainer::ENTITLEMENT);
|
||||||
key->set_type((License_KeyContainer_KeyType)keyType);
|
key->set_type((License_KeyContainer_KeyType)key_type);
|
||||||
mKeyId = mFdp.ConsumeRandomLengthString(kMaxByte);
|
key_id_ = fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||||
|
|
||||||
LicenseIdentification *id = mLicense.mutable_id();
|
LicenseIdentification *id = license_.mutable_id();
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
id->set_version(kLicenseIDVersion);
|
id->set_version(kLicenseIdVersion);
|
||||||
}
|
}
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
id->set_type(mFdp.ConsumeBool() ? STREAMING : OFFLINE);
|
id->set_type(fdp_.ConsumeBool() ? STREAMING : OFFLINE);
|
||||||
}
|
}
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
id->set_provider_session_token(mFdp.ConsumeRandomLengthString(kMaxByte));
|
id->set_provider_session_token(fdp_.ConsumeRandomLengthString(kMaxByte));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
mLicense.set_license_start_time(mFdp.ConsumeIntegral<int64_t>());
|
license_.set_license_start_time(fdp_.ConsumeIntegral<int64_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
License_KeyContainer_OutputProtection *outputProtection =
|
License_KeyContainer_OutputProtection *output_protection =
|
||||||
key->mutable_required_protection();
|
key->mutable_required_protection();
|
||||||
License_KeyContainer_OutputProtection_HDCP hdcpLevel =
|
License_KeyContainer_OutputProtection_HDCP hdcp_level =
|
||||||
(License_KeyContainer_OutputProtection_HDCP)mFdp
|
(License_KeyContainer_OutputProtection_HDCP)fdp_
|
||||||
.ConsumeIntegralInRange<uint8_t>(HDCP_NONE, HDCP_NO_DIGITAL_OUTPUT);
|
.ConsumeIntegralInRange<uint8_t>(HDCP_NONE, HDCP_NO_DIGITAL_OUTPUT);
|
||||||
outputProtection->set_hdcp(hdcpLevel);
|
output_protection->set_hdcp(hdcp_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
const std::string ivString = mFdp.ConsumeRandomLengthString(kMaxByte);
|
const std::string iv_string = fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||||
key->set_iv(ivString);
|
key->set_iv(iv_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (keyType) {
|
switch (key_type) {
|
||||||
case License::KeyContainer::SIGNING: {
|
case License::KeyContainer::SIGNING: {
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
mKeyId = mFdp.ConsumeBool() ? kSigningKeyId : mKeyId;
|
key_id_ = fdp_.ConsumeBool() ? kSigningKeyId : key_id_;
|
||||||
key->set_id(mKeyId);
|
key->set_id(key_id_);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case License::KeyContainer::CONTENT: {
|
case License::KeyContainer::CONTENT: {
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
key->set_id(mKeyId);
|
key->set_id(key_id_);
|
||||||
}
|
}
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
int32_t level = mFdp.ConsumeIntegralInRange<uint8_t>(
|
int32_t level = fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
License::KeyContainer::SW_SECURE_CRYPTO,
|
License::KeyContainer::SW_SECURE_CRYPTO,
|
||||||
License::KeyContainer::HW_SECURE_ALL);
|
License::KeyContainer::HW_SECURE_ALL);
|
||||||
key->set_level((License_KeyContainer_SecurityLevel)level);
|
key->set_level((License_KeyContainer_SecurityLevel)level);
|
||||||
}
|
}
|
||||||
|
License_Policy *policy = license_.mutable_policy();
|
||||||
License_Policy *policy = mLicense.mutable_policy();
|
PolicySetBool(
|
||||||
policySetBool(
|
|
||||||
std::bind(&License_Policy::set_can_play, policy, std::placeholders::_1),
|
std::bind(&License_Policy::set_can_play, policy, std::placeholders::_1),
|
||||||
&mFdp);
|
&fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_can_persist, policy,
|
PolicySetBool(std::bind(&License_Policy::set_can_persist, policy,
|
||||||
std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_can_renew, policy,
|
PolicySetBool(std::bind(&License_Policy::set_can_renew, policy,
|
||||||
std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_renew_with_usage, policy,
|
PolicySetBool(std::bind(&License_Policy::set_renew_with_usage, policy,
|
||||||
std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_soft_enforce_rental_duration,
|
PolicySetBool(std::bind(&License_Policy::set_soft_enforce_rental_duration,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_soft_enforce_playback_duration,
|
PolicySetBool(std::bind(&License_Policy::set_soft_enforce_playback_duration,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
|
|
||||||
policySetInt64(std::bind(&License_Policy::set_rental_duration_seconds,
|
PolicySetInt64(std::bind(&License_Policy::set_rental_duration_seconds,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetInt64(std::bind(&License_Policy::set_playback_duration_seconds,
|
PolicySetInt64(std::bind(&License_Policy::set_playback_duration_seconds,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetInt64(std::bind(&License_Policy::set_license_duration_seconds,
|
PolicySetInt64(std::bind(&License_Policy::set_license_duration_seconds,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetInt64(
|
PolicySetInt64(std::bind(&License_Policy::set_renewal_recovery_duration_seconds,
|
||||||
std::bind(&License_Policy::set_renewal_recovery_duration_seconds,
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policy, std::placeholders::_1), &mFdp);
|
PolicySetInt64(std::bind(&License_Policy::set_renewal_retry_interval_seconds, policy,
|
||||||
policySetInt64(
|
std::placeholders::_1), &fdp_);
|
||||||
std::bind(&License_Policy::set_renewal_retry_interval_seconds, policy,
|
PolicySetInt64(std::bind(&License_Policy::set_renewal_delay_seconds, policy,
|
||||||
std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetInt64(
|
|
||||||
std::bind(&License_Policy::set_renewal_delay_seconds, policy,
|
|
||||||
std::placeholders::_1), &mFdp);
|
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
video_widevine::License::Policy::TimerDelayBase timeDelayBase =
|
video_widevine::License::Policy::TimerDelayBase time_delay_base =
|
||||||
(video_widevine::License::Policy::TimerDelayBase)mFdp.ConsumeIntegralInRange<uint8_t>(
|
(video_widevine::License::Policy::TimerDelayBase)
|
||||||
License_Policy_TimerDelayBase_TIMER_DELAY_BASE_UNSPECIFIED ,
|
fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
License_Policy_TimerDelayBase_FIRST_DECRYPT);
|
License_Policy_TimerDelayBase_TIMER_DELAY_BASE_UNSPECIFIED,
|
||||||
policy->set_initial_renewal_delay_base(timeDelayBase);
|
License_Policy_TimerDelayBase_FIRST_DECRYPT);
|
||||||
}
|
policy->set_initial_renewal_delay_base(time_delay_base);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
std::string serverUrl = mFdp.ConsumeBool()
|
std::string serverUrl = fdp_.ConsumeBool()
|
||||||
? kRenewalServerUrl
|
? kRenewalServerUrl
|
||||||
: mFdp.ConsumeRandomLengthString(kMaxByte);
|
: fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||||
policy->set_renewal_server_url(serverUrl);
|
policy->set_renewal_server_url(serverUrl);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case License::KeyContainer::KEY_CONTROL: {
|
case License::KeyContainer::KEY_CONTROL: {
|
||||||
key->set_type(License::KeyContainer::KEY_CONTROL);
|
key->set_type(License::KeyContainer::KEY_CONTROL);
|
||||||
// No control bits for this type of key container used for license
|
// No control bits for this type of key container used for license
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case License::KeyContainer::OPERATOR_SESSION: {
|
case License::KeyContainer::OPERATOR_SESSION: {
|
||||||
key->set_type(License::KeyContainer::OPERATOR_SESSION);
|
key->set_type(License::KeyContainer::OPERATOR_SESSION);
|
||||||
|
if (fdp_.ConsumeBool()) {
|
||||||
|
key->set_id(key_id_);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
key->set_id(mKeyId);
|
int32_t level = fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
}
|
License::KeyContainer::SW_SECURE_CRYPTO,
|
||||||
|
License::KeyContainer::HW_SECURE_ALL);
|
||||||
|
key->set_level((License_KeyContainer_SecurityLevel)level);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
int32_t level = mFdp.ConsumeIntegralInRange<uint8_t>(
|
PolicySetBool(std::bind(&License_Policy::set_can_persist,license_.mutable_policy(),
|
||||||
License::KeyContainer::SW_SECURE_CRYPTO,
|
std::placeholders::_1),&fdp_);
|
||||||
License::KeyContainer::HW_SECURE_ALL);
|
}
|
||||||
key->set_level((License_KeyContainer_SecurityLevel)level);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
License::KeyContainer::OperatorSessionKeyPermissions *permissions =
|
||||||
policySetBool(std::bind(&License_Policy::set_can_persist, mLicense.mutable_policy(),
|
key->mutable_operator_session_key_permissions();
|
||||||
std::placeholders::_1), &mFdp);
|
PolicySetBool(
|
||||||
}
|
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
||||||
|
set_allow_encrypt,
|
||||||
|
permissions, std::placeholders::_1), &fdp_);
|
||||||
|
PolicySetBool(
|
||||||
|
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
||||||
|
set_allow_decrypt,
|
||||||
|
permissions, std::placeholders::_1), &fdp_);
|
||||||
|
PolicySetBool(std::bind(&License::KeyContainer::
|
||||||
|
OperatorSessionKeyPermissions::set_allow_sign,
|
||||||
|
permissions, std::placeholders::_1), &fdp_);
|
||||||
|
PolicySetBool(
|
||||||
|
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
||||||
|
set_allow_signature_verify,
|
||||||
|
permissions, std::placeholders::_1), &fdp_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case License::KeyContainer::ENTITLEMENT:
|
||||||
|
default: {
|
||||||
|
if (fdp_.ConsumeBool()) {
|
||||||
|
key_id_ = fdp_.ConsumeBool() ? kEntitlementKeyId : key_id_;
|
||||||
|
key->set_id(key_id_);
|
||||||
|
}
|
||||||
|
if (fdp_.ConsumeBool()) {
|
||||||
|
int32_t level = fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
|
License::KeyContainer::SW_SECURE_CRYPTO,
|
||||||
|
License::KeyContainer::HW_SECURE_ALL);
|
||||||
|
key->set_level((License_KeyContainer_SecurityLevel)level);
|
||||||
|
}
|
||||||
|
|
||||||
License::KeyContainer::OperatorSessionKeyPermissions *permissions =
|
License_Policy *policy = license_.mutable_policy();
|
||||||
key->mutable_operator_session_key_permissions();
|
PolicySetBool(
|
||||||
policySetBool(
|
std::bind(&License_Policy::set_can_play, policy, std::placeholders::_1),
|
||||||
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
&fdp_);
|
||||||
set_allow_encrypt,
|
PolicySetBool(std::bind(&License_Policy::set_can_persist, policy,
|
||||||
permissions, std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(
|
PolicySetBool(std::bind(&License_Policy::set_can_renew, policy,
|
||||||
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
std::placeholders::_1), &fdp_);
|
||||||
set_allow_decrypt,
|
PolicySetBool(std::bind(&License_Policy::set_renew_with_usage, policy,
|
||||||
permissions, std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License::KeyContainer::
|
PolicySetBool(std::bind(&License_Policy::set_soft_enforce_rental_duration,
|
||||||
OperatorSessionKeyPermissions::set_allow_sign,
|
policy, std::placeholders::_1), &fdp_);
|
||||||
permissions, std::placeholders::_1), &mFdp);
|
PolicySetBool(std::bind(&License_Policy::set_soft_enforce_playback_duration,
|
||||||
policySetBool(
|
policy, std::placeholders::_1), &fdp_);
|
||||||
std::bind(&License::KeyContainer::OperatorSessionKeyPermissions::
|
|
||||||
set_allow_signature_verify,
|
|
||||||
permissions, std::placeholders::_1), &mFdp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case License::KeyContainer::ENTITLEMENT:
|
|
||||||
default: {
|
|
||||||
if (mFdp.ConsumeBool()) {
|
|
||||||
mKeyId = mFdp.ConsumeBool() ? kEntitlementKeyId : mKeyId;
|
|
||||||
key->set_id(mKeyId);
|
|
||||||
}
|
|
||||||
if (mFdp.ConsumeBool()) {
|
|
||||||
int32_t level = mFdp.ConsumeIntegralInRange<uint8_t>(
|
|
||||||
License::KeyContainer::SW_SECURE_CRYPTO,
|
|
||||||
License::KeyContainer::HW_SECURE_ALL);
|
|
||||||
key->set_level((License_KeyContainer_SecurityLevel)level);
|
|
||||||
}
|
|
||||||
|
|
||||||
License_Policy *policy = mLicense.mutable_policy();
|
PolicySetInt64(std::bind(&License_Policy::set_rental_duration_seconds,
|
||||||
policySetBool(
|
policy, std::placeholders::_1), &fdp_);
|
||||||
std::bind(&License_Policy::set_can_play, policy, std::placeholders::_1),
|
PolicySetInt64(std::bind(&License_Policy::set_playback_duration_seconds,
|
||||||
&mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_can_persist, policy,
|
PolicySetInt64(std::bind(&License_Policy::set_license_duration_seconds,
|
||||||
std::placeholders::_1), &mFdp);
|
policy, std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_can_renew, policy,
|
PolicySetInt64(
|
||||||
std::placeholders::_1), &mFdp);
|
std::bind(&License_Policy::set_renewal_recovery_duration_seconds,
|
||||||
policySetBool(std::bind(&License_Policy::set_renew_with_usage, policy,
|
policy, std::placeholders::_1), &fdp_);
|
||||||
std::placeholders::_1), &mFdp);
|
PolicySetInt64(
|
||||||
policySetBool(std::bind(&License_Policy::set_soft_enforce_rental_duration,
|
std::bind(&License_Policy::set_renewal_retry_interval_seconds, policy,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
std::placeholders::_1), &fdp_);
|
||||||
policySetBool(std::bind(&License_Policy::set_soft_enforce_playback_duration,
|
PolicySetInt64(
|
||||||
policy, std::placeholders::_1), &mFdp);
|
std::bind(&License_Policy::set_renewal_delay_seconds, policy,
|
||||||
|
std::placeholders::_1), &fdp_);
|
||||||
|
|
||||||
policySetInt64(std::bind(&License_Policy::set_rental_duration_seconds,
|
if (fdp_.ConsumeBool()) {
|
||||||
policy, std::placeholders::_1), &mFdp);
|
video_widevine::License::Policy::TimerDelayBase time_delay_base =
|
||||||
policySetInt64(std::bind(&License_Policy::set_playback_duration_seconds,
|
(video_widevine::License::Policy::TimerDelayBase)
|
||||||
policy, std::placeholders::_1), &mFdp);
|
fdp_.ConsumeIntegralInRange<uint8_t>(
|
||||||
policySetInt64(std::bind(&License_Policy::set_license_duration_seconds,
|
License_Policy_TimerDelayBase_TIMER_DELAY_BASE_UNSPECIFIED,
|
||||||
policy, std::placeholders::_1), &mFdp);
|
License_Policy_TimerDelayBase_FIRST_DECRYPT);
|
||||||
policySetInt64(
|
policy->set_initial_renewal_delay_base(time_delay_base);
|
||||||
std::bind(&License_Policy::set_renewal_recovery_duration_seconds,
|
}
|
||||||
policy, std::placeholders::_1), &mFdp);
|
break;
|
||||||
policySetInt64(
|
}
|
||||||
std::bind(&License_Policy::set_renewal_retry_interval_seconds, policy,
|
|
||||||
std::placeholders::_1), &mFdp);
|
|
||||||
policySetInt64(
|
|
||||||
std::bind(&License_Policy::set_renewal_delay_seconds, policy,
|
|
||||||
std::placeholders::_1), &mFdp);
|
|
||||||
|
|
||||||
if (mFdp.ConsumeBool()) {
|
|
||||||
video_widevine::License::Policy::TimerDelayBase timeDelayBase = (video_widevine::License::Policy::TimerDelayBase)mFdp.ConsumeIntegralInRange<uint8_t>(
|
|
||||||
License_Policy_TimerDelayBase_TIMER_DELAY_BASE_UNSPECIFIED ,
|
|
||||||
License_Policy_TimerDelayBase_FIRST_DECRYPT);
|
|
||||||
policy->set_initial_renewal_delay_base(timeDelayBase);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolicyEngineFuzzer::process() {
|
void PolicyEngineFuzzer::Process() {
|
||||||
setUp();
|
SetUp();
|
||||||
FuzzWvCdmEventListener fuzzWvCdmEventListener;
|
FuzzWvCdmEventListener fuzz_wv_cdm_event_listener;
|
||||||
CdmSessionId sessionId = mFdp.ConsumeRandomLengthString(kMaxByte);
|
CdmSessionId session_id = fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||||
metrics::CryptoMetrics crypto_metrics;
|
metrics::CryptoMetrics crypto_metrics;
|
||||||
std::unique_ptr<CryptoSession> cryptoSession(
|
std::unique_ptr<CryptoSession> cryptoSession(
|
||||||
wvcdm::CryptoSession::MakeCryptoSession(&crypto_metrics));
|
wvcdm::CryptoSession::MakeCryptoSession(&crypto_metrics));
|
||||||
std::unique_ptr<PolicyEngine> policyEngine(new PolicyEngine(
|
std::unique_ptr<PolicyEngine> policy_engine(new PolicyEngine(
|
||||||
sessionId, &fuzzWvCdmEventListener, cryptoSession.get()));
|
session_id, &fuzz_wv_cdm_event_listener, cryptoSession.get()));
|
||||||
|
|
||||||
while (mFdp.remaining_bytes()) {
|
while (fdp_.remaining_bytes()) {
|
||||||
auto invokePolicyEngineAPI =
|
auto invokePolicyEngineAPI =
|
||||||
mFdp.PickValueInArray<const std::function<void()>>({
|
fdp_.PickValueInArray<const std::function<void()>>({
|
||||||
[&]() { policyEngine->CanDecryptContent(mKeyId); },
|
[&]() { policy_engine->CanDecryptContent(key_id_); },
|
||||||
[&]() { policyEngine->CanUseKeyForSecurityLevel(mKeyId); },
|
[&]() { policy_engine->CanUseKeyForSecurityLevel(key_id_); },
|
||||||
[&]() { policyEngine->OnTimerEvent(); },
|
[&]() { policy_engine->OnTimerEvent(); },
|
||||||
[&]() {
|
[&]() {
|
||||||
policyEngine->SetLicense(
|
policy_engine->SetLicense(
|
||||||
mLicense, mFdp.ConsumeBool() /*defer_license_state_update*/);
|
license_, fdp_.ConsumeBool() /*defer_license_state_update**/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
int32_t maxEntitledKey =
|
int32_t max_entitled_key=
|
||||||
mFdp.ConsumeIntegralInRange<uint8_t>(1, kMaxEntitledKey);
|
fdp_.ConsumeIntegralInRange<uint8_t>(1, kMaxEntitledKey);
|
||||||
std::vector<WidevinePsshData_EntitledKey> entitled_keys(
|
std::vector<WidevinePsshData_EntitledKey> entitled_keys(
|
||||||
maxEntitledKey);
|
max_entitled_key);
|
||||||
for (int i = 0; i < maxEntitledKey; ++i) {
|
for (int i = 0; i < max_entitled_key; ++i) {
|
||||||
entitled_keys[i].set_entitlement_key_id(
|
entitled_keys[i].set_entitlement_key_id(
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte));
|
fdp_.ConsumeRandomLengthString(kMaxByte));
|
||||||
entitled_keys[i].set_key_id(
|
entitled_keys[i].set_key_id(
|
||||||
mFdp.ConsumeBool()
|
fdp_.ConsumeBool()
|
||||||
? mFdp.ConsumeRandomLengthString(kMaxByte)
|
? fdp_.ConsumeRandomLengthString(kMaxByte)
|
||||||
: mKeyId);
|
: key_id_);
|
||||||
}
|
}
|
||||||
policyEngine->SetEntitledLicenseKeys(entitled_keys);
|
policy_engine->SetEntitledLicenseKeys(entitled_keys);
|
||||||
},
|
},
|
||||||
[&]() { policyEngine->SetLicenseForRelease(mLicense); },
|
[&]() { policy_engine->SetLicenseForRelease(license_); },
|
||||||
[&]() { policyEngine->BeginDecryption(); },
|
[&]() { policy_engine->BeginDecryption(); },
|
||||||
[&]() { policyEngine->DecryptionEvent(); },
|
[&]() { policy_engine->DecryptionEvent(); },
|
||||||
[&]() {
|
[&]() {
|
||||||
policyEngine->UpdateLicense(
|
policy_engine->UpdateLicense(
|
||||||
mLicense, mFdp.ConsumeBool() /*defer_license_state_update*/);
|
license_, fdp_.ConsumeBool() /*defer_license_state_update*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
policyEngine->UpdateLicenseState(
|
policy_engine->UpdateLicenseState(
|
||||||
mFdp.ConsumeIntegral<int64_t>() /*current_time*/);
|
fdp_.ConsumeIntegral<int64_t>() /*current_time*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
int32_t width = mFdp.ConsumeIntegralInRange<int32_t>(
|
int32_t width = fdp_.ConsumeIntegralInRange<int32_t>(
|
||||||
kMinResolution, kMaxResolution);
|
kMinResolution, kMaxResolution);
|
||||||
int32_t height = mFdp.ConsumeIntegralInRange<int32_t>(
|
int32_t height = fdp_.ConsumeIntegralInRange<int32_t>(
|
||||||
kMinResolution, kMaxResolution);
|
kMinResolution, kMaxResolution);
|
||||||
policyEngine->NotifyResolution(width, height);
|
policy_engine->NotifyResolution(width, height);
|
||||||
},
|
},
|
||||||
[&]() { policyEngine->NotifySessionExpiration(); },
|
[&]() { policy_engine->NotifySessionExpiration(); },
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmQueryMap query_info;
|
CdmQueryMap query_info;
|
||||||
policyEngine->Query(&query_info);
|
policy_engine->Query(&query_info);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmKeyAllowedUsage key_usage;
|
CdmKeyAllowedUsage key_usage;
|
||||||
policyEngine->QueryKeyAllowedUsage(
|
policy_engine->QueryKeyAllowedUsage(
|
||||||
mKeyId, (mFdp.ConsumeBool() ? nullptr : &key_usage));
|
key_id_, (fdp_.ConsumeBool() ? nullptr : &key_usage));
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
policyEngine->RestorePlaybackTimes(
|
policy_engine->RestorePlaybackTimes(
|
||||||
mFdp.ConsumeIntegral<int64_t>() /*playback_start_time*/,
|
fdp_.ConsumeIntegral<int64_t>() /*playback_start_time*/,
|
||||||
mFdp.ConsumeIntegral<int64_t>() /*last_playback_time*/,
|
fdp_.ConsumeIntegral<int64_t>() /*last_playback_time*/,
|
||||||
mFdp.ConsumeIntegral<int64_t>() /*grace_period_end_time*/);
|
fdp_.ConsumeIntegral<int64_t>() /*grace_period_end_time*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
policyEngine->HasLicenseOrRentalOrPlaybackDurationExpired(
|
policy_engine->HasLicenseOrRentalOrPlaybackDurationExpired(
|
||||||
mFdp.ConsumeIntegral<int64_t>());
|
fdp_.ConsumeIntegral<int64_t>());
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
invokePolicyEngineAPI();
|
invokePolicyEngineAPI();
|
||||||
@@ -347,7 +345,7 @@ void PolicyEngineFuzzer::process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
PolicyEngineFuzzer policyEngineFuzzer(data, size);
|
PolicyEngineFuzzer policy_engine_fuzzer(data, size);
|
||||||
policyEngineFuzzer.process();
|
policy_engine_fuzzer.Process();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user