comparison aes.c @ 221:6ff860ccdcff libavutil

10l (aes_crypt -> av_aes_crypt)
author michael
date Wed, 17 Jan 2007 00:49:48 +0000
parents b842bcbc6880
children 998d097d926d
comparison
equal deleted inserted replaced
220:b842bcbc6880 221:6ff860ccdcff
83 addkey(a->state[1], a->state[0], a->round_key[r]); 83 addkey(a->state[1], a->state[0], a->round_key[r]);
84 } 84 }
85 subshift(a->state[0][0], s, sbox); 85 subshift(a->state[0][0], s, sbox);
86 } 86 }
87 87
88 void aes_crypt(AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt){ 88 void av_aes_crypt(AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt){
89 while(count--){ 89 while(count--){
90 addkey(a->state[1], src, a->round_key[a->rounds]); 90 addkey(a->state[1], src, a->round_key[a->rounds]);
91 if(decrypt) { 91 if(decrypt) {
92 crypt(a, 0, inv_sbox, dec_multbl); 92 crypt(a, 0, inv_sbox, dec_multbl);
93 if(iv){ 93 if(iv){
210 av_aes_init(&ad, "PI=3.141592654..", 128, 1); 210 av_aes_init(&ad, "PI=3.141592654..", 128, 1);
211 av_log_level= AV_LOG_DEBUG; 211 av_log_level= AV_LOG_DEBUG;
212 212
213 for(i=0; i<2; i++){ 213 for(i=0; i<2; i++){
214 av_aes_init(&b, rkey[i], 128, 1); 214 av_aes_init(&b, rkey[i], 128, 1);
215 aes_crypt(&b, temp, rct[i], 1, NULL, 1); 215 av_aes_crypt(&b, temp, rct[i], 1, NULL, 1);
216 for(j=0; j<16; j++) 216 for(j=0; j<16; j++)
217 if(rpt[i][j] != temp[j]) 217 if(rpt[i][j] != temp[j])
218 av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]); 218 av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]);
219 } 219 }
220 220
221 for(i=0; i<10000; i++){ 221 for(i=0; i<10000; i++){
222 for(j=0; j<16; j++){ 222 for(j=0; j<16; j++){
223 pt[j]= random(); 223 pt[j]= random();
224 } 224 }
225 {START_TIMER 225 {START_TIMER
226 aes_crypt(&ae, temp, pt, 1, NULL, 0); 226 av_aes_crypt(&ae, temp, pt, 1, NULL, 0);
227 if(!(i&(i-1))) 227 if(!(i&(i-1)))
228 av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]); 228 av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]);
229 aes_crypt(&ad, temp, temp, 1, NULL, 1); 229 av_aes_crypt(&ad, temp, temp, 1, NULL, 1);
230 STOP_TIMER("aes")} 230 STOP_TIMER("aes")}
231 for(j=0; j<16; j++){ 231 for(j=0; j<16; j++){
232 if(pt[j] != temp[j]){ 232 if(pt[j] != temp[j]){
233 av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]); 233 av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]);
234 } 234 }