summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-07-03 00:46:23 +0100
committerMans Rullgard <mans@mansr.com>2011-07-03 03:08:52 +0100
commitaf2ea724951b4b12b4522b462047eebbf9566b84 (patch)
tree6741952f1d0d779a86ad0f21176aea12c0fff93b
parent5dd045ebc11933dca4d6af06e6b1e62be56802f7 (diff)
downloadffmpeg-streaming-af2ea724951b4b12b4522b462047eebbf9566b84.zip
ffmpeg-streaming-af2ea724951b4b12b4522b462047eebbf9566b84.tar.gz
aes: use direct assignments instead of memcpy() or loops
Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r--libavutil/aes.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libavutil/aes.c b/libavutil/aes.c
index fc6c416..f3f13bf 100644
--- a/libavutil/aes.c
+++ b/libavutil/aes.c
@@ -127,7 +127,7 @@ void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_,
crypt(a, 0, inv_sbox, dec_multbl);
if (iv) {
addkey(&a->state[0], &a->state[0], iv);
- memcpy(iv, src, 16);
+ *iv = *src;
}
addkey(dst, &a->state[0], &a->round_key[0]);
} else {
@@ -136,7 +136,7 @@ void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_,
crypt(a, 2, sbox, enc_multbl);
addkey(dst, &a->state[0], &a->round_key[0]);
if (iv)
- memcpy(iv, dst, 16);
+ *iv = *dst;
}
src++;
dst++;
@@ -221,15 +221,14 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
if (decrypt) {
for (i = 1; i < rounds; i++) {
av_aes_block tmp[3];
- memcpy(&tmp[2], &a->round_key[i], 16);
+ tmp[2] = a->round_key[i];
subshift(&tmp[1], 0, sbox);
mix(tmp, dec_multbl, 1, 3);
- memcpy(&a->round_key[i], &tmp[0], 16);
+ a->round_key[i] = tmp[0];
}
} else {
for (i = 0; i < (rounds + 1) >> 1; i++) {
- for (j = 0; j < 16; j++)
- FFSWAP(int, a->round_key[i].u8[j], a->round_key[rounds-i].u8[j]);
+ FFSWAP(av_aes_block, a->round_key[i], a->round_key[rounds-i]);
}
}
OpenPOWER on IntegriCloud