diff options
author | Chia-chi Yeh <chiachi@android.com> | 2009-08-06 02:28:24 +0800 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-08-11 21:14:09 -0400 |
commit | 188f5a71061791906572de375c5efe26cadddbae (patch) | |
tree | 261299ef173848480c75fd2e477ff8eaecead8f8 /media | |
parent | eccd6fdd0d86b8610b738fc15c707eedc00ec9dc (diff) | |
download | frameworks_base-188f5a71061791906572de375c5efe26cadddbae.zip frameworks_base-188f5a71061791906572de375c5efe26cadddbae.tar.gz frameworks_base-188f5a71061791906572de375c5efe26cadddbae.tar.bz2 |
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>
Diffstat (limited to 'media')
-rw-r--r-- | media/libdrm/mobile1/Android.mk | 17 | ||||
-rw-r--r-- | media/libdrm/mobile1/include/objmng/drm_rights_manager.h | 6 | ||||
-rw-r--r-- | media/libdrm/mobile1/src/objmng/drm_api.c | 11 | ||||
-rw-r--r-- | media/libdrm/mobile1/src/objmng/drm_rights_manager.c | 14 |
4 files changed, 23 insertions, 25 deletions
diff --git a/media/libdrm/mobile1/Android.mk b/media/libdrm/mobile1/Android.mk index 2065cd2..f105799 100644 --- a/media/libdrm/mobile1/Android.mk +++ b/media/libdrm/mobile1/Android.mk @@ -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 + libutils \ + libcutils \ + libcrypto LOCAL_MODULE := libdrm1 @@ -66,15 +66,14 @@ LOCAL_SRC_FILES := \ # Header files path LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/include/parser \ + $(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 \ - libutils \ - libcutils + libutils \ + libcutils LOCAL_MODULE := libdrm1_jni diff --git a/media/libdrm/mobile1/include/objmng/drm_rights_manager.h b/media/libdrm/mobile1/include/objmng/drm_rights_manager.h index dd2116c..d81e7a1 100644 --- a/media/libdrm/mobile1/include/objmng/drm_rights_manager.h +++ b/media/libdrm/mobile1/include/objmng/drm_rights_manager.h @@ -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/" @@ -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. diff --git a/media/libdrm/mobile1/src/objmng/drm_api.c b/media/libdrm/mobile1/src/objmng/drm_api.c index 0e453de..249cdbe 100644 --- a/media/libdrm/mobile1/src/objmng/drm_api.c +++ b/media/libdrm/mobile1/src/objmng/drm_api.c @@ -22,7 +22,6 @@ #include <drm_rights_manager.h> #include <drm_time.h> #include <drm_decoder.h> -#include <aes.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 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; @@ -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; @@ -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) @@ -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))) @@ -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); diff --git a/media/libdrm/mobile1/src/objmng/drm_rights_manager.c b/media/libdrm/mobile1/src/objmng/drm_rights_manager.c index 80901f5..df22327 100644 --- a/media/libdrm/mobile1/src/objmng/drm_rights_manager.c +++ b/media/libdrm/mobile1/src/objmng/drm_rights_manager.c @@ -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; @@ -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) @@ -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 */ @@ -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 */ @@ -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); |