DO NOT MERGE: cherry-pick: libdrm1: Use libcrypto instead of libaes.

It seems that libdrm1 was the only user of libaes.
Now libaes is no longer required and removing it saves 36 kilobytes.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Chia-chi Yeh
2009-08-06 02:28:24 +08:00
committed by Mike Lockwood
parent eccd6fdd0d
commit 188f5a7106
4 changed files with 23 additions and 25 deletions

View File

@@ -36,15 +36,15 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include/objmng \ $(LOCAL_PATH)/include/objmng \
$(LOCAL_PATH)/include/parser \ $(LOCAL_PATH)/include/parser \
$(LOCAL_PATH)/include/xml \ $(LOCAL_PATH)/include/xml \
external/aes \ external/openssl/include \
$(call include-path-for, system-core)/cutils $(call include-path-for, system-core)/cutils
LOCAL_CFLAGS := $(LOCAL_DRM_CFLAG) LOCAL_CFLAGS := $(LOCAL_DRM_CFLAG)
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libaes \ libutils \
libutils \ libcutils \
libcutils libcrypto
LOCAL_MODULE := libdrm1 LOCAL_MODULE := libdrm1
@@ -66,15 +66,14 @@ LOCAL_SRC_FILES := \
# Header files path # Header files path
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \ $(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/parser \ $(LOCAL_PATH)/include/parser \
$(JNI_H_INCLUDE) \ $(JNI_H_INCLUDE) \
$(call include-path-for, system-core)/cutils \ $(call include-path-for, system-core)/cutils
external/aes
LOCAL_SHARED_LIBRARIES := libdrm1 \ LOCAL_SHARED_LIBRARIES := libdrm1 \
libutils \ libutils \
libcutils libcutils
LOCAL_MODULE := libdrm1_jni LOCAL_MODULE := libdrm1_jni

View File

@@ -21,9 +21,9 @@
extern "C" { extern "C" {
#endif #endif
#include <openssl/aes.h>
#include <drm_common_types.h> #include <drm_common_types.h>
#include <parser_rel.h> #include <parser_rel.h>
#include <aes.h>
#ifdef DRM_DEVICE_ARCH_ARM #ifdef DRM_DEVICE_ARCH_ARM
#define ANDROID_DRM_CORE_PATH "/data/drm/rights/" #define ANDROID_DRM_CORE_PATH "/data/drm/rights/"
@@ -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 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 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 * \return
* -0 * -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. * Update the DCF data length according the CEK.

View File

@@ -22,7 +22,6 @@
#include <drm_rights_manager.h> #include <drm_rights_manager.h>
#include <drm_time.h> #include <drm_time.h>
#include <drm_decoder.h> #include <drm_decoder.h>
#include <aes.h>
#include "log.h" #include "log.h"
/** /**
@@ -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 readBytes = 0;
int32_t bufLen, piece, i, copyBytes, leftBytes; int32_t bufLen, piece, i, copyBytes, leftBytes;
int32_t aesStart, mediaStart, mediaBufOff; int32_t aesStart, mediaStart, mediaBufOff;
aes_decrypt_ctx ctx[1]; AES_KEY key;
if (FALSE == drm_getKey(s->contentID, keyValue)) if (FALSE == drm_getKey(s->contentID, keyValue))
return DRM_NO_RIGHTS; return DRM_NO_RIGHTS;
@@ -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; piece = (offset + readBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2;
mediaStart = offset % DRM_ONE_AES_BLOCK_LEN; mediaStart = offset % DRM_ONE_AES_BLOCK_LEN;
aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key);
mediaBufOff = 0; mediaBufOff = 0;
leftBytes = readBytes; leftBytes = readBytes;
@@ -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); memcpy(buf, s->rawContent + aesStart + i * DRM_ONE_AES_BLOCK_LEN, DRM_TWO_AES_BLOCK_LEN);
bufLen = 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; return DRM_MEDIA_DATA_INVALID;
if (0 != i) if (0 != i)
@@ -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; piece = (offset + leftBytes - 1) / DRM_ONE_AES_BLOCK_LEN - offset / DRM_ONE_AES_BLOCK_LEN + 2;
mediaBufOff = readBytes; mediaBufOff = readBytes;
aes_decrypt_key128(keyValue, ctx); AES_set_decrypt_key(keyValue, DRM_KEY_LEN * 8, &key);
for (i = 0; i < piece - 1; i++) { for (i = 0; i < piece - 1; i++) {
if (-1 == (res = drm_readAesData(buf, s, aesStart, DRM_TWO_AES_BLOCK_LEN))) if (-1 == (res = drm_readAesData(buf, s, aesStart, DRM_TWO_AES_BLOCK_LEN)))
@@ -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; bufLen = DRM_TWO_AES_BLOCK_LEN;
aesStart += DRM_ONE_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; return DRM_MEDIA_DATA_INVALID;
drm_discardPaddingByte(buf, &bufLen); drm_discardPaddingByte(buf, &bufLen);

View File

@@ -573,7 +573,7 @@ void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen)
return; 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]; 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; uint64_t i, len, wlen = DRM_ONE_AES_BLOCK_LEN, curLen, restLen;
@@ -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 */ if (len < 2 * DRM_ONE_AES_BLOCK_LEN) { /* The original file is less than one block in length */
len -= DRM_ONE_AES_BLOCK_LEN; len -= DRM_ONE_AES_BLOCK_LEN;
/* Decrypt from position len to position 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 */ /* Undo the CBC chaining */
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
@@ -620,7 +620,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx
Buffer += len; Buffer += len;
/* Decrypt the b2 block */ /* 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 */ if (len == 0 || len == DRM_ONE_AES_BLOCK_LEN) { /* No ciphertext stealing */
/* Unchain CBC using the previous ciphertext block in b1 */ /* Unchain CBC using the previous ciphertext block in b1 */
@@ -639,7 +639,7 @@ int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, aes_decrypt_ctx
b3[i] = buf[i]; b3[i] = buf[i];
/* Decrypt the C[N-1] block in b3 */ /* 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 */ /* Produce the last but one plaintext block by xoring with */
/* The last but two ciphertext block */ /* The last but two ciphertext block */
@@ -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) 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; int32_t len = DRM_TWO_AES_BLOCK_LEN;
if (NULL == pDcfLastData || NULL == keyValue) if (NULL == pDcfLastData || NULL == keyValue)
return FALSE; 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; return FALSE;
drm_discardPaddingByte(pDcfLastData, &len); drm_discardPaddingByte(pDcfLastData, &len);