Add Shared License bit to key control block
Merge from widevine of http://go/wvgerrit/23184 This adds the shared license bit to the key control block for the reference code and the unit tests. b/31458046 Change-Id: I4e360ea5dd2e6cee145663d4ab4f384b65cac427
This commit is contained in:
@@ -433,6 +433,10 @@ OEMCryptoResult SessionContext::LoadKeys(
|
||||
|
||||
StartTimer();
|
||||
|
||||
// If there are already keys installed in this session, then we can load
|
||||
// a shared license.
|
||||
bool second_license = (session_keys_.size() > 0);
|
||||
|
||||
// Decrypt and install keys in key object
|
||||
// Each key will have a key control block. They will all have the same nonce.
|
||||
OEMCryptoResult status = OEMCrypto_SUCCESS;
|
||||
@@ -459,7 +463,7 @@ OEMCryptoResult SessionContext::LoadKeys(
|
||||
|
||||
OEMCryptoResult result = InstallKey(
|
||||
key_id, enc_key_data, key_data_iv, key_control, key_control_iv,
|
||||
key_array[i].cipher_mode == OEMCrypto_CipherMode_CTR);
|
||||
key_array[i].cipher_mode == OEMCrypto_CipherMode_CTR, second_license);
|
||||
if (result != OEMCrypto_SUCCESS) {
|
||||
status = result;
|
||||
break;
|
||||
@@ -505,7 +509,7 @@ OEMCryptoResult SessionContext::LoadKeys(
|
||||
return OEMCrypto_ERROR_WRONG_PST;
|
||||
}
|
||||
if (!usage_entry_->VerifyMacKeys(mac_key_server_, mac_key_client_)) {
|
||||
LOGE("LoadKeys: Usage table entry does not match.\n");
|
||||
LOGE("LoadKeys: Usage table entry mac keys do not match.\n");
|
||||
return OEMCrypto_ERROR_WRONG_KEYS;
|
||||
}
|
||||
if (usage_entry_->Inactive()) return OEMCrypto_ERROR_LICENSE_INACTIVE;
|
||||
@@ -519,7 +523,8 @@ OEMCryptoResult SessionContext::InstallKey(
|
||||
const KeyId& key_id, const std::vector<uint8_t>& key_data,
|
||||
const std::vector<uint8_t>& key_data_iv,
|
||||
const std::vector<uint8_t>& key_control,
|
||||
const std::vector<uint8_t>& key_control_iv, bool ctr_mode) {
|
||||
const std::vector<uint8_t>& key_control_iv, bool ctr_mode,
|
||||
bool second_license) {
|
||||
// Decrypt encrypted key_data using derived encryption key and offered iv
|
||||
std::vector<uint8_t> content_key;
|
||||
std::vector<uint8_t> key_control_str;
|
||||
@@ -579,6 +584,13 @@ OEMCryptoResult SessionContext::InstallKey(
|
||||
return result;
|
||||
}
|
||||
|
||||
if (key_control_block.control_bits() & kSharedLicense) {
|
||||
if (!second_license) {
|
||||
LOGE("LoadKeys: Shared License, but no keys previously loaded.");
|
||||
return OEMCrypto_ERROR_MISSING_MASTER;
|
||||
}
|
||||
}
|
||||
|
||||
Key key(content_key, key_control_block, ctr_mode);
|
||||
session_keys_.Insert(key_id, key);
|
||||
return OEMCrypto_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user