changeset 1073:936ce049980f

Added docstrings and asserts for shift_row and mix_column.
author Marcel Keller <mkeller@cs.au.dk>
date Fri, 09 Jan 2009 15:29:40 +0100
parents c503c9b40df0
children 64052822e204
files viff/aes.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Fri Jan 09 14:22:58 2009 +0100
+++ b/viff/aes.py	Fri Jan 09 15:29:40 2009 +0100
@@ -114,6 +114,12 @@
                                 [bits[j] * 2**j for j in range(len(bits))])
 
     def shift_row(self, state):
+        """AES ShiftRow.
+
+        State should be a list of 4 rows."""
+
+        assert len(state) == 4, "Wrong state size."
+
         if self.n_b in [4,6]:
             offsets = [0, 1, 2, 3]
         else:
@@ -136,6 +142,12 @@
     C = Matrix(C)
 
     def mix_column(self, state):
+        """Rijndael MixColumn.
+
+        Input should be a list of 4 rows."""
+
+        assert len(state) == 4, "Wrong state size."
+
         state[:] = (AES.C * Matrix(state)).rows
 
     def add_round_key(self, state, round_key):