comparison aes.c @ 211:3ef3f2ad70a4 libavutil

remove useless parameter
author michael
date Tue, 16 Jan 2007 16:29:01 +0000
parents dd27616bb3fe
children d31d4880105e
comparison
equal deleted inserted replaced
210:dd27616bb3fe 211:3ef3f2ad70a4
48 static inline void addkey(uint64_t state[2], uint64_t round_key[2]){ 48 static inline void addkey(uint64_t state[2], uint64_t round_key[2]){
49 state[0] ^= round_key[0]; 49 state[0] ^= round_key[0];
50 state[1] ^= round_key[1]; 50 state[1] ^= round_key[1];
51 } 51 }
52 52
53 static void subshift(uint8_t s0[4], uint8_t s1[4], uint8_t s2[4], uint8_t s3[4], uint8_t *box){ 53 static void subshift(uint8_t s0[4], uint8_t s1[4], uint8_t s3[4], uint8_t *box){
54 int t; 54 int t;
55 s0[0]=box[s0[ 0]]; s0[ 4]=box[s0[ 4]]; s0[ 8]=box[s0[ 8]]; s0[12]=box[s0[12]]; 55 s0[0]=box[s0[ 0]]; s0[ 4]=box[s0[ 4]]; s0[ 8]=box[s0[ 8]]; s0[12]=box[s0[12]];
56 t=s1[0]; s1[0]=box[s1[ 4]]; s1[ 4]=box[s1[ 8]]; s1[ 8]=box[s1[12]]; s1[12]=box[t]; 56 t=s1[0]; s1[0]=box[s1[ 4]]; s1[ 4]=box[s1[ 8]]; s1[ 8]=box[s1[12]]; s1[12]=box[t];
57 t=s2[0]; s2[0]=box[s2[ 8]]; s2[ 8]=box[ t]; t=s2[ 4]; s2[ 4]=box[s2[12]]; s2[12]=box[t]; 57 t=s0[2]; s0[2]=box[s0[10]]; s0[10]=box[ t]; t=s0[ 6]; s0[ 6]=box[s0[14]]; s0[14]=box[t];
58 t=s3[0]; s3[0]=box[s3[12]]; s3[12]=box[s3[ 8]]; s3[ 8]=box[s3[ 4]]; s3[ 4]=box[t]; 58 t=s3[0]; s3[0]=box[s3[12]]; s3[12]=box[s3[ 8]]; s3[ 8]=box[s3[ 4]]; s3[ 4]=box[t];
59 } 59 }
60 60
61 #define ROT(x,s) ((x<<s)|(x>>(32-s))) 61 #define ROT(x,s) ((x<<s)|(x>>(32-s)))
62 #if 0 62 #if 0
94 for(r=a->rounds; r>1; r--){ 94 for(r=a->rounds; r>1; r--){
95 addkey(a->state, a->round_key[r]); 95 addkey(a->state, a->round_key[r]);
96 mix2(a->state, multbl, 3-s, 1+s); 96 mix2(a->state, multbl, 3-s, 1+s);
97 } 97 }
98 addkey(a->state, a->round_key[1]); 98 addkey(a->state, a->round_key[1]);
99 subshift(a->state[0], a->state[0]+3-s, a->state[0]+2, a->state[0]+1+s, sbox); 99 subshift(a->state[0], a->state[0]+3-s, a->state[0]+1+s, sbox);
100 addkey(a->state, a->round_key[0]); 100 addkey(a->state, a->round_key[0]);
101 } 101 }
102 102
103 static void aes_decrypt(AVAES *a){ 103 static void aes_decrypt(AVAES *a){
104 crypt(a, 0, inv_sbox, dec_multbl); 104 crypt(a, 0, inv_sbox, dec_multbl);
173 } 173 }
174 } 174 }
175 175
176 if(decrypt){ 176 if(decrypt){
177 for(i=1; i<rounds; i++){ 177 for(i=1; i<rounds; i++){
178 subshift(a->round_key[i][0], a->round_key[i][0]+3, a->round_key[i][0]+2, a->round_key[i][0]+1, sbox); 178 subshift(a->round_key[i][0], a->round_key[i][0]+3, a->round_key[i][0]+1, sbox);
179 mix2(a->round_key[i], dec_multbl, 1, 3); 179 mix2(a->round_key[i], dec_multbl, 1, 3);
180 } 180 }
181 }else{ 181 }else{
182 for(i=0; i<(rounds+1)>>1; i++){ 182 for(i=0; i<(rounds+1)>>1; i++){
183 for(j=0; j<16; j++) 183 for(j=0; j<16; j++)