From 09b16a0b17122e95917916c625f2dfd5f904abd4 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Wed, 20 Nov 2019 14:51:32 -0800 Subject: [PATCH] Correct GetDecryptHashSupport signature [ Merge of http://go/wvgerrit/89906 ] The change allows the GetDecryptHashSupport method to return an error. Bug: 144851430 Test: WV android unit/integration tests Change-Id: Ib3b95788adb21b5ed0daee51ad338f9674b04c3c --- .../cdm/core/include/crypto_session.h | 3 ++- libwvdrmengine/cdm/core/src/cdm_engine.cpp | 8 +++++-- .../cdm/core/src/crypto_session.cpp | 21 ++++++++++--------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libwvdrmengine/cdm/core/include/crypto_session.h b/libwvdrmengine/cdm/core/include/crypto_session.h index 5202513c..7f6a094b 100644 --- a/libwvdrmengine/cdm/core/include/crypto_session.h +++ b/libwvdrmengine/cdm/core/include/crypto_session.h @@ -178,7 +178,8 @@ class CryptoSession { std::string* info); virtual bool GetBuildInformation(std::string* info); - virtual uint32_t IsDecryptHashSupported(SecurityLevel security_level); + virtual bool GetDecryptHashSupport(SecurityLevel security_level, + uint32_t* hash_support); virtual CdmResponseType SetDecryptHash(uint32_t frame_number, const std::string& hash); diff --git a/libwvdrmengine/cdm/core/src/cdm_engine.cpp b/libwvdrmengine/cdm/core/src/cdm_engine.cpp index bc73fcf3..9ecbfe80 100644 --- a/libwvdrmengine/cdm/core/src/cdm_engine.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_engine.cpp @@ -665,8 +665,12 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level, } return NO_ERROR; } else if (query_token == QUERY_KEY_DECRYPT_HASH_SUPPORT) { - *query_response = - std::to_string(crypto_session->IsDecryptHashSupported(security_level)); + uint32_t hash_support = 0; + if (!crypto_session->GetDecryptHashSupport(security_level, &hash_support)) { + LOGW("GetDecryptHashSupport failed"); + return UNKNOWN_ERROR; + } + *query_response = std::to_string(hash_support); return NO_ERROR; } else if (query_token == QUERY_KEY_PROVISIONING_MODEL) { CdmClientTokenType token_type = kClientTokenUninitialized; diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index d9562cb8..5a4657bf 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -1812,26 +1812,27 @@ bool CryptoSession::GetBuildInformation(SecurityLevel security_level, return true; } -uint32_t CryptoSession::IsDecryptHashSupported(SecurityLevel security_level) { +bool CryptoSession::GetDecryptHashSupport(SecurityLevel security_level, + uint32_t* decrypt_hash_support) { LOGV("Checking if decrypt hash is supported"); RETURN_IF_UNINITIALIZED(false); + RETURN_IF_NULL(decrypt_hash_support, false); - uint32_t secure_decrypt_support; - WithOecReadLock("IsDecryptHashSupported", [&] { - secure_decrypt_support = OEMCrypto_SupportsDecryptHash(security_level); + WithOecReadLock("GetDecryptHashSupport", [&] { + *decrypt_hash_support = OEMCrypto_SupportsDecryptHash(security_level); }); - switch (secure_decrypt_support) { + switch (*decrypt_hash_support) { case OEMCrypto_Hash_Not_Supported: case OEMCrypto_CRC_Clear_Buffer: case OEMCrypto_Partner_Defined_Hash: break; default: - LOGE("OEMCrypto_SupportsDecryptHash failed: result = %d", - static_cast(secure_decrypt_support)); - secure_decrypt_support = OEMCrypto_Hash_Not_Supported; - break; + // Not flagging an error since it is only used in test + LOGW("OEMCrypto_SupportsDecryptHash unrecognized result = %d", + static_cast(*decrypt_hash_support)); + return false; } - return secure_decrypt_support; + return true; } CdmResponseType CryptoSession::SetDecryptHash(uint32_t frame_number,