viff

changeset 1133:f24861244622

Merged.
author Marcel Keller <mkeller@cs.au.dk>
date Thu, 12 Feb 2009 21:18:31 +0100
parents 87f37eb25159 cf4920b3ae72
children 72b7a0717627
files viff/aes.py
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Thu Feb 12 20:05:39 2009 +0100
     1.2 +++ b/viff/aes.py	Thu Feb 12 21:18:31 2009 +0100
     1.3 @@ -71,7 +71,7 @@
     1.4      """
     1.5  
     1.6      def __init__(self, runtime, key_size, block_size=128, 
     1.7 -                 use_exponentiation=False):
     1.8 +                 use_exponentiation=False, use_square_and_multiply=False):
     1.9          """Initialize Rijndael.
    1.10  
    1.11          AES(runtime, key_size, block_size), whereas key size and block
    1.12 @@ -87,6 +87,7 @@
    1.13          self.rounds = max(self.n_k, self.n_b) + 6
    1.14          self.runtime = runtime
    1.15          self.use_exponentiation = use_exponentiation
    1.16 +        self.use_square_and_multiply = use_square_and_multiply
    1.17  
    1.18      # matrix for byte_sub, the last column is the translation vector
    1.19      A = Matrix([[1,0,0,0,1,1,1,1, 1],
    1.20 @@ -112,7 +113,7 @@
    1.21  #                bits[j] = 1 - bits[j]
    1.22  
    1.23              while(len(bits) > 1):
    1.24 -                bits.append(bits.pop() * bits.pop())
    1.25 +                bits.append(bits.pop(0) * bits.pop(0))
    1.26  
    1.27              # b == 1 if byte is 0, b == 0 else
    1.28              b = bits[0]
    1.29 @@ -153,7 +154,10 @@
    1.30              return byte_254
    1.31  
    1.32          if (self.use_exponentiation):
    1.33 -            invert = invert_by_exponentiation
    1.34 +            if (self.use_square_and_multiply):
    1.35 +                invert = lambda byte: byte ** 254
    1.36 +            else:
    1.37 +                invert = invert_by_exponentiation
    1.38          else:
    1.39              invert = invert_by_masking
    1.40  
     2.1 --- a/viff/equality.py	Thu Feb 12 20:05:39 2009 +0100
     2.2 +++ b/viff/equality.py	Thu Feb 12 21:18:31 2009 +0100
     2.3 @@ -79,7 +79,7 @@
     2.4          # Take the product (this is here the same as the "and") of all
     2.5          # the x'es
     2.6          while len(x) > 1:
     2.7 -            x.append(x.pop() * x.pop())
     2.8 +            x.append(x.pop(0) * x.pop(0))
     2.9  
    2.10          return x[0]
    2.11