Refactor OEMCrypto_SetDecryptHash
The current implementation of OEMCrypto_SetDecryptHash gives developers flexibility to use different types of hashes. However, all the implementations we have seen thus far use crc32. Because of this, crc32 should be sufficient and we can refactor OEMCrypto_SetDecryptHash to only use the crc32 hash. Bug: 287706586 Change-Id: I4aaa253b2656dfd9c984f77dfb08fe160b23b47c
This commit is contained in:
@@ -2569,10 +2569,15 @@ CdmResponseType CryptoSession::SetDecryptHash(uint32_t frame_number,
|
||||
const std::string& hash) {
|
||||
LOGV("Setting decrypt hash");
|
||||
OEMCryptoResult sts;
|
||||
RETURN_IF_NOT_OPEN(CRYPTO_SESSION_NOT_OPEN);
|
||||
if (hash.size() != sizeof(uint32_t)) {
|
||||
LOGE("Unsupported hash size: hash_size = %zu, expected = %zu", hash.size(),
|
||||
sizeof(uint32_t));
|
||||
return CdmResponseType(UNKNOWN_ERROR);
|
||||
}
|
||||
WithOecSessionLock("SetDecryptHash", [&] {
|
||||
sts = OEMCrypto_SetDecryptHash(
|
||||
oec_session_id_, frame_number,
|
||||
reinterpret_cast<const uint8_t*>(hash.data()), hash.size());
|
||||
const uint32_t crc32 = *reinterpret_cast<const uint32_t*>(hash.data());
|
||||
sts = OEMCrypto_SetDecryptHash(oec_session_id_, frame_number, crc32);
|
||||
metrics_->oemcrypto_set_decrypt_hash_.Increment(sts);
|
||||
});
|
||||
|
||||
|
||||
@@ -214,8 +214,7 @@ typedef uint32_t (*L1_ResourceRatingTier_t)(void);
|
||||
typedef uint32_t (*L1_SupportsDecryptHash_t)(void);
|
||||
typedef OEMCryptoResult (*L1_SetDecryptHash_t)(OEMCrypto_SESSION session,
|
||||
uint32_t frame_number,
|
||||
const uint8_t* hash,
|
||||
size_t hash_length);
|
||||
uint32_t crc32);
|
||||
typedef OEMCryptoResult (*L1_GetHashErrorCode_t)(OEMCrypto_SESSION session,
|
||||
uint32_t* failed_frame_number);
|
||||
typedef OEMCryptoResult (*L1_AllocateSecureBuffer_t)(
|
||||
@@ -2704,16 +2703,14 @@ extern "C" size_t OEMCrypto_MaximumUsageTableHeaderSize() {
|
||||
|
||||
extern "C" OEMCryptoResult OEMCrypto_SetDecryptHash(OEMCrypto_SESSION session,
|
||||
uint32_t frame_number,
|
||||
const uint8_t* hash,
|
||||
size_t hash_length) {
|
||||
uint32_t crc32) {
|
||||
if (!gAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||
LevelSession pair = gAdapter->GetSession(session);
|
||||
if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION;
|
||||
if (pair.fcn->SetDecryptHash == nullptr) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return pair.fcn->SetDecryptHash(pair.session, frame_number, hash,
|
||||
hash_length);
|
||||
return pair.fcn->SetDecryptHash(pair.session, frame_number, crc32);
|
||||
}
|
||||
|
||||
extern "C" OEMCryptoResult OEMCrypto_GetHashErrorCode(
|
||||
|
||||
Reference in New Issue
Block a user