comparison aes.c @ 953:567489a515b2 libavutil

Use a consistent type for multbl array function parameters.
author reimar
date Mon, 28 Jun 2010 17:11:48 +0000
parents 5d344280a1f8
children 2b38811998d1
comparison
equal deleted inserted replaced
952:e461801687c9 953:567489a515b2
59 s1[0][3]=box[s1[1][ 7]]; s1[0][ 7]=box[s1[1][11]]; s1[0][11]=box[s1[1][15]]; s1[0][15]=box[s1[1][ 3]]; 59 s1[0][3]=box[s1[1][ 7]]; s1[0][ 7]=box[s1[1][11]]; s1[0][11]=box[s1[1][15]]; s1[0][15]=box[s1[1][ 3]];
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[][256], int a, int b, int c, int d){
65 #if 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
71 } 71 }
72 72
73 static inline void mix(uint8_t state[2][4][4], uint32_t multbl[4][256], int s1, int s3){ 73 static inline void mix(uint8_t state[2][4][4], uint32_t multbl[][256], int s1, int s3){
74 ((uint32_t *)(state))[0] = mix_core(multbl, state[1][0][0], state[1][s1 ][1], state[1][2][2], state[1][s3 ][3]); 74 ((uint32_t *)(state))[0] = mix_core(multbl, state[1][0][0], state[1][s1 ][1], state[1][2][2], state[1][s3 ][3]);
75 ((uint32_t *)(state))[1] = mix_core(multbl, state[1][1][0], state[1][s3-1][1], state[1][3][2], state[1][s1-1][3]); 75 ((uint32_t *)(state))[1] = mix_core(multbl, state[1][1][0], state[1][s3-1][1], state[1][3][2], state[1][s1-1][3]);
76 ((uint32_t *)(state))[2] = mix_core(multbl, state[1][2][0], state[1][s3 ][1], state[1][0][2], state[1][s1 ][3]); 76 ((uint32_t *)(state))[2] = mix_core(multbl, state[1][2][0], state[1][s3 ][1], state[1][0][2], state[1][s1 ][3]);
77 ((uint32_t *)(state))[3] = mix_core(multbl, state[1][3][0], state[1][s1-1][1], state[1][1][2], state[1][s3-1][3]); 77 ((uint32_t *)(state))[3] = mix_core(multbl, state[1][3][0], state[1][s1-1][1], state[1][1][2], state[1][s3-1][3]);
78 } 78 }
79 79
80 static inline void crypt(AVAES *a, int s, const uint8_t *sbox, const uint32_t *multbl){ 80 static inline void crypt(AVAES *a, int s, const uint8_t *sbox, uint32_t multbl[][256]){
81 int r; 81 int r;
82 82
83 for(r=a->rounds-1; r>0; r--){ 83 for(r=a->rounds-1; r>0; r--){
84 mix(a->state, multbl, 3-s, 1+s); 84 mix(a->state, multbl, 3-s, 1+s);
85 addkey(a->state[1], a->state[0], a->round_key[r]); 85 addkey(a->state[1], a->state[0], a->round_key[r]);