changeset 1070:d2d9d638364b

AES ShiftRow implemented.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 23 Dec 2008 13:20:11 +0100
parents 53e67a17c67d
children f9fb8c387f8f
files viff/aes.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Mon Dec 22 15:39:41 2008 +0100
+++ b/viff/aes.py	Tue Dec 23 13:20:11 2008 +0100
@@ -116,3 +116,15 @@
 
                 row[i] = reduce(lambda x,y: x + y, 
                                 [bits[j] * 2**j for j in range(len(bits))])
+
+    def shift_row(self, state):
+        if self.n_b in [4,6]:
+            offsets = [0, 1, 2, 3]
+        else:
+            offsets = [0, 1, 3, 4]
+
+        for i, row in enumerate(state):
+            for j in range(offsets[i]):
+                row.append(row.pop(0))
+
+