Remove error OEMCrypto_KEY_NOT_LOADED

Merge from master branch of Widevine repo of http://go/wvgerrit/66066
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63628

The error code OEMCrypto_KEY_NOT_LOADED is redundant with
OEMCrypto_ERROR_NO_CONTENT_KEY and OEMCrypto_KEY_NOT_ENTITLED.  The
function LoadEntitledContentKey should return KEY_NOT_ENTITLED if it
does not find the corresponding entitlement key in its key table.  All
other functions that do not find a key id in the key table should
return OEMCrypto_ERROR_NO_CONTENT_KEY.  This includes QueryKeyControl,
SelectKey, and RefreshKeys.

Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 115574797
Change-Id: Ida2111f32e331b99f3f0c77fa404a42654d0870c
This commit is contained in:
Fred Gylys-Colwell
2018-11-12 14:12:26 -08:00
parent f3e9d84484
commit ef067572bc
9 changed files with 62 additions and 18 deletions

View File

@@ -980,7 +980,7 @@ CdmResponseType CryptoSession::SelectKey(const std::string& key_id,
return NO_DEVICE_KEY_1;
case OEMCrypto_ERROR_NO_CONTENT_KEY:
return NO_CONTENT_KEY_2;
case OEMCrypto_KEY_NOT_LOADED:
case OEMCrypto_KEY_NOT_LOADED: // obsolete.
return NO_CONTENT_KEY_3;
case OEMCrypto_ERROR_INSUFFICIENT_RESOURCES:
return INSUFFICIENT_CRYPTO_RESOURCES_2;
@@ -1802,7 +1802,8 @@ CdmResponseType CryptoSession::GenericEncrypt(const std::string& in_buffer,
LOGE("GenericEncrypt: OEMCrypto_Generic_Encrypt err=%d", sts);
if (OEMCrypto_ERROR_KEY_EXPIRED == sts) {
return NEED_KEY;
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) {
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts
|| OEMCrypto_KEY_NOT_LOADED == sts) { // obsolete in v15.
return KEY_NOT_FOUND_3;
} else {
return UNKNOWN_ERROR;
@@ -1854,7 +1855,8 @@ CdmResponseType CryptoSession::GenericDecrypt(const std::string& in_buffer,
LOGE("GenericDecrypt: OEMCrypto_Generic_Decrypt err=%d", sts);
if (OEMCrypto_ERROR_KEY_EXPIRED == sts) {
return NEED_KEY;
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) {
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts
|| OEMCrypto_KEY_NOT_LOADED == sts) { // obsolete in v15.
return KEY_NOT_FOUND_4;
} else {
return UNKNOWN_ERROR;
@@ -1916,7 +1918,8 @@ CdmResponseType CryptoSession::GenericSign(const std::string& message,
LOGE("GenericSign: OEMCrypto_Generic_Sign err=%d", sts);
if (OEMCrypto_ERROR_KEY_EXPIRED == sts) {
return NEED_KEY;
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) {
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts
|| OEMCrypto_KEY_NOT_LOADED == sts) { // obsolete in v15.
return KEY_NOT_FOUND_5;
} else {
return UNKNOWN_ERROR;
@@ -1954,7 +1957,8 @@ CdmResponseType CryptoSession::GenericVerify(const std::string& message,
LOGE("GenericVerify: OEMCrypto_Generic_Verify err=%d", sts);
if (OEMCrypto_ERROR_KEY_EXPIRED == sts) {
return NEED_KEY;
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) {
} else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts
|| OEMCrypto_KEY_NOT_LOADED == sts) { // obsolete in v15.
return KEY_NOT_FOUND_6;
} else {
return UNKNOWN_ERROR;

View File

@@ -49,7 +49,7 @@ OEMCryptoResult EntitlementKeySession::SelectKey(const std::string& key_id,
// correct key every time SelectKey() is called.
if (entitled_keys_.find(key_id) == entitled_keys_.end()) {
LOGE("Unknown entitled key ID selected.");
return OEMCrypto_KEY_NOT_LOADED;
return OEMCrypto_ERROR_NO_CONTENT_KEY;
}
OEMCrypto_EntitledContentKeyObject entitled_key =

View File

@@ -120,7 +120,7 @@ TEST_F(WvGenericOperationsTest, GenericEncryptNoKey) {
cdm_sts = cdm_engine_.GenericEncrypt(
holder_.session_id(), in_buffer_, key_id, iv_,
wvcdm::kEncryptionAlgorithmAesCbc128, &out_buffer);
EXPECT_EQ(NO_CONTENT_KEY_3, cdm_sts);
EXPECT_EQ(NO_CONTENT_KEY_2, cdm_sts);
EXPECT_NE(encrypted, out_buffer);
}
@@ -163,7 +163,7 @@ TEST_F(WvGenericOperationsTest, GenericDecryptNoKey) {
cdm_sts = cdm_engine_.GenericDecrypt(
holder_.session_id(), in_buffer_, key_id, iv_,
wvcdm::kEncryptionAlgorithmAesCbc128, &out_buffer);
EXPECT_EQ(NO_CONTENT_KEY_3, cdm_sts);
EXPECT_EQ(NO_CONTENT_KEY_2, cdm_sts);
EXPECT_NE(decrypted, out_buffer);
}