Handle KEY_NOT_LOADED error

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

In OEMCrypto v14, SelectKey can also return KEY_NOT_LOADED if the key
id is not found.  This was added to help with entitlement licenses.
However, SelectKey in crypto session converts this to an unknown
error.

In this CL we change that to a NO_CONTENT_KEY_3 error.  This is
probably only important because the generic crypto tests expect
NO_CONTENT_KEY_3 when we try to use an undefined key.

Test: existing unit tests pass, and some future unit tests pass.
Bug: 72354901 Turn on generic crypto tests
Change-Id: I3c0b7e6306cafd3feabc8aac7e47983c89194a26
This commit is contained in:
Fred Gylys-Colwell
2018-08-03 17:10:30 -07:00
parent 790799ceaa
commit 5095bb746e
7 changed files with 11 additions and 4 deletions

View File

@@ -333,9 +333,10 @@ enum CdmResponseType {
GET_PROVISIONING_METHOD_ERROR = 289,
SESSION_NOT_FOUND_17 = 290,
SESSION_NOT_FOUND_18 = 291,
/* Error code 292 can be reused as it was never present in a release */
NO_CONTENT_KEY_3 = 292,
DEVICE_CANNOT_REPROVISION = 293,
SESSION_NOT_FOUND_19 = 294,
// Don't forget to add new values to ../test/test_printers.cpp.
};
enum CdmKeyStatus {

View File

@@ -981,6 +981,8 @@ 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:
return NO_CONTENT_KEY_3;
case OEMCrypto_ERROR_INSUFFICIENT_RESOURCES:
return INSUFFICIENT_CRYPTO_RESOURCES_2;
case OEMCrypto_ERROR_UNKNOWN_FAILURE:

View File

@@ -258,7 +258,7 @@ TEST_F(WvGenericOperationsTest, GenericEncryptNoKey) {
cdm_sts = cdm_engine_->GenericEncrypt(session_id_, in_buffer, key_id, iv,
wvcdm::kEncryptionAlgorithmAesCbc128,
&out_buffer);
EXPECT_EQ(NO_CONTENT_KEY_2, cdm_sts);
EXPECT_EQ(NO_CONTENT_KEY_3, cdm_sts);
}
TEST_F(WvGenericOperationsTest, GenericEncryptKeyNotAllowed) {

View File

@@ -395,6 +395,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
break;
case NO_CONTENT_KEY_2: *os << "NO_CONTENT_KEY_2";
break;
case NO_CONTENT_KEY_3: *os << "NO_CONTENT_KEY_3";
break;
case INSUFFICIENT_CRYPTO_RESOURCES_2:
*os << "INSUFFICIENT_CRYPTO_RESOURCES_2";
break;

View File

@@ -27,6 +27,7 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
case wvcdm::DECRYPT_NOT_READY:
case wvcdm::KEY_NOT_FOUND_IN_SESSION:
case wvcdm::NO_MATCHING_ENTITLEMENT_KEY:
case wvcdm::NO_CONTENT_KEY_3:
return android::ERROR_DRM_NO_LICENSE;
case wvcdm::NEED_PROVISIONING:
return android::ERROR_DRM_NOT_PROVISIONED;

View File

@@ -30,6 +30,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
case wvcdm::KEY_NOT_FOUND_IN_SESSION:
case wvcdm::NEED_KEY:
case wvcdm::NO_MATCHING_ENTITLEMENT_KEY:
case wvcdm::NO_CONTENT_KEY_3:
return Status::ERROR_DRM_NO_LICENSE;
case wvcdm::NEED_PROVISIONING:

View File

@@ -1224,8 +1224,8 @@ OEMCryptoResult SessionContext::SelectContentKey(
}
Key* content_key = session_keys_->Find(key_id);
if (NULL == content_key) {
LOGE("[SelectContentKey(): No key matches key id]");
return OEMCrypto_ERROR_NO_CONTENT_KEY;
LOGE("No key matches key id");
return OEMCrypto_KEY_NOT_LOADED;
}
if (LogCategoryEnabled(kLoggingTraceDecryption)) {
LOGI((" Select Key: key = " + wvcdm::b2a_hex(content_key->value()))