From 7f27e5a2663833828da97d2bfc8ddad0677afe0d Mon Sep 17 00:00:00 2001 From: "John W. Bruce" Date: Mon, 10 Apr 2017 16:49:44 -0700 Subject: [PATCH] Always Report OEMCrypto_ERROR_KEY_EXPIRED as NEED_KEY (This is a merge of wvgerrit/25422) OEMCrypto_ERROR_KEY_EXPIRED was not always being reported to the higher layers as a NEED_KEY error, which could cause inconsistent error handling. Bug: 28294273 Test: Unit tests Change-Id: Idf5642ea0f0ba915bc1f53025a1f14691d142aed --- .../cdm/core/src/crypto_session.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index 108356ed..80cab2e6 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -1631,8 +1631,9 @@ CdmResponseType CryptoSession::GenericEncrypt(const std::string& in_buffer, if (OEMCrypto_SUCCESS != sts) { LOGE("GenericEncrypt: OEMCrypto_Generic_Encrypt err=%d", sts); - if (OEMCrypto_ERROR_KEY_EXPIRED == sts || - OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { + if (OEMCrypto_ERROR_KEY_EXPIRED == sts) { + return NEED_KEY; + } else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { return KEY_NOT_FOUND_3; } else { return UNKNOWN_ERROR; @@ -1680,8 +1681,9 @@ CdmResponseType CryptoSession::GenericDecrypt(const std::string& in_buffer, if (OEMCrypto_SUCCESS != sts) { LOGE("GenericDecrypt: OEMCrypto_Generic_Decrypt err=%d", sts); - if (OEMCrypto_ERROR_KEY_EXPIRED == sts || - OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { + if (OEMCrypto_ERROR_KEY_EXPIRED == sts) { + return NEED_KEY; + } else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { return KEY_NOT_FOUND_4; } else { return UNKNOWN_ERROR; @@ -1742,8 +1744,9 @@ CdmResponseType CryptoSession::GenericSign(const std::string& message, } LOGE("GenericSign: OEMCrypto_Generic_Sign err=%d", sts); - if (OEMCrypto_ERROR_KEY_EXPIRED == sts || - OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { + if (OEMCrypto_ERROR_KEY_EXPIRED == sts) { + return NEED_KEY; + } else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { return KEY_NOT_FOUND_5; } else { return UNKNOWN_ERROR; @@ -1781,8 +1784,9 @@ CdmResponseType CryptoSession::GenericVerify(const std::string& message, if (OEMCrypto_SUCCESS != sts) { LOGE("GenericVerify: OEMCrypto_Generic_Verify err=%d", sts); - if (OEMCrypto_ERROR_KEY_EXPIRED == sts || - OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { + if (OEMCrypto_ERROR_KEY_EXPIRED == sts) { + return NEED_KEY; + } else if (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) { return KEY_NOT_FOUND_6; } else { return UNKNOWN_ERROR;