From 7d7860954877cb34168dcd3cb2d32e0f6e322ff3 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Thu, 9 May 2019 13:49:47 -0700 Subject: [PATCH] Key Status should reflect key container security level [ Merge of http://go/wvgerrit/77506 ] Callers of MediaDrm can register to be notified when key status changes and if they are usable for decryption. A number of factors are evaluated when making this determination. Key container security level will now be included in the evaluation. Bug: 78652608 Test: WV unit/integration test, GtsMediaDrmTest, Play movies playback testing. Change-Id: I20243e5cb160f7957e3239e8d05f715ff0ee6dd6 --- .../cdm/core/include/license_key_status.h | 21 +- .../cdm/core/include/policy_engine.h | 9 +- libwvdrmengine/cdm/core/src/cdm_session.cpp | 3 +- .../cdm/core/src/license_key_status.cpp | 49 +- libwvdrmengine/cdm/core/src/policy_engine.cpp | 32 +- .../cdm/core/test/cdm_session_unittest.cpp | 5 +- .../cdm/core/test/license_keys_unittest.cpp | 881 ++++++++++-------- .../cdm/core/test/policy_engine_unittest.cpp | 33 +- 8 files changed, 621 insertions(+), 412 deletions(-) diff --git a/libwvdrmengine/cdm/core/include/license_key_status.h b/libwvdrmengine/cdm/core/include/license_key_status.h index a3a7ad8a..5eba0b60 100644 --- a/libwvdrmengine/cdm/core/include/license_key_status.h +++ b/libwvdrmengine/cdm/core/include/license_key_status.h @@ -21,7 +21,8 @@ using video_widevine::WidevinePsshData_EntitledKey; // Holds all content and operator session keys for a session. class LicenseKeys { public: - LicenseKeys() {} + LicenseKeys(CdmSecurityLevel security_level) + : security_level_(security_level) {} virtual ~LicenseKeys() { Clear(); } virtual bool Empty() { return key_statuses_.empty(); } @@ -54,6 +55,9 @@ class LicenseKeys { // to the key, returns true. virtual bool MeetsConstraints(const KeyId& key_id); + // Indicates whether specified key can be used for the sessions security level + virtual bool MeetsSecurityLevelConstraints(const KeyId& key_id); + // Applies a resolution and/or hdcp change to each key, updating their // useability under their constraints. virtual void ApplyConstraints(uint32_t new_resolution, @@ -67,6 +71,10 @@ class LicenseKeys { virtual void SetEntitledKeys( const std::vector& keys); + // For test use: Sets the OEMCrypto security level + virtual void SetSecurityLevelForTest( + CdmSecurityLevel security_level) { security_level_ = security_level; } + private: typedef ::video_widevine::License::KeyContainer KeyContainer; typedef std::map::const_iterator @@ -83,6 +91,8 @@ class LicenseKeys { // key status from |key_statuses_| when using entitlement key licensing. std::map content_keyid_to_entitlement_key_id_; + CdmSecurityLevel security_level_; + CORE_DISALLOW_COPY_AND_ASSIGN(LicenseKeys); }; @@ -114,6 +124,10 @@ class LicenseKeyStatus { // Note: this will return true until the first call to ApplyConstraints(). virtual bool MeetsConstraints() const { return meets_constraints_; } + // Indicates whether a key can be used for a given security level + virtual bool MeetsSecurityLevelConstraints() const { + return meets_security_level_constraints_; } + // Applies the given changes in resolution or HDCP settings. virtual void ApplyConstraints(uint32_t new_resolution, CryptoSession::HdcpCapability new_hdcp_level); @@ -127,12 +141,12 @@ class LicenseKeyStatus { typedef ::google::protobuf::RepeatedPtrField ConstraintList; - LicenseKeyStatus(const KeyContainer& key); + LicenseKeyStatus(const KeyContainer& key, const CdmSecurityLevel level); virtual ~LicenseKeyStatus() {} private: - void ParseContentKey(const KeyContainer& key); + void ParseContentKey(const KeyContainer& key, CdmSecurityLevel level); void ParseOperatorSessionKey(const KeyContainer& key); bool HasConstraints() { return is_content_key_ && constraints_.size() != 0; } @@ -142,6 +156,7 @@ class LicenseKeyStatus { bool is_content_key_; CdmKeyStatus key_status_; bool meets_constraints_; + bool meets_security_level_constraints_; CdmKeyAllowedUsage allowed_usage_; CryptoSession::HdcpCapability default_hdcp_level_; ConstraintList constraints_; diff --git a/libwvdrmengine/cdm/core/include/policy_engine.h b/libwvdrmengine/cdm/core/include/policy_engine.h index b40f42ad..d0a6759d 100644 --- a/libwvdrmengine/cdm/core/include/policy_engine.h +++ b/libwvdrmengine/cdm/core/include/policy_engine.h @@ -45,8 +45,7 @@ class PolicyEngine { // Verifies whether the policy allows use of the specified key of // a given security level for content decryption. - virtual bool CanUseKeyForSecurityLevel(const KeyId& key_id, - CdmSecurityLevel security_level); + virtual bool CanUseKeyForSecurityLevel(const KeyId& key_id); // OnTimerEvent is called when a timer fires. It notifies the Policy Engine // that the timer has fired and dispatches the relevant events through @@ -167,10 +166,12 @@ class PolicyEngine { // Guard against clock rollbacks int64_t GetCurrentTime(); - // set_clock() is for testing only. It alters ownership of the - // passed-in pointer. + // Test only methods + // set_clock alters ownership of the passed-in pointer. void set_clock(Clock* clock); + void SetSecurityLevelForTest(CdmSecurityLevel security_level); + LicenseState license_state_; // This is the current policy information for this license. This gets updated diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index da643010..f3473b52 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -635,8 +635,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) { return INSUFFICIENT_OUTPUT_PROTECTION; return NEED_KEY; } - if (!policy_engine_->CanUseKeyForSecurityLevel(*params.key_id, - security_level_)) { + if (!policy_engine_->CanUseKeyForSecurityLevel(*params.key_id)) { return KEY_PROHIBITED_FOR_SECURITY_LEVEL; } } diff --git a/libwvdrmengine/cdm/core/src/license_key_status.cpp b/libwvdrmengine/cdm/core/src/license_key_status.cpp index b2485a07..ace80a17 100644 --- a/libwvdrmengine/cdm/core/src/license_key_status.cpp +++ b/libwvdrmengine/cdm/core/src/license_key_status.cpp @@ -152,6 +152,16 @@ bool LicenseKeys::MeetsConstraints(const KeyId& key_id) { } } +bool LicenseKeys::MeetsSecurityLevelConstraints(const KeyId& key_id) { + if (key_statuses_.count(key_id) > 0) { + return key_statuses_[key_id]->MeetsSecurityLevelConstraints(); + } else { + // If a Key ID is unknown to us, we don't know of any constraints for it, + // so never block decryption. + return true; + } +} + void LicenseKeys::ApplyConstraints( uint32_t new_resolution, CryptoSession::HdcpCapability new_hdcp_level) { for (LicenseKeyStatusIterator i = key_statuses_.begin(); @@ -168,7 +178,7 @@ void LicenseKeys::SetFromLicense(const video_widevine::License& license) { key.type() == KeyContainer::OPERATOR_SESSION || key.type() == KeyContainer::ENTITLEMENT)) { const KeyId& key_id = key.id(); - key_statuses_[key_id] = new LicenseKeyStatus(key); + key_statuses_[key_id] = new LicenseKeyStatus(key, security_level_); } } } @@ -190,23 +200,26 @@ void LicenseKeys::SetEntitledKeys( } } -LicenseKeyStatus::LicenseKeyStatus(const KeyContainer& key) +LicenseKeyStatus::LicenseKeyStatus(const KeyContainer& key, + const CdmSecurityLevel security_level) : is_content_key_(false), key_status_(kKeyStatusInternalError), meets_constraints_(true), + meets_security_level_constraints_(true), default_hdcp_level_(HDCP_NONE) { allowed_usage_.Clear(); constraints_.Clear(); if (key.type() == KeyContainer::CONTENT || key.type() == KeyContainer::ENTITLEMENT) { - ParseContentKey(key); + ParseContentKey(key, security_level); } else if (key.type() == KeyContainer::OPERATOR_SESSION) { ParseOperatorSessionKey(key); } } -void LicenseKeyStatus::ParseContentKey(const KeyContainer& key) { +void LicenseKeyStatus::ParseContentKey(const KeyContainer& key, + CdmSecurityLevel security_level) { is_content_key_ = true; if (key.has_level() && ((key.level() == KeyContainer::HW_SECURE_DECODE) || (key.level() == KeyContainer::HW_SECURE_ALL))) { @@ -238,8 +251,34 @@ void LicenseKeyStatus::ParseContentKey(const KeyContainer& key) { allowed_usage_.key_security_level_ = kKeySecurityLevelUnknown; break; } + + switch (security_level) { + case kSecurityLevelL1: + meets_security_level_constraints_ = true; + break; + case kSecurityLevelL2: + case kSecurityLevelL3: + switch (key.level()) { + case KeyContainer::SW_SECURE_CRYPTO: + case KeyContainer::SW_SECURE_DECODE: + meets_security_level_constraints_ = true; + break; + case KeyContainer::HW_SECURE_CRYPTO: + meets_security_level_constraints_ = + security_level == kSecurityLevelL2; + break; + default: + meets_security_level_constraints_ = false; + break; + } + break; + default: + meets_security_level_constraints_ = false; + break; + } } else { allowed_usage_.key_security_level_ = kKeySecurityLevelUnset; + meets_security_level_constraints_ = true; } allowed_usage_.SetValid(); @@ -301,7 +340,7 @@ bool LicenseKeyStatus::ApplyStatusChange(CdmKeyStatus new_status, } CdmKeyStatus updated_status = new_status; if (updated_status == kKeyStatusUsable) { - if (!MeetsConstraints()) { + if (!MeetsConstraints() || !MeetsSecurityLevelConstraints()) { updated_status = kKeyStatusOutputNotAllowed; } } diff --git a/libwvdrmengine/cdm/core/src/policy_engine.cpp b/libwvdrmengine/cdm/core/src/policy_engine.cpp index c78cacb8..8a6ff8f5 100644 --- a/libwvdrmengine/cdm/core/src/policy_engine.cpp +++ b/libwvdrmengine/cdm/core/src/policy_engine.cpp @@ -40,7 +40,7 @@ PolicyEngine::PolicyEngine(CdmSessionId session_id, last_recorded_current_time_(0), session_id_(session_id), event_listener_(event_listener), - license_keys_(new LicenseKeys), + license_keys_(new LicenseKeys(crypto_session->GetSecurityLevel())), clock_(new Clock) { InitDevice(crypto_session); } @@ -311,30 +311,8 @@ CdmResponseType PolicyEngine::QueryKeyAllowedUsage( return KEY_NOT_FOUND_1; } -bool PolicyEngine::CanUseKeyForSecurityLevel( - const KeyId& key_id, - CdmSecurityLevel security_level) { - - if (security_level == kSecurityLevelL1) return true; - - CdmKeyAllowedUsage key_usage; - CdmResponseType status = QueryKeyAllowedUsage(key_id, &key_usage); - - if (status != NO_ERROR) return false; - - // L1 has already been addressed so verify that L2/3 are allowed - switch (key_usage.key_security_level_) { - case kKeySecurityLevelUnset: - return true; - case kSoftwareSecureCrypto: - case kSoftwareSecureDecode: - return security_level == kSecurityLevelL2 || - security_level == kSecurityLevelL3; - case kHardwareSecureCrypto: - return security_level == kSecurityLevelL2; - default: - return false; - } +bool PolicyEngine::CanUseKeyForSecurityLevel(const KeyId& key_id) { + return license_keys_->MeetsSecurityLevelConstraints(key_id); } bool PolicyEngine::GetSecondsSinceStarted(int64_t* seconds_since_started) { @@ -525,4 +503,8 @@ int64_t PolicyEngine::GetCurrentTime() { void PolicyEngine::set_clock(Clock* clock) { clock_.reset(clock); } +void PolicyEngine::SetSecurityLevelForTest(CdmSecurityLevel security_level) { + license_keys_->SetSecurityLevelForTest(security_level); +} + } // namespace wvcdm diff --git a/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp b/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp index 6633bf43..11290133 100644 --- a/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp @@ -152,7 +152,8 @@ class MockCryptoSession : public TestCryptoSession { class MockPolicyEngine : public PolicyEngine { public: - MockPolicyEngine() : PolicyEngine("mock_session_id", NULL, NULL) {} + MockPolicyEngine(CryptoSession* crypto_session) + : PolicyEngine("mock_session_id", NULL, crypto_session) {} // Leaving a place-holder for when PolicyEngine methods need to be mocked }; @@ -181,7 +182,7 @@ class CdmSessionTest : public WvCdmTestBase { cdm_session_->set_license_parser(license_parser_); crypto_session_ = new NiceMock(&crypto_metrics_); cdm_session_->set_crypto_session(crypto_session_); - policy_engine_ = new MockPolicyEngine(); + policy_engine_ = new MockPolicyEngine(crypto_session_); cdm_session_->set_policy_engine(policy_engine_); file_handle_ = new MockDeviceFiles(); cdm_session_->set_file_handle(file_handle_); diff --git a/libwvdrmengine/cdm/core/test/license_keys_unittest.cpp b/libwvdrmengine/cdm/core/test/license_keys_unittest.cpp index 2dc00dc1..1718b036 100644 --- a/libwvdrmengine/cdm/core/test/license_keys_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/license_keys_unittest.cpp @@ -98,6 +98,7 @@ class LicenseKeysTest : public ::testing::Test { static const KeyFlag kContentClearTrue = kKeyFlagTrue; void SetUp() override { + license_keys_.reset(new LicenseKeys(kSecurityLevelL1)); LicenseIdentification* id = license_.mutable_id(); id->set_version(1); id->set_type(STREAMING); @@ -217,7 +218,7 @@ class LicenseKeysTest : public ::testing::Test { content_key_count_++; AddContentKey(ck_hw_secure, true, KeyContainer::HW_SECURE_ALL); content_key_count_++; - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); } virtual void StageOperatorSessionKeys() { @@ -235,7 +236,7 @@ class LicenseKeysTest : public ::testing::Test { kEncryptNull, kDecryptNull, kSignTrue, kVerifyTrue); AddOperatorSessionKey(osk_all, true, kEncryptTrue, kDecryptTrue, kSignTrue, kVerifyTrue); - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); } virtual void StageHdcpKeys() { @@ -276,7 +277,7 @@ class LicenseKeysTest : public ::testing::Test { KeyContainer::HW_SECURE_ALL, true, KeyContainer::OutputProtection::HDCP_NO_DIGITAL_OUTPUT); content_key_count_++; - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); } virtual void AddConstraint( @@ -348,7 +349,7 @@ class LicenseKeysTest : public ::testing::Test { &constraints); content_key_count_++; - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); } virtual void ExpectKeyStatusesEqual(CdmKeyStatusMap& key_status_map, @@ -372,19 +373,19 @@ class LicenseKeysTest : public ::testing::Test { size_t content_key_count_; - LicenseKeys license_keys_; + std::unique_ptr license_keys_; License license_; }; TEST_F(LicenseKeysTest, Empty) { - EXPECT_TRUE(license_keys_.Empty()); + EXPECT_TRUE(license_keys_->Empty()); } TEST_F(LicenseKeysTest, NotEmpty) { const KeyId c_key = "content_key"; AddContentKey(c_key); - license_keys_.SetFromLicense(license_); - EXPECT_FALSE(license_keys_.Empty()); + license_keys_->SetFromLicense(license_); + EXPECT_FALSE(license_keys_->Empty()); } TEST_F(LicenseKeysTest, BadKeyId) { @@ -394,11 +395,12 @@ TEST_F(LicenseKeysTest, BadKeyId) { CdmKeyAllowedUsage allowed_usage; AddContentKey(c_key); AddOperatorSessionKey(os_key); - license_keys_.SetFromLicense(license_); - EXPECT_FALSE(license_keys_.IsContentKey(unk_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(unk_key)); - EXPECT_TRUE(license_keys_.MeetsConstraints(unk_key)); - EXPECT_FALSE(license_keys_.GetAllowedUsage(unk_key, &allowed_usage)); + license_keys_->SetFromLicense(license_); + EXPECT_FALSE(license_keys_->IsContentKey(unk_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(unk_key)); + EXPECT_TRUE(license_keys_->MeetsConstraints(unk_key)); + EXPECT_TRUE(license_keys_->MeetsSecurityLevelConstraints(unk_key)); + EXPECT_FALSE(license_keys_->GetAllowedUsage(unk_key, &allowed_usage)); } TEST_F(LicenseKeysTest, SigningKey) { @@ -409,81 +411,82 @@ TEST_F(LicenseKeysTest, SigningKey) { AddSigningKey(sign_key); AddContentKey(c_key); AddOperatorSessionKey(os_key); - license_keys_.SetFromLicense(license_); - EXPECT_FALSE(license_keys_.IsContentKey(sign_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(sign_key)); - EXPECT_TRUE(license_keys_.MeetsConstraints(sign_key)); - EXPECT_FALSE(license_keys_.GetAllowedUsage(sign_key, &allowed_usage)); + license_keys_->SetFromLicense(license_); + EXPECT_FALSE(license_keys_->IsContentKey(sign_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(sign_key)); + EXPECT_TRUE(license_keys_->MeetsConstraints(sign_key)); + EXPECT_TRUE(license_keys_->MeetsSecurityLevelConstraints(sign_key)); + EXPECT_FALSE(license_keys_->GetAllowedUsage(sign_key, &allowed_usage)); } TEST_F(LicenseKeysTest, ContentKey) { const KeyId c_key = "content_key"; AddContentKey(c_key); - EXPECT_FALSE(license_keys_.IsContentKey(c_key)); + EXPECT_FALSE(license_keys_->IsContentKey(c_key)); - license_keys_.SetFromLicense(license_); - EXPECT_TRUE(license_keys_.IsContentKey(c_key)); + license_keys_->SetFromLicense(license_); + EXPECT_TRUE(license_keys_->IsContentKey(c_key)); } TEST_F(LicenseKeysTest, EntitlementKey) { const KeyId e_key = "entitlement_key"; const KeyId c_key = "content_key"; AddEntitlementKey(e_key); - EXPECT_FALSE(license_keys_.IsContentKey(e_key)); + EXPECT_FALSE(license_keys_->IsContentKey(e_key)); - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); // TODO(juce, rfrias): For simplicity entitlement keys are indicated as // content keys. It doesn't break anything, but CanDecryptContent returns true // for and entitlement key id. - EXPECT_TRUE(license_keys_.IsContentKey(e_key)); + EXPECT_TRUE(license_keys_->IsContentKey(e_key)); std::vector entitled_keys(1); entitled_keys[0].set_entitlement_key_id(e_key); entitled_keys[0].set_key_id(c_key); - EXPECT_FALSE(license_keys_.IsContentKey(c_key)); - license_keys_.SetEntitledKeys(entitled_keys); - EXPECT_TRUE(license_keys_.IsContentKey(c_key)); + EXPECT_FALSE(license_keys_->IsContentKey(c_key)); + license_keys_->SetEntitledKeys(entitled_keys); + EXPECT_TRUE(license_keys_->IsContentKey(c_key)); } TEST_F(LicenseKeysTest, OperatorSessionKey) { const KeyId os_key = "op_sess_key"; - EXPECT_FALSE(license_keys_.IsContentKey(os_key)); + EXPECT_FALSE(license_keys_->IsContentKey(os_key)); AddOperatorSessionKey(os_key); - license_keys_.SetFromLicense(license_); - EXPECT_FALSE(license_keys_.IsContentKey(os_key)); + license_keys_->SetFromLicense(license_); + EXPECT_FALSE(license_keys_->IsContentKey(os_key)); } TEST_F(LicenseKeysTest, CanDecrypt) { const KeyId os_key = "op_sess_key"; const KeyId c_key = "content_key"; const KeyId e_key = "entitlement_key"; - EXPECT_FALSE(license_keys_.CanDecryptContent(c_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(os_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(e_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(c_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(os_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(e_key)); AddOperatorSessionKey(os_key); AddContentKey(c_key); AddEntitlementKey(e_key); - license_keys_.SetFromLicense(license_); - EXPECT_FALSE(license_keys_.CanDecryptContent(c_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(os_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(e_key)); + license_keys_->SetFromLicense(license_); + EXPECT_FALSE(license_keys_->CanDecryptContent(c_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(os_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(e_key)); bool new_usable_keys = false; bool any_change = false; - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + 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)); + EXPECT_TRUE(license_keys_->CanDecryptContent(c_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(os_key)); - any_change = license_keys_.ApplyStatusChange(kKeyStatusExpired, + 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)); - EXPECT_FALSE(license_keys_.CanDecryptContent(os_key)); - EXPECT_FALSE(license_keys_.CanDecryptContent(e_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(c_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(os_key)); + EXPECT_FALSE(license_keys_->CanDecryptContent(e_key)); } TEST_F(LicenseKeysTest, AllowedUsageNull) { @@ -495,22 +498,22 @@ TEST_F(LicenseKeysTest, AllowedUsageNull) { AddContentKey(c_key); AddSigningKey(sign_key); AddEntitlementKey(e_key); - license_keys_.SetFromLicense(license_); + license_keys_->SetFromLicense(license_); CdmKeyAllowedUsage usage_1; - EXPECT_FALSE(license_keys_.GetAllowedUsage(sign_key, &usage_1)); + EXPECT_FALSE(license_keys_->GetAllowedUsage(sign_key, &usage_1)); CdmKeyAllowedUsage usage_2; - EXPECT_TRUE(license_keys_.GetAllowedUsage(c_key, &usage_2)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(c_key, &usage_2)); ExpectAllowedUsageContent(usage_2, kContentClearTrue, kContentSecureTrue, kKeySecurityLevelUnset); CdmKeyAllowedUsage usage_3; - EXPECT_TRUE(license_keys_.GetAllowedUsage(os_key, &usage_3)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(os_key, &usage_3)); ExpectAllowedUsageContent(usage_3, kContentClearFalse, kContentSecureFalse, kKeySecurityLevelUnset); CdmKeyAllowedUsage usage_4; - EXPECT_TRUE(license_keys_.GetAllowedUsage(os_key, &usage_4)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(os_key, &usage_4)); ExpectAllowedUsageContent(usage_4, kContentClearFalse, kContentSecureFalse, kKeySecurityLevelUnset); } @@ -518,27 +521,27 @@ TEST_F(LicenseKeysTest, AllowedUsageNull) { TEST_F(LicenseKeysTest, AllowedUsageContent) { StageContentKeys(); CdmKeyAllowedUsage u_sw_crypto; - EXPECT_TRUE(license_keys_.GetAllowedUsage(ck_sw_crypto, &u_sw_crypto)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_sw_crypto, &u_sw_crypto)); ExpectAllowedUsageContent(u_sw_crypto, kContentSecureTrue, kContentClearTrue, kSoftwareSecureCrypto); CdmKeyAllowedUsage u_sw_decode; - EXPECT_TRUE(license_keys_.GetAllowedUsage(ck_sw_decode, &u_sw_decode)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_sw_decode, &u_sw_decode)); ExpectAllowedUsageContent(u_sw_decode, kContentSecureTrue, kContentClearTrue, kSoftwareSecureDecode); CdmKeyAllowedUsage u_hw_crypto; - EXPECT_TRUE(license_keys_.GetAllowedUsage(ck_hw_crypto, &u_hw_crypto)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_hw_crypto, &u_hw_crypto)); ExpectAllowedUsageContent(u_hw_crypto, kContentSecureTrue, kContentClearTrue, kHardwareSecureCrypto); CdmKeyAllowedUsage u_hw_decode; - EXPECT_TRUE(license_keys_.GetAllowedUsage(ck_hw_decode, &u_hw_decode)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_hw_decode, &u_hw_decode)); ExpectAllowedUsageContent(u_hw_decode, kContentSecureTrue, kContentClearFalse, kHardwareSecureDecode); CdmKeyAllowedUsage u_hw_secure; - EXPECT_TRUE(license_keys_.GetAllowedUsage(ck_hw_secure, &u_hw_secure)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(ck_hw_secure, &u_hw_secure)); ExpectAllowedUsageContent(u_hw_secure, kContentSecureTrue, kContentClearFalse, kHardwareSecureAll); } @@ -546,38 +549,38 @@ TEST_F(LicenseKeysTest, AllowedUsageContent) { TEST_F(LicenseKeysTest, AllowedUsageOperatorSession) { StageOperatorSessionKeys(); CdmKeyAllowedUsage u_encrypt; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_encrypt, &u_encrypt)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_encrypt, &u_encrypt)); ExpectAllowedUsageOperator(u_encrypt, kEncryptTrue, kDecryptFalse, kSignFalse, kVerifyFalse); CdmKeyAllowedUsage u_decrypt; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_decrypt, &u_decrypt)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_decrypt, &u_decrypt)); ExpectAllowedUsageOperator(u_decrypt, kEncryptFalse, kDecryptTrue, kSignFalse, kVerifyFalse); CdmKeyAllowedUsage u_sign; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_sign, &u_sign)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_sign, &u_sign)); ExpectAllowedUsageOperator(u_sign, kEncryptFalse, kDecryptFalse, kSignTrue, kVerifyFalse); CdmKeyAllowedUsage u_verify; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_verify, &u_verify)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_verify, &u_verify)); ExpectAllowedUsageOperator(u_verify, kEncryptFalse, kDecryptFalse, kSignFalse, kVerifyTrue); CdmKeyAllowedUsage u_encrypt_decrypt; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_encrypt_decrypt, + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_encrypt_decrypt, &u_encrypt_decrypt)); ExpectAllowedUsageOperator(u_encrypt_decrypt, kEncryptTrue, kDecryptTrue, kSignFalse, kVerifyFalse); CdmKeyAllowedUsage u_sign_verify; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_sign_verify, &u_sign_verify)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_sign_verify, &u_sign_verify)); ExpectAllowedUsageOperator(u_sign_verify, kEncryptFalse, kDecryptFalse, kSignTrue, kVerifyTrue); CdmKeyAllowedUsage u_all; - EXPECT_TRUE(license_keys_.GetAllowedUsage(osk_all, &u_all)); + EXPECT_TRUE(license_keys_->GetAllowedUsage(osk_all, &u_all)); ExpectAllowedUsageOperator(u_all, kEncryptTrue, kDecryptTrue, kSignTrue, kVerifyTrue); } @@ -585,10 +588,10 @@ TEST_F(LicenseKeysTest, AllowedUsageOperatorSession) { TEST_F(LicenseKeysTest, ExtractKeyStatuses) { CdmKeyStatusMap key_status_map; StageOperatorSessionKeys(); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(0u, key_status_map.size()); StageContentKeys(); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusInternalError); } @@ -600,67 +603,67 @@ TEST_F(LicenseKeysTest, KeyStatusChanges) { StageOperatorSessionKeys(); StageContentKeys(); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusInternalError); // change to pending - any_change = license_keys_.ApplyStatusChange(kKeyStatusPending, + 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)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusPending); // change to pending (again) - any_change = license_keys_.ApplyStatusChange(kKeyStatusPending, + any_change = license_keys_->ApplyStatusChange(kKeyStatusPending, &new_usable_keys); EXPECT_FALSE(any_change); EXPECT_FALSE(new_usable_keys); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusPending); // change to usable - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsable); // change to usable (again) - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusUsable); // change to expired - any_change = license_keys_.ApplyStatusChange(kKeyStatusExpired, + 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)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); EXPECT_EQ(content_key_count_, key_status_map.size()); ExpectKeyStatusesEqual(key_status_map, kKeyStatusExpired); } @@ -671,61 +674,61 @@ TEST_F(LicenseKeysTest, HdcpChanges) { CdmKeyStatusMap key_status_map; StageHdcpKeys(); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ApplyConstraints(100, HDCP_NONE); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_NONE); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_FALSE(new_usable_keys); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -745,35 +748,35 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_NO_OUTPUT, kKeyStatusOutputNotAllowed); - license_keys_.ApplyConstraints(100, HDCP_V1); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_V1); + 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_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -793,35 +796,35 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_NO_OUTPUT, kKeyStatusOutputNotAllowed); - license_keys_.ApplyConstraints(100, HDCP_V2_1); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_V2_1); + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -841,35 +844,35 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_NO_OUTPUT, kKeyStatusOutputNotAllowed); - license_keys_.ApplyConstraints(100, HDCP_V2_2); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_V2_2); + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -889,35 +892,35 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_NO_OUTPUT, kKeyStatusOutputNotAllowed); - license_keys_.ApplyConstraints(100, HDCP_V2_3); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_V2_3); + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -937,27 +940,27 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_NO_OUTPUT, kKeyStatusOutputNotAllowed); - license_keys_.ApplyConstraints(100, HDCP_NO_DIGITAL_OUTPUT); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_NO_DIGITAL_OUTPUT); + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -977,35 +980,35 @@ TEST_F(LicenseKeysTest, HdcpChanges) { ExpectKeyStatusEqual(key_status_map, ck_hw_secure_HDCP_NO_OUTPUT, kKeyStatusUsable); - license_keys_.ApplyConstraints(100, HDCP_NONE); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(100, HDCP_NONE); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_FALSE(new_usable_keys); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure_HDCP_NO_OUTPUT)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_sw_crypto_NO_HDCP)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_hw_secure_NO_HDCP)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_1)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_2)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_V2_3)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_sw_crypto_NO_HDCP)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_hw_secure_NO_HDCP)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_1)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_2)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_V2_3)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_sw_crypto_HDCP_NO_OUTPUT)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_hw_secure_HDCP_NO_OUTPUT)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -1033,46 +1036,46 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { StageConstraintKeys(); // No constraints set by device - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + 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)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); // Low-res device, no HDCP support - license_keys_.ApplyConstraints(dev_lo_res, HDCP_NONE); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_lo_res, HDCP_NONE); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_FALSE(new_usable_keys); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -1093,27 +1096,27 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusOutputNotAllowed); // Hi-res device, HDCP_V1 support - license_keys_.ApplyConstraints(dev_hi_res, HDCP_V1); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_hi_res, HDCP_V1); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_TRUE(new_usable_keys); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_NO_HDCP_lo_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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_HDCP_V2_1, @@ -1134,27 +1137,27 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusOutputNotAllowed); // Lo-res device, HDCP V2.2 support - license_keys_.ApplyConstraints(dev_lo_res, HDCP_V2_2); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_lo_res, HDCP_V2_2); + 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)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_V2_1, kKeyStatusUsable); ExpectKeyStatusEqual(key_status_map, ck_hw_secure_HDCP_V2_1, @@ -1173,27 +1176,27 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusOutputNotAllowed); // Hi-res device, Maximal HDCP support - license_keys_.ApplyConstraints(dev_hi_res, HDCP_NO_DIGITAL_OUTPUT); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_hi_res, HDCP_NO_DIGITAL_OUTPUT); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_TRUE(new_usable_keys); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_NO_HDCP_lo_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + license_keys_->ExtractKeyStatuses(&key_status_map); ExpectKeyStatusEqual(key_status_map, ck_sw_crypto_HDCP_V2_1, kKeyStatusUsable); ExpectKeyStatusEqual(key_status_map, ck_hw_secure_HDCP_V2_1, @@ -1212,29 +1215,29 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusUsable); // Lo-res device, no HDCP support - license_keys_.ApplyConstraints(dev_lo_res, HDCP_NONE); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_lo_res, HDCP_NONE); + 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)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); - EXPECT_TRUE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_TRUE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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, @@ -1257,27 +1260,27 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusOutputNotAllowed); // Too-high-res -- all keys rejected - license_keys_.ApplyConstraints(dev_top_res, HDCP_NONE); - any_change = license_keys_.ApplyStatusChange(kKeyStatusUsable, + license_keys_->ApplyConstraints(dev_top_res, HDCP_NONE); + any_change = license_keys_->ApplyStatusChange(kKeyStatusUsable, &new_usable_keys); EXPECT_TRUE(any_change); EXPECT_FALSE(new_usable_keys); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_HDCP_V2_3_max_res)); - EXPECT_FALSE(license_keys_.CanDecryptContent(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_HDCP_V2_3_max_res)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_NO_HDCP_dual_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_NO_HDCP_lo_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_1_hi_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_2_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_HDCP_V2_3_max_res)); - EXPECT_FALSE(license_keys_.MeetsConstraints(ck_NO_HDCP_dual_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_lo_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_NO_OUTPUT_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_1_hi_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_2_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_HDCP_V2_3_max_res)); + EXPECT_FALSE(license_keys_->MeetsConstraints(ck_NO_HDCP_dual_res)); - license_keys_.ExtractKeyStatuses(&key_status_map); + 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, @@ -1300,4 +1303,156 @@ TEST_F(LicenseKeysTest, ConstraintChanges) { kKeyStatusOutputNotAllowed); } +struct KeySecurityLevelParams { + CdmSecurityLevel security_level; + bool expect_usable_keys; + bool expect_can_use_sw_crypto_key; + bool expect_can_use_sw_decode_key; + bool expect_can_use_hw_crypto_key; + bool expect_can_use_hw_decode_key; + bool expect_can_use_hw_secure_key; +}; + +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}, +}; + +class LicenseKeysSecurityLevelConstraintsTest + : public LicenseKeysTest, + public ::testing::WithParamInterface {}; + +TEST_P(LicenseKeysSecurityLevelConstraintsTest, KeyStatusChange) { + bool new_usable_keys = false; + bool any_change = false; + CdmKeyStatusMap key_status_map; + + KeySecurityLevelParams* config = GetParam(); + license_keys_->SetSecurityLevelForTest(config->security_level); + StageContentKeys(); + + license_keys_->ExtractKeyStatuses(&key_status_map); + EXPECT_EQ(content_key_count_, key_status_map.size()); + ExpectKeyStatusesEqual(key_status_map, kKeyStatusInternalError); + + // change to pending + 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)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_decode)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_decode)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); + + license_keys_->ExtractKeyStatuses(&key_status_map); + EXPECT_EQ(content_key_count_, key_status_map.size()); + ExpectKeyStatusesEqual(key_status_map, kKeyStatusPending); + + // change to pending (again) + any_change = license_keys_->ApplyStatusChange(kKeyStatusPending, + &new_usable_keys); + EXPECT_FALSE(any_change); + EXPECT_FALSE(new_usable_keys); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_sw_decode)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_crypto)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_decode)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); + + license_keys_->ExtractKeyStatuses(&key_status_map); + EXPECT_EQ(content_key_count_, key_status_map.size()); + ExpectKeyStatusesEqual(key_status_map, kKeyStatusPending); + + // change to usable + 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, + license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_EQ(config->expect_can_use_sw_decode_key, + license_keys_->CanDecryptContent(ck_sw_decode)); + EXPECT_EQ(config->expect_can_use_hw_crypto_key, + license_keys_->CanDecryptContent(ck_hw_crypto)); + EXPECT_EQ(config->expect_can_use_hw_decode_key, + license_keys_->CanDecryptContent(ck_hw_decode)); + EXPECT_EQ(config->expect_can_use_hw_secure_key, + license_keys_->CanDecryptContent(ck_hw_secure)); + + 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, + key_status_map[ck_sw_crypto]); + 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, + key_status_map[ck_hw_crypto]); + 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, + key_status_map[ck_hw_secure]); + + // change to usable (again) + 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, + license_keys_->CanDecryptContent(ck_sw_crypto)); + EXPECT_EQ(config->expect_can_use_sw_decode_key, + license_keys_->CanDecryptContent(ck_sw_decode)); + EXPECT_EQ(config->expect_can_use_hw_crypto_key, + license_keys_->CanDecryptContent(ck_hw_crypto)); + EXPECT_EQ(config->expect_can_use_hw_decode_key, + license_keys_->CanDecryptContent(ck_hw_decode)); + EXPECT_EQ(config->expect_can_use_hw_secure_key, + license_keys_->CanDecryptContent(ck_hw_secure)); + + 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, + key_status_map[ck_sw_crypto]); + 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, + key_status_map[ck_hw_crypto]); + 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, + key_status_map[ck_hw_secure]); + + // change to expired + 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)); + EXPECT_FALSE(license_keys_->CanDecryptContent(ck_hw_secure)); + + license_keys_->ExtractKeyStatuses(&key_status_map); + EXPECT_EQ(content_key_count_, key_status_map.size()); + ExpectKeyStatusesEqual(key_status_map, kKeyStatusExpired); +} + +INSTANTIATE_TEST_CASE_P(KeyStatusChange, + LicenseKeysSecurityLevelConstraintsTest, + ::testing::Range(&key_security_level_test_vectors[0], + &key_security_level_test_vectors[5])); + } // namespace wvcdm diff --git a/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp b/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp index f346cd86..3ce75e51 100644 --- a/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp @@ -182,6 +182,10 @@ class PolicyEngineTest : public WvCdmTestBase { expected_has_new_usable_key)); } + void SetCdmSecurityLevel(CdmSecurityLevel security_level) { + policy_engine_->SetSecurityLevelForTest(security_level); + } + metrics::CryptoMetrics dummy_metrics_; NiceMock crypto_session_; StrictMock mock_event_listener_; @@ -1725,20 +1729,29 @@ TEST_P(PolicyEngineKeySecurityLevelTest, CanUseKeyForSecurityLevel) { ExpectSessionKeysChange(kKeyStatusUsable, true); EXPECT_CALL(mock_event_listener_, OnExpirationUpdate(_, _)); + SetCdmSecurityLevel(kSecurityLevelL1); policy_engine_->SetLicense(license_); EXPECT_EQ(param->expect_can_L1_use_key, - policy_engine_->CanUseKeyForSecurityLevel(kKeyId, - kSecurityLevelL1)); + policy_engine_->CanUseKeyForSecurityLevel(kKeyId)); + + SetCdmSecurityLevel(kSecurityLevelL2); + policy_engine_->SetLicense(license_); + EXPECT_EQ(param->expect_can_L2_use_key, - policy_engine_->CanUseKeyForSecurityLevel(kKeyId, - kSecurityLevelL2)); + policy_engine_->CanUseKeyForSecurityLevel(kKeyId)); + + SetCdmSecurityLevel(kSecurityLevelL3); + policy_engine_->SetLicense(license_); + EXPECT_EQ(param->expect_can_L3_use_key, - policy_engine_->CanUseKeyForSecurityLevel(kKeyId, - kSecurityLevelL3)); + policy_engine_->CanUseKeyForSecurityLevel(kKeyId)); + + SetCdmSecurityLevel(kSecurityLevelUnknown); + policy_engine_->SetLicense(license_); + EXPECT_EQ(param->expect_can_level_unknown_use_key, - policy_engine_->CanUseKeyForSecurityLevel(kKeyId, - kSecurityLevelUnknown)); + policy_engine_->CanUseKeyForSecurityLevel(kKeyId)); } INSTANTIATE_TEST_CASE_P( @@ -1859,6 +1872,8 @@ TEST_F(PolicyEngineKeyAllowedUsageTest, AllowedUsageBasic) { content_key->set_id(kKeyId); content_key->set_level(License::KeyContainer::HW_SECURE_ALL); + SetCdmSecurityLevel(kSecurityLevelL1); + // generic operator session key (sign) AddOperatorSessionKey(kGenericKeyId, kEncryptNull, kDecryptNull, kSignTrue, kVerifyNull); @@ -1917,6 +1932,8 @@ TEST_F(PolicyEngineKeyAllowedUsageTest, AllowedUsageGeneric) { another_content_key->set_id(kAnotherKeyId); another_content_key->set_level(License::KeyContainer::HW_SECURE_CRYPTO); + SetCdmSecurityLevel(kSecurityLevelL1); + // generic operator session keys AddOperatorSessionKey(kGenericSignKeyId, kEncryptNull, kDecryptNull, kSignTrue, kVerifyNull);