diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-01-14 21:30:54 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-01-14 21:30:54 +0000 |
commit | 7200f5d054421484f1326ff5e25340629154b421 (patch) | |
tree | 2b70013b598df77a420ce228bed66208ba40738a /libavutil | |
parent | 86074ce3412005a56428477695f27efeb4d7bcc3 (diff) | |
download | ffmpeg-7200f5d054421484f1326ff5e25340629154b421.tar.gz |
simplify multiply table init
Originally committed as revision 7503 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/aes.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libavutil/aes.c b/libavutil/aes.c index a10b45c6e6..d649dfa29f 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -99,15 +99,25 @@ void av_aes_encrypt(AVAES *a){ crypt(a, 2, sbox, enc_multbl); } +static void init_multbl3(uint8_t tbl[4][256][4]){ + int i, j, k; + for(k=1; k<4; k++) + for(j=0; j<256; j++) + for(i=0; i<4; i++) + tbl[k][j][i]= tbl[k-1][j][(i-1)&3]; +} + static void init_multbl2(uint8_t tbl[1024], int c[4], uint8_t *log8, uint8_t *alog8, uint8_t *sbox){ int i; for(i=0; i<1024; i++){ int x= sbox[i/4]; if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; } +#ifndef CONFIG_SMALL + init_multbl3(tbl); +#endif } - // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen AVAES *av_aes_init(uint8_t *key, int key_bits, int decrypt) { AVAES *a; @@ -136,17 +146,7 @@ AVAES *av_aes_init(uint8_t *key, int key_bits, int decrypt) { // av_log(NULL, AV_LOG_ERROR, "%d, ", log8[i]); } init_multbl2(dec_multbl[0], (int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox); -#ifndef CONFIG_SMALL - init_multbl2(dec_multbl[1], (int[4]){0xb, 0xe, 0x9, 0xd}, log8, alog8, inv_sbox); - init_multbl2(dec_multbl[2], (int[4]){0xd, 0xb, 0xe, 0x9}, log8, alog8, inv_sbox); - init_multbl2(dec_multbl[3], (int[4]){0x9, 0xd, 0xb, 0xe}, log8, alog8, inv_sbox); -#endif init_multbl2(enc_multbl[0], (int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox); -#ifndef CONFIG_SMALL - init_multbl2(enc_multbl[1], (int[4]){0x3, 0x2, 0x1, 0x1}, log8, alog8, sbox); - init_multbl2(enc_multbl[2], (int[4]){0x1, 0x3, 0x2, 0x1}, log8, alog8, sbox); - init_multbl2(enc_multbl[3], (int[4]){0x1, 0x1, 0x3, 0x2}, log8, alog8, sbox); -#endif } if(key_bits!=128 && key_bits!=192 && key_bits!=256) |