viff

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 diff
     1.1 --- a/viff/aes.py	Mon Dec 22 15:39:41 2008 +0100
     1.2 +++ b/viff/aes.py	Tue Dec 23 13:20:11 2008 +0100
     1.3 @@ -116,3 +116,15 @@
     1.4  
     1.5                  row[i] = reduce(lambda x,y: x + y, 
     1.6                                  [bits[j] * 2**j for j in range(len(bits))])
     1.7 +
     1.8 +    def shift_row(self, state):
     1.9 +        if self.n_b in [4,6]:
    1.10 +            offsets = [0, 1, 2, 3]
    1.11 +        else:
    1.12 +            offsets = [0, 1, 3, 4]
    1.13 +
    1.14 +        for i, row in enumerate(state):
    1.15 +            for j in range(offsets[i]):
    1.16 +                row.append(row.pop(0))
    1.17 +
    1.18 +