http://hg.viff.dk/viff/rev/936ce049980f
changeset: 1073:936ce049980f
user:      Marcel Keller <[email protected]>
date:      Fri Jan 09 15:29:40 2009 +0100
summary:   Added docstrings and asserts for shift_row and mix_column.

diffstat:

1 file changed, 12 insertions(+)
viff/aes.py |   12 ++++++++++++

diffs (29 lines):

diff -r c503c9b40df0 -r 936ce049980f viff/aes.py
--- 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):
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to