Update key control block logging

Merge from Widevine repo of http://go/wvgerrit/72386

This CL changes reference and testbed OEMCyrpto only.

Updates the logging of the key control block for testing by adding new
bits to log and cleaning up the format.

Also, update access to entitlement keys so that they can also have
their key control block logged in tests.

Test: reference and test code only.
Bug: http://b/113594182 Full Decrypt Path Testing - Top Level
Bug: http://b/68648263 Log Key Control Block
Change-Id: I259d6f29eceb9f097640aa50f43443e308797f69
This commit is contained in:
Fred Gylys-Colwell
2019-02-09 09:31:50 -08:00
parent 3448b2d4ec
commit b34c9db4c7
4 changed files with 21 additions and 29 deletions

View File

@@ -67,8 +67,7 @@ class ContentKeysContext : public SessionContextKeys {
bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key) override;
bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** entitlement_key) override;
EntitlementKey* GetEntitlementKey(const KeyId& entitlement_id) override;
private:
SessionKeyTable session_keys_;
@@ -98,11 +97,11 @@ bool ContentKeysContext::SetContentKey(
return false;
}
bool ContentKeysContext::GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** key) {
EntitlementKey* ContentKeysContext::GetEntitlementKey(
const KeyId& entitlement_id) {
// Unsupported action for this type.
return false;
};
return nullptr;
}
/***************************************/
@@ -118,8 +117,7 @@ class EntitlementKeysContext : public SessionContextKeys {
bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key) override;
bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** key) override;
EntitlementKey* GetEntitlementKey(const KeyId& entitlement_id) override;
OEMCrypto_LicenseType type() override { return OEMCrypto_EntitlementLicense; }
@@ -151,9 +149,9 @@ bool EntitlementKeysContext::SetContentKey(
content_key);
}
bool EntitlementKeysContext::GetEntitlementKey(
const KeyId& entitlement_id, const std::vector<uint8_t>** out_key) {
return session_keys_.GetEntitlementKey(entitlement_id, out_key);
EntitlementKey* EntitlementKeysContext::GetEntitlementKey(
const KeyId& entitlement_id) {
return session_keys_.GetEntitlementKey(entitlement_id);
}
/***************************************/
@@ -657,9 +655,9 @@ OEMCryptoResult SessionContext::LoadEntitledContentKeys(
message + key_data->entitlement_key_id.offset +
key_data->entitlement_key_id.length);
const std::vector<uint8_t>* entitlement_key = NULL;
if (!session_keys_->GetEntitlementKey(entitlement_key_id,
&entitlement_key)) {
EntitlementKey* entitlement_key =
session_keys_->GetEntitlementKey(entitlement_key_id);
if (entitlement_key == nullptr) {
return OEMCrypto_KEY_NOT_ENTITLED;
}
std::vector<uint8_t> content_key;
@@ -675,8 +673,9 @@ OEMCryptoResult SessionContext::LoadEntitledContentKeys(
content_key_id.assign(message + key_data->content_key_id.offset,
message + key_data->content_key_id.offset +
key_data->content_key_id.length);
if (!DecryptMessage(*entitlement_key, iv, encrypted_content_key,
&content_key, 256 /* key size */)) {
if (!DecryptMessage(entitlement_key->entitlement_key(), iv,
encrypted_content_key, &content_key,
256 /* key size */)) {
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
}
if (!session_keys_->SetContentKey(entitlement_key_id, content_key_id,

View File

@@ -46,8 +46,7 @@ class SessionContextKeys {
virtual bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key) = 0;
virtual bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** key) = 0;
virtual EntitlementKey* GetEntitlementKey(const KeyId& entitlement_id) = 0;
virtual ~SessionContextKeys() {}

View File

@@ -102,18 +102,13 @@ bool EntitlementKeyTable::SetContentKey(
return true;
}
bool EntitlementKeyTable::GetEntitlementKey(
const KeyId& entitlement_id,
const std::vector<uint8_t>** entitlement_key) {
if (!entitlement_key) {
return false;
}
EntitlementKey* EntitlementKeyTable::GetEntitlementKey(
const KeyId& entitlement_id) {
EntitlementKeyMap::iterator it = keys_.find(entitlement_id);
if (it == keys_.end()) {
return false;
return nullptr;
}
*entitlement_key = &it->second->entitlement_key();
return true;
return it->second;
}
} // namespace wvoec_ref

View File

@@ -57,8 +57,7 @@ class EntitlementKeyTable {
size_t size() const { return contentid_to_entitlementid_.size(); }
bool SetContentKey(const KeyId& entitlement_id, const KeyId& content_key_id,
const std::vector<uint8_t> content_key);
bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** entitlement_key);
EntitlementKey* GetEntitlementKey(const KeyId& entitlement_id);
private:
EntitlementKeyMap keys_;