changeset 1140:cbdcba8630c5

Added option take quiet AES initialization, used by unit tests.
author Marcel Keller <mkeller@cs.au.dk>
date Thu, 19 Feb 2009 16:21:59 +0100
parents 6b80efc3bfc5
children 4bacbff2e79f
files viff/aes.py viff/test/test_aes.py
diffstat 2 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Wed Feb 18 20:13:57 2009 +0100
+++ b/viff/aes.py	Thu Feb 19 16:21:59 2009 +0100
@@ -72,7 +72,7 @@
     """
 
     def __init__(self, runtime, key_size, block_size=128, 
-                 use_exponentiation=False):
+                 use_exponentiation=False, quiet=False):
         """Initialize Rijndael.
 
         AES(runtime, key_size, block_size), whereas key size and block
@@ -96,8 +96,9 @@
             elif (use_exponentiation not in AES.exponentation_variants):
                 use_exponentiation = "shortest_sequential_chain"
 
-            print "Use %s for inversion by exponentiation." % \
-                use_exponentiation
+            if (not quiet):
+                print "Use %s for inversion by exponentiation." % \
+                    use_exponentiation
 
             if (use_exponentiation == "standard_square_and_multiply"):
                 self.invert = lambda byte: byte ** 254
@@ -107,7 +108,9 @@
                 self.invert = self.invert_by_exponentiation
         else:
             self.invert = self.invert_by_masking
-            print "Use inversion by masking."
+
+            if (not quiet):
+                print "Use inversion by masking."
 
     exponentiation_variants = ["standard_square_and_multiply",
                                "shortest_sequential_chain",
--- a/viff/test/test_aes.py	Wed Feb 18 20:13:57 2009 +0100
+++ b/viff/test/test_aes.py	Thu Feb 19 16:21:59 2009 +0100
@@ -88,16 +88,16 @@
     @protocol
     def test_byte_sub_with_masking(self, runtime):
         self._test_byte_sub(runtime, AES(runtime, 128, 
-                                         use_exponentiation=False))
+                                         use_exponentiation=False, quiet=True))
 
     @protocol
     def test_byte_sub_with_exponentiation(self, runtime):
         self._test_byte_sub(runtime, AES(runtime, 128, 
-                                         use_exponentiation=True))
+                                         use_exponentiation=True, quiet=True))
 
     @protocol
     def test_key_expansion(self, runtime):
-        aes = AES(runtime, 256)
+        aes = AES(runtime, 256, quiet=True)
         key = []
         ascii_key = []
 
@@ -130,7 +130,7 @@
         cleartext = "Encrypt this!!!!"
         key = "Supposed to be secret!?!"
 
-        aes = AES(runtime, 192)
+        aes = AES(runtime, 192, quiet=True)
         r = rijndael(key)
 
         result = aes.encrypt(cleartext, key)