http://hg.viff.dk/viff/rev/50056a810951
changeset: 1097:50056a810951
user:      Marcel Keller <[email protected]>
date:      Fri Jan 30 14:50:47 2009 +0100
summary:   Optimization: Use lin_comb() instead of Matrix class in mix_column().

diffstat:

1 file changed, 9 insertions(+), 2 deletions(-)
viff/aes.py |   11 +++++++++--

diffs (27 lines):

diff -r 072920ec7f69 -r 50056a810951 viff/aes.py
--- a/viff/aes.py       Fri Jan 30 14:19:54 2009 +0100
+++ b/viff/aes.py       Fri Jan 30 14:50:47 2009 +0100
@@ -202,14 +202,21 @@
 
     C = Matrix(C)
 
-    def mix_column(self, state):
+    def mix_column(self, state, use_lin_comb=True):
         """Rijndael MixColumn.
 
         Input should be a list of 4 rows."""
 
         assert len(state) == 4, "Wrong state size."
 
-        state[:] = (AES.C * Matrix(state)).rows
+        if (use_lin_comb):
+            columns = zip(*state)
+
+            for i, row in enumerate(state):
+                row[:] = [self.runtime.lin_comb(AES.C.rows[i], column)
+                          for column in columns]
+        else:
+            state[:] = (AES.C * Matrix(state)).rows
 
     def add_round_key(self, state, round_key):
         """Rijndael AddRoundKey.
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to