viff

changeset 1071:f9fb8c387f8f

AES MixColumn implemented.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 23 Dec 2008 16:28:37 +0100
parents d2d9d638364b
children c503c9b40df0
files viff/aes.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Tue Dec 23 13:20:11 2008 +0100
     1.2 +++ b/viff/aes.py	Tue Dec 23 16:28:37 2008 +0100
     1.3 @@ -127,4 +127,18 @@
     1.4              for j in range(offsets[i]):
     1.5                  row.append(row.pop(0))
     1.6  
     1.7 -    
     1.8 +    # matrix for mix_column
     1.9 +    C = [[2, 3, 1, 1],
    1.10 +         [1, 2, 3, 1],
    1.11 +         [1, 1, 2, 3],
    1.12 +         [3, 1, 1, 2]]
    1.13 +
    1.14 +    for row in C:
    1.15 +        for i in xrange(len(row)):
    1.16 +            row[i] = GF256(row[i])
    1.17 +
    1.18 +    C = Matrix(C)
    1.19 +
    1.20 +    def mix_column(self, state):
    1.21 +        state[:] = (AES.C * Matrix(state)).rows
    1.22 +