[Ffmpeg-cvslog] r7490 - trunk/libavutil/aes.c

michael subversion
Sun Jan 14 20:01:17 CET 2007


Author: michael
Date: Sun Jan 14 20:01:17 2007
New Revision: 7490

Modified:
   trunk/libavutil/aes.c

Log:
dont use encode tables for decoding


Modified: trunk/libavutil/aes.c
==============================================================================
--- trunk/libavutil/aes.c	(original)
+++ trunk/libavutil/aes.c	Sun Jan 14 20:01:17 2007
@@ -75,7 +75,7 @@
 void av_aes_decrypt(AVAES *a){
     int t, r;
 
-    addkey(a->state, a->round_enc_key[a->rounds]);
+    addkey(a->state, a->round_dec_key[a->rounds]);
     for(r=a->rounds-2; r>=0; r--){
         SUBSHIFT3x((a->state[0]+1))
         SUBSHIFT2x((a->state[0]+2))
@@ -87,7 +87,7 @@
     SUBSHIFT3((a->state[0]+1), inv_sbox)
     SUBSHIFT2((a->state[0]+2), inv_sbox)
     SUBSHIFT1((a->state[0]+3), inv_sbox)
-    addkey(a->state, a->round_enc_key[0]);
+    addkey(a->state, a->round_dec_key[0]);
 }
 
 void av_aes_encrypt(AVAES *a){
@@ -183,10 +183,12 @@
         }
     }
 
-    for(i=0; i<sizeof(a->round_enc_key); i++)
-        a->round_dec_key[0][0][i]= sbox[a->round_enc_key[0][0][i]];
-    for(i=1; i<rounds; i++)
+    memcpy(a->round_dec_key, a->round_enc_key, sizeof(a->round_enc_key));
+    for(i=1; i<rounds; i++){
+        for(j=0; j<16; j++)
+            a->round_dec_key[i][0][j]= sbox[a->round_enc_key[i][0][j]];
         mix(a->round_dec_key[i], dec_multbl);
+    }
 
     return a;
 }




More information about the ffmpeg-cvslog mailing list