Mercurial > libavutil.hg
comparison aes.c @ 603:880c6441f56a libavutil
Change semantic of CONFIG_*, HAVE_* and ARCH_*.
They are now always defined to either 0 or 1.
author | aurel |
---|---|
date | Tue, 13 Jan 2009 23:44:16 +0000 |
parents | cf0184d7d6d7 |
children | 0a51400a64c9 |
comparison
equal
deleted
inserted
replaced
602:0b84593767d8 | 603:880c6441f56a |
---|---|
37 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 | 37 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 |
38 }; | 38 }; |
39 | 39 |
40 static uint8_t sbox[256]; | 40 static uint8_t sbox[256]; |
41 static uint8_t inv_sbox[256]; | 41 static uint8_t inv_sbox[256]; |
42 #ifdef CONFIG_SMALL | 42 #if CONFIG_SMALL |
43 static uint32_t enc_multbl[1][256]; | 43 static uint32_t enc_multbl[1][256]; |
44 static uint32_t dec_multbl[1][256]; | 44 static uint32_t dec_multbl[1][256]; |
45 #else | 45 #else |
46 static uint32_t enc_multbl[4][256]; | 46 static uint32_t enc_multbl[4][256]; |
47 static uint32_t dec_multbl[4][256]; | 47 static uint32_t dec_multbl[4][256]; |
60 s0[0][2]=box[s0[1][10]]; s0[0][10]=box[s0[1][ 2]]; s0[0][ 6]=box[s0[1][14]]; s0[0][14]=box[s0[1][ 6]]; | 60 s0[0][2]=box[s0[1][10]]; s0[0][10]=box[s0[1][ 2]]; s0[0][ 6]=box[s0[1][14]]; s0[0][14]=box[s0[1][ 6]]; |
61 s3[0][1]=box[s3[1][13]]; s3[0][13]=box[s3[1][ 9]]; s3[0][ 9]=box[s3[1][ 5]]; s3[0][ 5]=box[s3[1][ 1]]; | 61 s3[0][1]=box[s3[1][13]]; s3[0][13]=box[s3[1][ 9]]; s3[0][ 9]=box[s3[1][ 5]]; s3[0][ 5]=box[s3[1][ 1]]; |
62 } | 62 } |
63 | 63 |
64 static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){ | 64 static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){ |
65 #ifdef CONFIG_SMALL | 65 #if CONFIG_SMALL |
66 #define ROT(x,s) ((x<<s)|(x>>(32-s))) | 66 #define ROT(x,s) ((x<<s)|(x>>(32-s))) |
67 return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); | 67 return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); |
68 #else | 68 #else |
69 return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d]; | 69 return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d]; |
70 #endif | 70 #endif |
112 int i, j; | 112 int i, j; |
113 for(i=0; i<1024; i++){ | 113 for(i=0; i<1024; i++){ |
114 int x= sbox[i>>2]; | 114 int x= sbox[i>>2]; |
115 if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; | 115 if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ]; |
116 } | 116 } |
117 #ifndef CONFIG_SMALL | 117 #if !CONFIG_SMALL |
118 for(j=256; j<1024; j++) | 118 for(j=256; j<1024; j++) |
119 for(i=0; i<4; i++) | 119 for(i=0; i<4; i++) |
120 tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024]; | 120 tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024]; |
121 #endif | 121 #endif |
122 } | 122 } |