changeset 1071:f9fb8c387f8f

AES MixColumn implemented.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 23 Dec 2008 16:28:37 +0100
parents d2d9d638364b
children c503c9b40df0
files viff/aes.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Tue Dec 23 13:20:11 2008 +0100
+++ b/viff/aes.py	Tue Dec 23 16:28:37 2008 +0100
@@ -127,4 +127,18 @@
             for j in range(offsets[i]):
                 row.append(row.pop(0))
 
-    
+    # matrix for mix_column
+    C = [[2, 3, 1, 1],
+         [1, 2, 3, 1],
+         [1, 1, 2, 3],
+         [3, 1, 1, 2]]
+
+    for row in C:
+        for i in xrange(len(row)):
+            row[i] = GF256(row[i])
+
+    C = Matrix(C)
+
+    def mix_column(self, state):
+        state[:] = (AES.C * Matrix(state)).rows
+