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 wrap: on
line diff
--- a/viff/aes.py	Thu Feb 12 20:05:39 2009 +0100
+++ b/viff/aes.py	Thu Feb 12 21:18:31 2009 +0100
@@ -71,7 +71,7 @@
     """
 
     def __init__(self, runtime, key_size, block_size=128, 
-                 use_exponentiation=False):
+                 use_exponentiation=False, use_square_and_multiply=False):
         """Initialize Rijndael.
 
         AES(runtime, key_size, block_size), whereas key size and block
@@ -87,6 +87,7 @@
         self.rounds = max(self.n_k, self.n_b) + 6
         self.runtime = runtime
         self.use_exponentiation = use_exponentiation
+        self.use_square_and_multiply = use_square_and_multiply
 
     # matrix for byte_sub, the last column is the translation vector
     A = Matrix([[1,0,0,0,1,1,1,1, 1],
@@ -112,7 +113,7 @@
 #                bits[j] = 1 - bits[j]
 
             while(len(bits) > 1):
-                bits.append(bits.pop() * bits.pop())
+                bits.append(bits.pop(0) * bits.pop(0))
 
             # b == 1 if byte is 0, b == 0 else
             b = bits[0]
@@ -153,7 +154,10 @@
             return byte_254
 
         if (self.use_exponentiation):
-            invert = invert_by_exponentiation
+            if (self.use_square_and_multiply):
+                invert = lambda byte: byte ** 254
+            else:
+                invert = invert_by_exponentiation
         else:
             invert = invert_by_masking
 
--- a/viff/equality.py	Thu Feb 12 20:05:39 2009 +0100
+++ b/viff/equality.py	Thu Feb 12 21:18:31 2009 +0100
@@ -79,7 +79,7 @@
         # Take the product (this is here the same as the "and") of all
         # the x'es
         while len(x) > 1:
-            x.append(x.pop() * x.pop())
+            x.append(x.pop(0) * x.pop(0))
 
         return x[0]