viff

changeset 1144:28c946f07e18

Increment program counter by AES.encrypt(). Since AES is not a subclass of Runtime, the program counter is referenced in AES and should therefore only be changed in-place in Runtime.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 24 Feb 2009 11:24:48 +0100
parents 4506ca5dbf70
children 58576bfc42e8
files viff/aes.py viff/runtime.py
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Mon Feb 23 17:22:30 2009 +0100
     1.2 +++ b/viff/aes.py	Tue Feb 24 11:24:48 2009 +0100
     1.3 @@ -24,7 +24,7 @@
     1.4  import operator
     1.5  
     1.6  from viff.field import GF256
     1.7 -from viff.runtime import Share, gather_shares
     1.8 +from viff.runtime import Share, gather_shares, increment_pc
     1.9  from viff.matrix import Matrix
    1.10  
    1.11  
    1.12 @@ -87,6 +87,7 @@
    1.13          self.n_b = block_size / 32
    1.14          self.rounds = max(self.n_k, self.n_b) + 6
    1.15          self.runtime = runtime
    1.16 +        self.program_counter = runtime.program_counter
    1.17  
    1.18          if (use_exponentiation is not False):
    1.19              if (isinstance(use_exponentiation, int) and
    1.20 @@ -311,6 +312,7 @@
    1.21                      "or of shares thereof."
    1.22              return input
    1.23  
    1.24 +    @increment_pc
    1.25      def encrypt(self, cleartext, key, benchmark=False, prepare_at_once=False):
    1.26          """Rijndael encryption.
    1.27  
     2.1 --- a/viff/runtime.py	Mon Feb 23 17:22:30 2009 +0100
     2.2 +++ b/viff/runtime.py	Tue Feb 24 11:24:48 2009 +0100
     2.3 @@ -568,11 +568,11 @@
     2.4          def callback_wrapper(*args, **kwargs):
     2.5              """Wrapper for a callback which ensures a correct PC."""
     2.6              try:
     2.7 -                current_pc = self.program_counter
     2.8 -                self.program_counter = saved_pc
     2.9 +                current_pc = self.program_counter[:]
    2.10 +                self.program_counter[:] = saved_pc
    2.11                  return func(*args, **kwargs)
    2.12              finally:
    2.13 -                self.program_counter = current_pc
    2.14 +                self.program_counter[:] = current_pc
    2.15  
    2.16          deferred.addCallback(callback_wrapper, *args, **kwargs)
    2.17