Loading media/libdrm/mobile1/Android.mk +8 −9 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include/objmng \ $(LOCAL_PATH)/include/parser \ $(LOCAL_PATH)/include/xml \ external/aes \ external/openssl/include \ $(call include-path-for, system-core)/cutils LOCAL_CFLAGS := $(LOCAL_DRM_CFLAG) LOCAL_SHARED_LIBRARIES := \ libaes \ libutils \ libcutils libcutils \ libcrypto LOCAL_MODULE := libdrm1 Loading @@ -68,8 +68,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/include/parser \ $(JNI_H_INCLUDE) \ $(call include-path-for, system-core)/cutils \ external/aes $(call include-path-for, system-core)/cutils LOCAL_SHARED_LIBRARIES := libdrm1 \ Loading media/libdrm/mobile1/include/objmng/drm_rights_manager.h +3 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ extern "C" { #endif #include <openssl/aes.h> #include <drm_common_types.h> #include <parser_rel.h> #include <aes.h> #ifdef DRM_DEVICE_ARCH_ARM #define ANDROID_DRM_CORE_PATH "/data/drm/rights/" Loading Loading @@ -141,12 +141,12 @@ void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen); * * \param Buffer The buffer to decrypted and also used to save the output data. * \param BufferLen The length of the buffer data and also save the output data length. * \param ctx The structure of the CEK. * \param key The structure of the CEK. * * \return * -0 */ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx ctx[1]); int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key); /** * Update the DCF data length according the CEK. Loading media/libdrm/mobile1/src/objmng/drm_api.c +5 −6 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <drm_rights_manager.h> #include <drm_time.h> #include <drm_decoder.h> #include <aes.h> #include "log.h" /** Loading Loading @@ -1578,7 +1577,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t int32_t readBytes = 0; int32_t bufLen, piece, i, copyBytes, leftBytes; int32_t aesStart, mediaStart, mediaBufOff; aes_decrypt_ctx ctx[1]; AES_KEY key; if (FALSE == drm_getKey(s->contentID, keyValue)) return DRM_NO_RIGHTS; Loading @@ -1600,7 +1599,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t piece = (offset + readBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2; mediaStart = offset % DRM_ONE_AES_BLOCK_LEN; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); mediaBufOff = 0; leftBytes = readBytes; Loading @@ -1608,7 +1607,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t memcpy(buf, s->rawContent + aesStart + i * DRM_ONE_AES_BLOCK_LEN, DRM_TWO_AES_BLOCK_LEN); bufLen = DRM_TWO_AES_BLOCK_LEN; if (drm_aesDecBuffer(buf, &bufLen, ctx) < 0) if (drm_aesDecBuffer(buf, &bufLen, &key) < 0) return DRM_MEDIA_DATA_INVALID; if (0 != i) Loading Loading @@ -1651,7 +1650,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t piece = (offset + leftBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2; mediaBufOff = readBytes; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); for (i = 0; i < piece - 1; i++) { if (-1 == (res = drm_readAesData(buf, s, aesStart, DRM_TWO_AES_BLOCK_LEN))) Loading @@ -1663,7 +1662,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t bufLen = DRM_TWO_AES_BLOCK_LEN; aesStart += DRM_ONE_AES_BLOCK_LEN; if (drm_aesDecBuffer(buf, &bufLen, ctx) < 0) if (drm_aesDecBuffer(buf, &bufLen, &key) < 0) return DRM_MEDIA_DATA_INVALID; drm_discardPaddingByte(buf, &bufLen); Loading media/libdrm/mobile1/src/objmng/drm_rights_manager.c +7 −7 Original line number Diff line number Diff line Loading @@ -573,7 +573,7 @@ void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen) return; } int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx ctx[1]) int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key) { uint8_t dbuf[3 * DRM_ONE_AES_BLOCK_LEN], buf[DRM_ONE_AES_BLOCK_LEN]; uint64_t i, len, wlen = DRM_ONE_AES_BLOCK_LEN, curLen, restLen; Loading @@ -596,7 +596,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx if (len < 2 * DRM_ONE_AES_BLOCK_LEN) { /* The original file is less than one block in length */ len -= DRM_ONE_AES_BLOCK_LEN; /* Decrypt from position len to position len + DRM_ONE_AES_BLOCK_LEN */ aes_decrypt((dbuf + len), (dbuf + len), ctx); AES_decrypt((dbuf + len), (dbuf + len), key); /* Undo the CBC chaining */ for (i = 0; i < len; ++i) Loading @@ -620,7 +620,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx Buffer += len; /* Decrypt the b2 block */ aes_decrypt((uint8_t *)b2, buf, ctx); AES_decrypt((uint8_t *)b2, buf, key); if (len == 0 || len == DRM_ONE_AES_BLOCK_LEN) { /* No ciphertext stealing */ /* Unchain CBC using the previous ciphertext block in b1 */ Loading @@ -639,7 +639,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx b3[i] = buf[i]; /* Decrypt the C[N-1] block in b3 */ aes_decrypt((uint8_t *)b3, (uint8_t *)b3, ctx); AES_decrypt((uint8_t *)b3, (uint8_t *)b3, key); /* Produce the last but one plaintext block by xoring with */ /* The last but two ciphertext block */ Loading Loading @@ -669,15 +669,15 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx int32_t drm_updateDcfDataLen(uint8_t* pDcfLastData, uint8_t* keyValue, int32_t* moreBytes) { aes_decrypt_ctx ctx[1]; AES_KEY key; int32_t len = DRM_TWO_AES_BLOCK_LEN; if (NULL == pDcfLastData || NULL == keyValue) return FALSE; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); if (drm_aesDecBuffer(pDcfLastData, &len, ctx) < 0) if (drm_aesDecBuffer(pDcfLastData, &len, &key) < 0) return FALSE; drm_discardPaddingByte(pDcfLastData, &len); Loading Loading
media/libdrm/mobile1/Android.mk +8 −9 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include/objmng \ $(LOCAL_PATH)/include/parser \ $(LOCAL_PATH)/include/xml \ external/aes \ external/openssl/include \ $(call include-path-for, system-core)/cutils LOCAL_CFLAGS := $(LOCAL_DRM_CFLAG) LOCAL_SHARED_LIBRARIES := \ libaes \ libutils \ libcutils libcutils \ libcrypto LOCAL_MODULE := libdrm1 Loading @@ -68,8 +68,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/include/parser \ $(JNI_H_INCLUDE) \ $(call include-path-for, system-core)/cutils \ external/aes $(call include-path-for, system-core)/cutils LOCAL_SHARED_LIBRARIES := libdrm1 \ Loading
media/libdrm/mobile1/include/objmng/drm_rights_manager.h +3 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ extern "C" { #endif #include <openssl/aes.h> #include <drm_common_types.h> #include <parser_rel.h> #include <aes.h> #ifdef DRM_DEVICE_ARCH_ARM #define ANDROID_DRM_CORE_PATH "/data/drm/rights/" Loading Loading @@ -141,12 +141,12 @@ void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen); * * \param Buffer The buffer to decrypted and also used to save the output data. * \param BufferLen The length of the buffer data and also save the output data length. * \param ctx The structure of the CEK. * \param key The structure of the CEK. * * \return * -0 */ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx ctx[1]); int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key); /** * Update the DCF data length according the CEK. Loading
media/libdrm/mobile1/src/objmng/drm_api.c +5 −6 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <drm_rights_manager.h> #include <drm_time.h> #include <drm_decoder.h> #include <aes.h> #include "log.h" /** Loading Loading @@ -1578,7 +1577,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t int32_t readBytes = 0; int32_t bufLen, piece, i, copyBytes, leftBytes; int32_t aesStart, mediaStart, mediaBufOff; aes_decrypt_ctx ctx[1]; AES_KEY key; if (FALSE == drm_getKey(s->contentID, keyValue)) return DRM_NO_RIGHTS; Loading @@ -1600,7 +1599,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t piece = (offset + readBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2; mediaStart = offset % DRM_ONE_AES_BLOCK_LEN; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); mediaBufOff = 0; leftBytes = readBytes; Loading @@ -1608,7 +1607,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t memcpy(buf, s->rawContent + aesStart + i * DRM_ONE_AES_BLOCK_LEN, DRM_TWO_AES_BLOCK_LEN); bufLen = DRM_TWO_AES_BLOCK_LEN; if (drm_aesDecBuffer(buf, &bufLen, ctx) < 0) if (drm_aesDecBuffer(buf, &bufLen, &key) < 0) return DRM_MEDIA_DATA_INVALID; if (0 != i) Loading Loading @@ -1651,7 +1650,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t piece = (offset + leftBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2; mediaBufOff = readBytes; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); for (i = 0; i < piece - 1; i++) { if (-1 == (res = drm_readAesData(buf, s, aesStart, DRM_TWO_AES_BLOCK_LEN))) Loading @@ -1663,7 +1662,7 @@ static int32_t drm_readAesContent(T_DRM_Session_Node* s, int32_t offset, uint8_t bufLen = DRM_TWO_AES_BLOCK_LEN; aesStart += DRM_ONE_AES_BLOCK_LEN; if (drm_aesDecBuffer(buf, &bufLen, ctx) < 0) if (drm_aesDecBuffer(buf, &bufLen, &key) < 0) return DRM_MEDIA_DATA_INVALID; drm_discardPaddingByte(buf, &bufLen); Loading
media/libdrm/mobile1/src/objmng/drm_rights_manager.c +7 −7 Original line number Diff line number Diff line Loading @@ -573,7 +573,7 @@ void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen) return; } int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx ctx[1]) int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key) { uint8_t dbuf[3 * DRM_ONE_AES_BLOCK_LEN], buf[DRM_ONE_AES_BLOCK_LEN]; uint64_t i, len, wlen = DRM_ONE_AES_BLOCK_LEN, curLen, restLen; Loading @@ -596,7 +596,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx if (len < 2 * DRM_ONE_AES_BLOCK_LEN) { /* The original file is less than one block in length */ len -= DRM_ONE_AES_BLOCK_LEN; /* Decrypt from position len to position len + DRM_ONE_AES_BLOCK_LEN */ aes_decrypt((dbuf + len), (dbuf + len), ctx); AES_decrypt((dbuf + len), (dbuf + len), key); /* Undo the CBC chaining */ for (i = 0; i < len; ++i) Loading @@ -620,7 +620,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx Buffer += len; /* Decrypt the b2 block */ aes_decrypt((uint8_t *)b2, buf, ctx); AES_decrypt((uint8_t *)b2, buf, key); if (len == 0 || len == DRM_ONE_AES_BLOCK_LEN) { /* No ciphertext stealing */ /* Unchain CBC using the previous ciphertext block in b1 */ Loading @@ -639,7 +639,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx b3[i] = buf[i]; /* Decrypt the C[N-1] block in b3 */ aes_decrypt((uint8_t *)b3, (uint8_t *)b3, ctx); AES_decrypt((uint8_t *)b3, (uint8_t *)b3, key); /* Produce the last but one plaintext block by xoring with */ /* The last but two ciphertext block */ Loading Loading @@ -669,15 +669,15 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx int32_t drm_updateDcfDataLen(uint8_t* pDcfLastData, uint8_t* keyValue, int32_t* moreBytes) { aes_decrypt_ctx ctx[1]; AES_KEY key; int32_t len = DRM_TWO_AES_BLOCK_LEN; if (NULL == pDcfLastData || NULL == keyValue) return FALSE; aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key); if (drm_aesDecBuffer(pDcfLastData, &len, ctx) < 0) if (drm_aesDecBuffer(pDcfLastData, &len, &key) < 0) return FALSE; drm_discardPaddingByte(pDcfLastData, &len); Loading