Pick widevine oemcrypto-v18 change
No-Typo-Check: From a third party header file Bug: 260918793 Test: unit tests Test: atp v2/widevine-eng/drm_compliance Change-Id: I36effd6a10a99bdb2399ab1f4a0fad026d607c70
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
#include "OEMCryptoCENCCommon.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "odk.h"
|
||||
#include "odk_structs.h"
|
||||
#include "odk_structs_priv.h"
|
||||
#include "odk_test_helper.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -23,6 +25,99 @@ constexpr uint64_t kRentalClockStart = 1000u;
|
||||
// renewal is not loaded.
|
||||
constexpr uint64_t kGracePeriod = 5u;
|
||||
|
||||
constexpr uint32_t kExtraPayloadSize = 128u;
|
||||
|
||||
constexpr uint32_t kSystemTime = 20u;
|
||||
|
||||
namespace wvodk_test {
|
||||
|
||||
TEST(OdkTimerBasicTest, ParseLicenseTimerSet) {
|
||||
// playback timer is successfully started
|
||||
::wvodk_test::ODK_LicenseResponseParams params;
|
||||
ODK_SetDefaultLicenseResponseParams(¶ms, ODK_MAJOR_VERSION);
|
||||
params.parsed_license.renewal_delay_base = OEMCrypto_License_Load;
|
||||
params.parsed_license.timer_limits.soft_enforce_rental_duration = false;
|
||||
params.parsed_license.timer_limits.soft_enforce_playback_duration = false;
|
||||
params.parsed_license.timer_limits.earliest_playback_start_seconds = 10;
|
||||
params.parsed_license.timer_limits.total_playback_duration_seconds = 0;
|
||||
params.parsed_license.timer_limits.rental_duration_seconds = 10;
|
||||
params.parsed_license.timer_limits.initial_renewal_duration_seconds = 0;
|
||||
OEMCryptoResult result =
|
||||
ODK_InitializeClockValues(¶ms.clock_values, kSystemTime);
|
||||
EXPECT_EQ(OEMCrypto_SUCCESS, result);
|
||||
params.clock_values.time_of_license_request_signed = 5;
|
||||
params.clock_values.status = kActive;
|
||||
|
||||
uint8_t* buf = nullptr;
|
||||
uint32_t buf_size = 0;
|
||||
ODK_BuildMessageBuffer(&(params.core_message), params.extra_fields, &buf,
|
||||
&buf_size);
|
||||
|
||||
result = ODK_ParseLicense(
|
||||
buf, buf_size + kExtraPayloadSize, buf_size, params.initial_license_load,
|
||||
params.usage_entry_present, kSystemTime, &(params.timer_limits),
|
||||
&(params.clock_values), &(params.core_message.nonce_values),
|
||||
&(params.parsed_license), nullptr);
|
||||
EXPECT_EQ(ODK_SET_TIMER, result);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
TEST(OdkTimerBasicTest, ParseLicenseTimerDisabled) {
|
||||
// playback timer is successfully started
|
||||
::wvodk_test::ODK_LicenseResponseParams params;
|
||||
ODK_SetDefaultLicenseResponseParams(¶ms, ODK_MAJOR_VERSION);
|
||||
params.parsed_license.renewal_delay_base = OEMCrypto_License_Load;
|
||||
params.parsed_license.timer_limits.soft_enforce_rental_duration = true;
|
||||
params.parsed_license.timer_limits.earliest_playback_start_seconds = 3;
|
||||
params.parsed_license.timer_limits.total_playback_duration_seconds = 0;
|
||||
params.parsed_license.timer_limits.initial_renewal_duration_seconds = 0;
|
||||
params.clock_values.time_of_first_decrypt = 10;
|
||||
params.clock_values.time_of_license_request_signed = 5;
|
||||
params.clock_values.status = kActive;
|
||||
|
||||
uint8_t* buf = nullptr;
|
||||
uint32_t buf_size = 0;
|
||||
ODK_BuildMessageBuffer(&(params.core_message), params.extra_fields, &buf,
|
||||
&buf_size);
|
||||
|
||||
OEMCryptoResult result = ODK_ParseLicense(
|
||||
buf, buf_size + kExtraPayloadSize, buf_size, params.initial_license_load,
|
||||
params.usage_entry_present, kSystemTime, &(params.timer_limits),
|
||||
&(params.clock_values), &(params.core_message.nonce_values),
|
||||
&(params.parsed_license), nullptr);
|
||||
EXPECT_EQ(ODK_DISABLE_TIMER, result);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
TEST(OdkTimerBasicTest, ParseRenewalTimerExpired) {
|
||||
// playback timer is successfully started
|
||||
::wvodk_test::ODK_LicenseResponseParams params;
|
||||
ODK_SetDefaultLicenseResponseParams(¶ms, ODK_MAJOR_VERSION);
|
||||
|
||||
params.parsed_license.renewal_delay_base = OEMCrypto_License_Load;
|
||||
params.parsed_license.timer_limits.rental_duration_seconds = 5;
|
||||
params.parsed_license.timer_limits.earliest_playback_start_seconds = 3;
|
||||
OEMCryptoResult result =
|
||||
ODK_InitializeClockValues(¶ms.clock_values, kSystemTime);
|
||||
EXPECT_EQ(OEMCrypto_SUCCESS, result);
|
||||
params.clock_values.time_of_license_request_signed = 5;
|
||||
|
||||
uint8_t* buf = nullptr;
|
||||
uint32_t buf_size = 0;
|
||||
ODK_BuildMessageBuffer(&(params.core_message), params.extra_fields, &buf,
|
||||
&buf_size);
|
||||
|
||||
result = ODK_ParseLicense(
|
||||
buf, buf_size + kExtraPayloadSize, buf_size, params.initial_license_load,
|
||||
params.usage_entry_present, kSystemTime, &(params.timer_limits),
|
||||
&(params.clock_values), &(params.core_message.nonce_values),
|
||||
&(params.parsed_license), nullptr);
|
||||
EXPECT_EQ(ODK_TIMER_EXPIRED, result);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
} // namespace wvodk_test
|
||||
|
||||
TEST(OdkTimerBasicTest, NullTest) {
|
||||
// Assert that nullptr does not cause a core dump.
|
||||
ODK_InitializeClockValues(nullptr, 0u);
|
||||
|
||||
Reference in New Issue
Block a user