diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index 60c9f357..7966a39a 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -212,9 +212,10 @@ typedef uint32_t (*L1_GetAnalogOutputFlags_t)(void); typedef const char* (*L1_BuildInformation_V16_t)(void); 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, - uint32_t crc32); +typedef OEMCryptoResult (*L1_SetDecryptHash_V18_t)(OEMCrypto_SESSION session, + uint32_t frame_number, + const uint8_t* hash, + size_t hash_length); typedef OEMCryptoResult (*L1_GetHashErrorCode_t)(OEMCrypto_SESSION session, uint32_t* failed_frame_number); typedef OEMCryptoResult (*L1_AllocateSecureBuffer_t)( @@ -314,6 +315,9 @@ typedef OEMCryptoResult (*L1_Generic_Verify_t)( typedef OEMCryptoResult (*L1_GetSignatureHashAlgorithm_t)( OEMCrypto_SESSION session, OEMCrypto_SignatureHashAlgorithm* algorithm); typedef OEMCryptoResult (*L1_EnterTestMode_t)(void); +typedef OEMCryptoResult (*L1_SetDecryptHash_t)(OEMCrypto_SESSION session, + uint32_t frame_number, + uint32_t crc32); struct FunctionPointers { wvcdm::CdmSecurityLevel security_level; @@ -382,7 +386,7 @@ struct FunctionPointers { L1_BuildInformation_V16_t BuildInformation_V16; L1_ResourceRatingTier_t ResourceRatingTier; L1_SupportsDecryptHash_t SupportsDecryptHash; - L1_SetDecryptHash_t SetDecryptHash; + L1_SetDecryptHash_V18_t SetDecryptHash_V18; L1_GetHashErrorCode_t GetHashErrorCode; L1_AllocateSecureBuffer_t AllocateSecureBuffer; L1_FreeSecureBuffer_t FreeSecureBuffer; @@ -408,7 +412,7 @@ struct FunctionPointers { L1_GenerateOTARequest_t GenerateOTARequest; L1_ProcessOTAKeybox_t ProcessOTAKeybox; - // new v18 functions. + // New v18 functions. L1_GetDeviceInformation_t GetDeviceInformation; L1_GetDeviceSignedCsrPayload_t GetDeviceSignedCsrPayload; L1_GetKeyHandle_t GetKeyHandle; @@ -419,6 +423,9 @@ struct FunctionPointers { L1_Generic_Verify_t Generic_Verify; L1_GetSignatureHashAlgorithm_t GetSignatureHashAlgorithm; L1_EnterTestMode_t EnterTestMode; + + // New v19 functions. + L1_SetDecryptHash_t SetDecryptHash; }; // The WatchDog looks after a worker thread that is trying to initialize L3. @@ -996,7 +1003,7 @@ class Adapter { LOOKUP( 9, 12, UpdateUsageTable, OEMCrypto_UpdateUsageTable); LOOKUP_ALL( 8, WrapKeybox, OEMCrypto_WrapKeybox); LOOKUP_ALL(15, SupportsDecryptHash, OEMCrypto_SupportsDecryptHash); - LOOKUP_ALL(15, SetDecryptHash, OEMCrypto_SetDecryptHash); + LOOKUP(15, 18, SetDecryptHash_V18, OEMCrypto_SetDecryptHash_V18); LOOKUP_ALL(15, GetHashErrorCode, OEMCrypto_GetHashErrorCode); LOOKUP_ALL(16, AllocateSecureBuffer, OEMCrypto_AllocateSecureBuffer); LOOKUP_ALL(16, FreeSecureBuffer, OEMCrypto_FreeSecureBuffer); @@ -1033,6 +1040,8 @@ class Adapter { LOOKUP_ALL(18, GetSignatureHashAlgorithm, OEMCrypto_GetSignatureHashAlgorithm); LOOKUP_ALL(18, EnterTestMode, OEMCrypto_EnterTestMode); + LOOKUP_ALL(19, SetDecryptHash, OEMCrypto_SetDecryptHash); + // clang-format on // There was a mistake in version 16.3 of the header that did not rename @@ -2707,10 +2716,18 @@ extern "C" OEMCryptoResult OEMCrypto_SetDecryptHash(OEMCrypto_SESSION session, 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; + if (pair.fcn->SetDecryptHash != nullptr) { + return pair.fcn->SetDecryptHash(pair.session, frame_number, crc32); } - return pair.fcn->SetDecryptHash(pair.session, frame_number, crc32); + if (pair.fcn->SetDecryptHash_V18 != nullptr) { + // Vendor-specific hashes will fail, but this change was brought + // about because there were no known users of anything other than + // CRC-32. + return pair.fcn->SetDecryptHash_V18( + pair.session, frame_number, reinterpret_cast(&crc32), + sizeof(crc32)); + } + return OEMCrypto_ERROR_NOT_IMPLEMENTED; } extern "C" OEMCryptoResult OEMCrypto_GetHashErrorCode(