viff

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 diff
     1.1 --- a/viff/aes.py	Fri Jan 09 14:22:58 2009 +0100
     1.2 +++ b/viff/aes.py	Fri Jan 09 15:29:40 2009 +0100
     1.3 @@ -114,6 +114,12 @@
     1.4                                  [bits[j] * 2**j for j in range(len(bits))])
     1.5  
     1.6      def shift_row(self, state):
     1.7 +        """AES ShiftRow.
     1.8 +
     1.9 +        State should be a list of 4 rows."""
    1.10 +
    1.11 +        assert len(state) == 4, "Wrong state size."
    1.12 +
    1.13          if self.n_b in [4,6]:
    1.14              offsets = [0, 1, 2, 3]
    1.15          else:
    1.16 @@ -136,6 +142,12 @@
    1.17      C = Matrix(C)
    1.18  
    1.19      def mix_column(self, state):
    1.20 +        """Rijndael MixColumn.
    1.21 +
    1.22 +        Input should be a list of 4 rows."""
    1.23 +
    1.24 +        assert len(state) == 4, "Wrong state size."
    1.25 +
    1.26          state[:] = (AES.C * Matrix(state)).rows
    1.27  
    1.28      def add_round_key(self, state, round_key):