viff

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 diff
     1.1 --- a/viff/aes.py	Wed Feb 18 20:13:57 2009 +0100
     1.2 +++ b/viff/aes.py	Thu Feb 19 16:21:59 2009 +0100
     1.3 @@ -72,7 +72,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, quiet=False):
     1.9          """Initialize Rijndael.
    1.10  
    1.11          AES(runtime, key_size, block_size), whereas key size and block
    1.12 @@ -96,8 +96,9 @@
    1.13              elif (use_exponentiation not in AES.exponentation_variants):
    1.14                  use_exponentiation = "shortest_sequential_chain"
    1.15  
    1.16 -            print "Use %s for inversion by exponentiation." % \
    1.17 -                use_exponentiation
    1.18 +            if (not quiet):
    1.19 +                print "Use %s for inversion by exponentiation." % \
    1.20 +                    use_exponentiation
    1.21  
    1.22              if (use_exponentiation == "standard_square_and_multiply"):
    1.23                  self.invert = lambda byte: byte ** 254
    1.24 @@ -107,7 +108,9 @@
    1.25                  self.invert = self.invert_by_exponentiation
    1.26          else:
    1.27              self.invert = self.invert_by_masking
    1.28 -            print "Use inversion by masking."
    1.29 +
    1.30 +            if (not quiet):
    1.31 +                print "Use inversion by masking."
    1.32  
    1.33      exponentiation_variants = ["standard_square_and_multiply",
    1.34                                 "shortest_sequential_chain",
     2.1 --- a/viff/test/test_aes.py	Wed Feb 18 20:13:57 2009 +0100
     2.2 +++ b/viff/test/test_aes.py	Thu Feb 19 16:21:59 2009 +0100
     2.3 @@ -88,16 +88,16 @@
     2.4      @protocol
     2.5      def test_byte_sub_with_masking(self, runtime):
     2.6          self._test_byte_sub(runtime, AES(runtime, 128, 
     2.7 -                                         use_exponentiation=False))
     2.8 +                                         use_exponentiation=False, quiet=True))
     2.9  
    2.10      @protocol
    2.11      def test_byte_sub_with_exponentiation(self, runtime):
    2.12          self._test_byte_sub(runtime, AES(runtime, 128, 
    2.13 -                                         use_exponentiation=True))
    2.14 +                                         use_exponentiation=True, quiet=True))
    2.15  
    2.16      @protocol
    2.17      def test_key_expansion(self, runtime):
    2.18 -        aes = AES(runtime, 256)
    2.19 +        aes = AES(runtime, 256, quiet=True)
    2.20          key = []
    2.21          ascii_key = []
    2.22  
    2.23 @@ -130,7 +130,7 @@
    2.24          cleartext = "Encrypt this!!!!"
    2.25          key = "Supposed to be secret!?!"
    2.26  
    2.27 -        aes = AES(runtime, 192)
    2.28 +        aes = AES(runtime, 192, quiet=True)
    2.29          r = rijndael(key)
    2.30  
    2.31          result = aes.encrypt(cleartext, key)