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
This commit is contained in:
Rahul Frias
2019-05-09 13:49:47 -07:00
parent c71fb10b95
commit 7d78609548
8 changed files with 621 additions and 412 deletions

View File

@@ -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<WidevinePsshData_EntitledKey>& 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<wvcdm::KeyId, LicenseKeyStatus*>::const_iterator
@@ -83,6 +91,8 @@ class LicenseKeys {
// key status from |key_statuses_| when using entitlement key licensing.
std::map<KeyId, KeyId> 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<VideoResolutionConstraint>
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_;

View File

@@ -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