summaryrefslogtreecommitdiff
path: root/libavformat/asfcrypt.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-09-16 11:06:55 +0200
committerHendrik Leppkes <h.leppkes@gmail.com>2015-09-16 11:06:55 +0200
commit182550e42c02b16ecb7fd2a77ea532c830c8ce78 (patch)
tree5159b0909fa5cd7b5413cd16835bffaf8896ba6b /libavformat/asfcrypt.c
parentcbbd906be6150be38dfc14b6bc67dcac8da8aea4 (diff)
parent10de408738d28ab17aa5c1fdccd809b0637c12d5 (diff)
Merge commit '10de408738d28ab17aa5c1fdccd809b0637c12d5'
* commit '10de408738d28ab17aa5c1fdccd809b0637c12d5': lavf: Update to the new crypto API Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavformat/asfcrypt.c')
-rw-r--r--libavformat/asfcrypt.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c
index a402758d0a..221a8a89bc 100644
--- a/libavformat/asfcrypt.c
+++ b/libavformat/asfcrypt.c
@@ -146,8 +146,8 @@ static uint64_t multiswap_dec(const uint32_t keys[12],
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
{
- struct AVDES des;
- struct AVRC4 rc4;
+ struct AVDES *des;
+ struct AVRC4 *rc4;
int num_qwords = len >> 3;
uint8_t *qwords = data;
uint64_t rc4buff[8] = { 0 };
@@ -160,19 +160,26 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
data[i] ^= key[i];
return;
}
+ des = av_des_alloc();
+ rc4 = av_rc4_alloc();
+ if (!des || !rc4) {
+ av_freep(&des);
+ av_freep(&rc4);
+ return;
+ }
- av_rc4_init(&rc4, key, 12 * 8, 1);
- av_rc4_crypt(&rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
+ av_rc4_init(rc4, key, 12 * 8, 1);
+ av_rc4_crypt(rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
multiswap_init((uint8_t *)rc4buff, ms_keys);
packetkey = AV_RN64(&qwords[num_qwords * 8 - 8]);
packetkey ^= rc4buff[7];
- av_des_init(&des, key + 12, 64, 1);
- av_des_crypt(&des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 1);
+ av_des_init(des, key + 12, 64, 1);
+ av_des_crypt(des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 1);
packetkey ^= rc4buff[6];
- av_rc4_init(&rc4, (uint8_t *)&packetkey, 64, 1);
- av_rc4_crypt(&rc4, data, data, len, NULL, 1);
+ av_rc4_init(rc4, (uint8_t *)&packetkey, 64, 1);
+ av_rc4_crypt(rc4, data, data, len, NULL, 1);
ms_state = 0;
for (i = 0; i < num_qwords - 1; i++, qwords += 8)
@@ -182,4 +189,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
packetkey = av_le2ne64(packetkey);
packetkey = multiswap_dec(ms_keys, ms_state, packetkey);
AV_WL64(qwords, packetkey);
+
+ av_free(rc4);
+ av_free(des);
}