Use Inheritence for OEMCrypto Mock Properties

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

We use compiler options to set different properties in the oemcrypto
mock.  With this CL, we define a base class that has default
properties.  All other variants need only define the properties that
they change.

b/35141278
b/37353534

Change-Id: Id38ec5bf35dcd83cea9a066ebe201e6da7c1a2b0
This commit is contained in:
Fred Gylys-Colwell
2017-04-14 13:47:02 -07:00
parent 86db60d097
commit ab0d00b92a
8 changed files with 215 additions and 349 deletions

View File

@@ -524,6 +524,9 @@ OEMCryptoResult SessionContext::InstallKey(
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
}
if (LogCategoryEnabled(kLoggingDumpKeyControlBlocks)) {
LOGD("Key ID: %s", wvcdm::b2a_hex(key_id).c_str());
}
KeyControlBlock key_control_block(key_control_str);
if (!key_control_block.valid()) {
LOGE("Error parsing key control.");
@@ -543,13 +546,11 @@ OEMCryptoResult SessionContext::InstallKey(
OEMCrypto_Security_Patch_Level(), minimum_patch_level);
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
}
OEMCryptoResult result = CheckNonceOrEntry(key_control_block);
if (result != OEMCrypto_SUCCESS) {
LOGE("LoadKeys: Failed Nonce/PST check.");
return result;
}
if (key_control_block.control_bits() & kSharedLicense) {
if (!second_license) {
LOGE("LoadKeys: Shared License, but no keys previously loaded.");
@@ -1109,11 +1110,6 @@ OEMCryptoResult SessionContext::DecryptCENC(
return OEMCrypto_SUCCESS;
}
if (buffer_type == OEMCrypto_BufferType_Secure) {
// For reference implementation, we also quietly drop secure data.
return OEMCrypto_SUCCESS;
}
if (!current_content_key()->ctr_mode()) {
if (block_offset > 0) return OEMCrypto_ERROR_INVALID_CONTEXT;
return DecryptCBC(key_u8, iv, pattern, cipher_data, cipher_data_length,