Source release 16.2.0

This commit is contained in:
John W. Bruce
2020-04-10 16:13:07 -07:00
parent 1ff9f8588a
commit b830b1d1fb
883 changed files with 509706 additions and 143739 deletions

View File

@@ -64,20 +64,15 @@ static const KeyId ck_NO_HDCP_dual_res = "ck_NO_HDCP_dual_res";
// protobuf generated classes.
using video_widevine::License;
using video_widevine::LicenseIdentification;
using video_widevine::STREAMING;
using video_widevine::OFFLINE;
using video_widevine::STREAMING;
using KeyContainer = ::video_widevine::License::KeyContainer;
using VideoResolutionConstraint = KeyContainer::VideoResolutionConstraint;
class LicenseKeysTest : public ::testing::Test {
protected:
enum KeyFlag {
kKeyFlagNull,
kKeyFlagFalse,
kKeyFlagTrue
};
enum KeyFlag { kKeyFlagNull, kKeyFlagFalse, kKeyFlagTrue };
static const KeyFlag kEncryptNull = kKeyFlagNull;
static const KeyFlag kEncryptFalse = kKeyFlagFalse;
@@ -107,10 +102,11 @@ class LicenseKeysTest : public ::testing::Test {
virtual void AddContentKey(
const KeyId& key_id, bool set_level = false,
KeyContainer::SecurityLevel level = KeyContainer::SW_SECURE_CRYPTO,
bool set_hdcp = false, KeyContainer::OutputProtection::HDCP hdcp_value =
bool set_hdcp = false,
KeyContainer::OutputProtection::HDCP hdcp_value =
KeyContainer::OutputProtection::HDCP_NONE,
bool set_constraints = false,
std::vector<VideoResolutionConstraint>* constraints = NULL) {
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
KeyContainer* key = license_.add_key();
key->set_type(KeyContainer::CONTENT);
if (set_level) {
@@ -121,14 +117,15 @@ class LicenseKeysTest : public ::testing::Test {
pro->set_hdcp(hdcp_value);
}
if (set_constraints) {
for (std::vector<VideoResolutionConstraint>::iterator
it = constraints->begin(); it != constraints->end(); ++it) {
for (std::vector<VideoResolutionConstraint>::iterator it =
constraints->begin();
it != constraints->end(); ++it) {
VideoResolutionConstraint* constraint =
key->add_video_resolution_constraints();
constraint->set_min_resolution_pixels(it->min_resolution_pixels());
constraint->set_max_resolution_pixels(it->max_resolution_pixels());
constraint->mutable_required_protection()->
set_hdcp(it->required_protection().hdcp());
constraint->mutable_required_protection()->set_hdcp(
it->required_protection().hdcp());
}
}
key->set_id(key_id);
@@ -141,17 +138,19 @@ class LicenseKeysTest : public ::testing::Test {
KeyContainer::OutputProtection::HDCP hdcp_value =
KeyContainer::OutputProtection::HDCP_NONE,
bool set_constraints = false,
std::vector<VideoResolutionConstraint>* constraints = NULL) {
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
AddContentKey(key_id, set_level, level, set_hdcp, hdcp_value,
set_constraints, constraints);
license_.mutable_key(license_.key_size() - 1)
->set_type(KeyContainer::ENTITLEMENT);
}
virtual void AddOperatorSessionKey(
const KeyId& key_id, bool set_perms = false,
KeyFlag encrypt = kKeyFlagNull, KeyFlag decrypt = kKeyFlagNull,
KeyFlag sign = kKeyFlagNull, KeyFlag verify = kKeyFlagNull) {
virtual void AddOperatorSessionKey(const KeyId& key_id,
bool set_perms = false,
KeyFlag encrypt = kKeyFlagNull,
KeyFlag decrypt = kKeyFlagNull,
KeyFlag sign = kKeyFlagNull,
KeyFlag verify = kKeyFlagNull) {
KeyContainer* non_content_key = license_.add_key();
non_content_key->set_type(KeyContainer::OPERATOR_SESSION);
non_content_key->set_id(key_id);
@@ -191,9 +190,9 @@ class LicenseKeysTest : public ::testing::Test {
EXPECT_FALSE(key_usage.generic_verify);
}
virtual void ExpectAllowedUsageOperator(
const CdmKeyAllowedUsage& key_usage, KeyFlag encrypt, KeyFlag decrypt,
KeyFlag sign, KeyFlag verify) {
virtual void ExpectAllowedUsageOperator(const CdmKeyAllowedUsage& key_usage,
KeyFlag encrypt, KeyFlag decrypt,
KeyFlag sign, KeyFlag verify) {
EXPECT_FALSE(key_usage.decrypt_to_secure_buffer);
EXPECT_FALSE(key_usage.decrypt_to_clear_buffer);
EXPECT_EQ(key_usage.generic_encrypt, encrypt == kKeyFlagTrue);
@@ -202,9 +201,7 @@ class LicenseKeysTest : public ::testing::Test {
EXPECT_EQ(key_usage.generic_verify, verify == kKeyFlagTrue);
}
virtual int NumContentKeys() {
return content_key_count_;
}
virtual int NumContentKeys() { return content_key_count_; }
virtual void StageContentKeys() {
content_key_count_ = 0;
@@ -222,20 +219,20 @@ class LicenseKeysTest : public ::testing::Test {
}
virtual void StageOperatorSessionKeys() {
AddOperatorSessionKey(osk_decrypt, true,
kEncryptNull, kDecryptTrue, kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_encrypt, true,
kEncryptTrue, kDecryptNull, kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_sign, true,
kEncryptNull, kDecryptNull, kSignTrue, kVerifyNull);
AddOperatorSessionKey(osk_verify, true,
kEncryptNull, kDecryptNull, kSignNull, kVerifyTrue);
AddOperatorSessionKey(osk_encrypt_decrypt, true,
kEncryptTrue, kDecryptTrue, kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_sign_verify, true,
kEncryptNull, kDecryptNull, kSignTrue, kVerifyTrue);
AddOperatorSessionKey(osk_all, true,
kEncryptTrue, kDecryptTrue, kSignTrue, kVerifyTrue);
AddOperatorSessionKey(osk_decrypt, true, kEncryptNull, kDecryptTrue,
kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_encrypt, true, kEncryptTrue, kDecryptNull,
kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_sign, true, kEncryptNull, kDecryptNull, kSignTrue,
kVerifyNull);
AddOperatorSessionKey(osk_verify, true, kEncryptNull, kDecryptNull,
kSignNull, kVerifyTrue);
AddOperatorSessionKey(osk_encrypt_decrypt, true, kEncryptTrue, kDecryptTrue,
kSignNull, kVerifyNull);
AddOperatorSessionKey(osk_sign_verify, true, kEncryptNull, kDecryptNull,
kSignTrue, kVerifyTrue);
AddOperatorSessionKey(osk_all, true, kEncryptTrue, kDecryptTrue, kSignTrue,
kVerifyTrue);
license_keys_->SetFromLicense(license_);
}
@@ -309,10 +306,10 @@ class LicenseKeysTest : public ::testing::Test {
constraints.clear();
AddConstraint(constraints, key_hi_res_min, key_hi_res_max);
AddContentKey(
ck_HDCP_NO_OUTPUT_hi_res, true, KeyContainer::SW_SECURE_CRYPTO, true,
KeyContainer::OutputProtection::HDCP_NO_DIGITAL_OUTPUT, true,
&constraints);
AddContentKey(ck_HDCP_NO_OUTPUT_hi_res, true,
KeyContainer::SW_SECURE_CRYPTO, true,
KeyContainer::OutputProtection::HDCP_NO_DIGITAL_OUTPUT, true,
&constraints);
content_key_count_++;
constraints.clear();
@@ -371,15 +368,12 @@ class LicenseKeysTest : public ::testing::Test {
}
}
size_t content_key_count_;
std::unique_ptr<LicenseKeys> license_keys_;
License license_;
};
TEST_F(LicenseKeysTest, Empty) {
EXPECT_TRUE(license_keys_->Empty());
}
TEST_F(LicenseKeysTest, Empty) { EXPECT_TRUE(license_keys_->Empty()); }
TEST_F(LicenseKeysTest, NotEmpty) {
const KeyId c_key = "content_key";
@@ -473,15 +467,15 @@ TEST_F(LicenseKeysTest, CanDecrypt) {
EXPECT_FALSE(license_keys_->CanDecryptContent(e_key));
bool new_usable_keys = false;
bool any_change = false;
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
EXPECT_TRUE(license_keys_->CanDecryptContent(c_key));
EXPECT_FALSE(license_keys_->CanDecryptContent(os_key));
any_change = license_keys_->ApplyStatusChange(kKeyStatusExpired,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusExpired, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(c_key));
@@ -537,13 +531,13 @@ TEST_F(LicenseKeysTest, AllowedUsageContent) {
CdmKeyAllowedUsage u_hw_decode;
EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_hw_decode, &u_hw_decode));
ExpectAllowedUsageContent(u_hw_decode, kContentSecureTrue,
kContentClearFalse, kHardwareSecureDecode);
ExpectAllowedUsageContent(u_hw_decode, kContentSecureTrue, kContentClearFalse,
kHardwareSecureDecode);
CdmKeyAllowedUsage u_hw_secure;
EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_hw_secure, &u_hw_secure));
ExpectAllowedUsageContent(u_hw_secure, kContentSecureTrue,
kContentClearFalse, kHardwareSecureAll);
ExpectAllowedUsageContent(u_hw_secure, kContentSecureTrue, kContentClearFalse,
kHardwareSecureAll);
}
TEST_F(LicenseKeysTest, AllowedUsageOperatorSession) {
@@ -569,8 +563,8 @@ TEST_F(LicenseKeysTest, AllowedUsageOperatorSession) {
kVerifyTrue);
CdmKeyAllowedUsage u_encrypt_decrypt;
EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_encrypt_decrypt,
&u_encrypt_decrypt));
EXPECT_TRUE(
license_keys_->GetAllowedUsage(osk_encrypt_decrypt, &u_encrypt_decrypt));
ExpectAllowedUsageOperator(u_encrypt_decrypt, kEncryptTrue, kDecryptTrue,
kSignFalse, kVerifyFalse);
@@ -608,8 +602,8 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusInternalError);
// change to pending
any_change = license_keys_->ApplyStatusChange(kKeyStatusPending,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusPending, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -621,7 +615,7 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) {
// change to usable in future
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsableInFuture,
&new_usable_keys);
&new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -632,8 +626,8 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsableInFuture);
// change to usable
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -644,8 +638,8 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsable);
// change to usable (again)
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_FALSE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -656,8 +650,8 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsable);
// change to expired
any_change = license_keys_->ApplyStatusChange(kKeyStatusExpired,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusExpired, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -674,8 +668,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
CdmKeyStatusMap key_status_map;
StageHdcpKeys();
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP));
@@ -701,8 +695,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT));
license_keys_->ApplyConstraints(100, HDCP_NONE);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
@@ -749,8 +743,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusOutputNotAllowed);
license_keys_->ApplyConstraints(100, HDCP_V1);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_FALSE(any_change);
EXPECT_FALSE(new_usable_keys);
@@ -797,8 +791,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusOutputNotAllowed);
license_keys_->ApplyConstraints(100, HDCP_V2_1);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -845,8 +839,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusOutputNotAllowed);
license_keys_->ApplyConstraints(100, HDCP_V2_2);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -893,8 +887,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusOutputNotAllowed);
license_keys_->ApplyConstraints(100, HDCP_V2_3);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -941,8 +935,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusOutputNotAllowed);
license_keys_->ApplyConstraints(100, HDCP_NO_DIGITAL_OUTPUT);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -981,8 +975,8 @@ TEST_F(LicenseKeysTest, HdcpChanges) {
kKeyStatusUsable);
license_keys_->ApplyConstraints(100, HDCP_NONE);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
@@ -1036,8 +1030,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
StageConstraintKeys();
// No constraints set by device
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res));
@@ -1056,8 +1050,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Low-res device, no HDCP support
license_keys_->ApplyConstraints(dev_lo_res, HDCP_NONE);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
@@ -1097,8 +1091,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Hi-res device, HDCP_V1 support
license_keys_->ApplyConstraints(dev_hi_res, HDCP_V1);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -1138,8 +1132,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Lo-res device, HDCP V2.2 support
license_keys_->ApplyConstraints(dev_lo_res, HDCP_V2_2);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -1177,8 +1171,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Hi-res device, Maximal HDCP support
license_keys_->ApplyConstraints(dev_hi_res, HDCP_NO_DIGITAL_OUTPUT);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -1216,8 +1210,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Lo-res device, no HDCP support
license_keys_->ApplyConstraints(dev_lo_res, HDCP_NONE);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_TRUE(new_usable_keys);
@@ -1238,10 +1232,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res));
license_keys_->ExtractKeyStatuses(&key_status_map);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_NO_HDCP,
kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_NO_HDCP,
kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_NO_HDCP, kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_NO_HDCP, kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_V2_1,
kKeyStatusOutputNotAllowed);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_HDCP_V2_1,
@@ -1261,8 +1253,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
// Too-high-res -- all keys rejected
license_keys_->ApplyConstraints(dev_top_res, HDCP_NONE);
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
@@ -1281,10 +1273,8 @@ TEST_F(LicenseKeysTest, ConstraintChanges) {
EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res));
license_keys_->ExtractKeyStatuses(&key_status_map);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_NO_HDCP,
kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_NO_HDCP,
kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_NO_HDCP, kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_NO_HDCP, kKeyStatusUsable);
ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_V2_1,
kKeyStatusOutputNotAllowed);
ExpectKeyStatusEqual(key_status_map, ck_hw_secure_HDCP_V2_1,
@@ -1314,11 +1304,11 @@ struct KeySecurityLevelParams {
};
KeySecurityLevelParams key_security_level_test_vectors[] = {
{ kSecurityLevelUninitialized, false, false, false, false, false, false},
{ kSecurityLevelL1, true, true, true, true, true, true},
{ kSecurityLevelL2, true, true, true, true, false, false},
{ kSecurityLevelL3, true, true, true, false, false, false},
{ kSecurityLevelUnknown, false, false, false, false, false, false},
{kSecurityLevelUninitialized, false, false, false, false, false, false},
{kSecurityLevelL1, true, true, true, true, true, true},
{kSecurityLevelL2, true, true, true, true, false, false},
{kSecurityLevelL3, true, true, true, false, false, false},
{kSecurityLevelUnknown, false, false, false, false, false, false},
};
class LicenseKeysSecurityLevelConstraintsTest
@@ -1339,8 +1329,8 @@ TEST_P(LicenseKeysSecurityLevelConstraintsTest, KeyStatusChange) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusInternalError);
// change to pending
any_change = license_keys_->ApplyStatusChange(kKeyStatusPending,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusPending, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto));
@@ -1369,8 +1359,8 @@ TEST_P(LicenseKeysSecurityLevelConstraintsTest, KeyStatusChange) {
ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsableInFuture);
// change to usable
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_EQ(config->expect_usable_keys, new_usable_keys);
EXPECT_EQ(config->expect_can_use_sw_crypto_key,
@@ -1387,25 +1377,25 @@ TEST_P(LicenseKeysSecurityLevelConstraintsTest, KeyStatusChange) {
license_keys_->ExtractKeyStatuses(&key_status_map);
EXPECT_EQ(content_key_count_, key_status_map.size());
EXPECT_EQ(config->expect_can_use_sw_crypto_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_sw_crypto_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_sw_crypto]);
EXPECT_EQ(config->expect_can_use_sw_decode_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_sw_decode_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_sw_decode]);
EXPECT_EQ(config->expect_can_use_hw_crypto_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_crypto_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_crypto]);
EXPECT_EQ(config->expect_can_use_hw_decode_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_decode_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_decode]);
EXPECT_EQ(config->expect_can_use_hw_secure_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_secure_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_secure]);
// change to usable (again)
any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys);
EXPECT_FALSE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_EQ(config->expect_can_use_sw_crypto_key,
@@ -1421,25 +1411,25 @@ TEST_P(LicenseKeysSecurityLevelConstraintsTest, KeyStatusChange) {
license_keys_->ExtractKeyStatuses(&key_status_map);
EXPECT_EQ(content_key_count_, key_status_map.size());
EXPECT_EQ(config->expect_can_use_sw_crypto_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_sw_crypto_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_sw_crypto]);
EXPECT_EQ(config->expect_can_use_sw_decode_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_sw_decode_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_sw_decode]);
EXPECT_EQ(config->expect_can_use_hw_crypto_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_crypto_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_crypto]);
EXPECT_EQ(config->expect_can_use_hw_decode_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_decode_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_decode]);
EXPECT_EQ(config->expect_can_use_hw_secure_key
? kKeyStatusUsable : kKeyStatusOutputNotAllowed,
EXPECT_EQ(config->expect_can_use_hw_secure_key ? kKeyStatusUsable
: kKeyStatusOutputNotAllowed,
key_status_map[ck_hw_secure]);
// change to expired
any_change = license_keys_->ApplyStatusChange(kKeyStatusExpired,
&new_usable_keys);
any_change =
license_keys_->ApplyStatusChange(kKeyStatusExpired, &new_usable_keys);
EXPECT_TRUE(any_change);
EXPECT_FALSE(new_usable_keys);
EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto));