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 wrap: on
line diff
--- a/viff/aes.py	Mon Feb 23 17:22:30 2009 +0100
+++ b/viff/aes.py	Tue Feb 24 11:24:48 2009 +0100
@@ -24,7 +24,7 @@
 import operator
 
 from viff.field import GF256
-from viff.runtime import Share, gather_shares
+from viff.runtime import Share, gather_shares, increment_pc
 from viff.matrix import Matrix
 
 
@@ -87,6 +87,7 @@
         self.n_b = block_size / 32
         self.rounds = max(self.n_k, self.n_b) + 6
         self.runtime = runtime
+        self.program_counter = runtime.program_counter
 
         if (use_exponentiation is not False):
             if (isinstance(use_exponentiation, int) and
@@ -311,6 +312,7 @@
                     "or of shares thereof."
             return input
 
+    @increment_pc
     def encrypt(self, cleartext, key, benchmark=False, prepare_at_once=False):
         """Rijndael encryption.
 
--- a/viff/runtime.py	Mon Feb 23 17:22:30 2009 +0100
+++ b/viff/runtime.py	Tue Feb 24 11:24:48 2009 +0100
@@ -568,11 +568,11 @@
         def callback_wrapper(*args, **kwargs):
             """Wrapper for a callback which ensures a correct PC."""
             try:
-                current_pc = self.program_counter
-                self.program_counter = saved_pc
+                current_pc = self.program_counter[:]
+                self.program_counter[:] = saved_pc
                 return func(*args, **kwargs)
             finally:
-                self.program_counter = current_pc
+                self.program_counter[:] = current_pc
 
         deferred.addCallback(callback_wrapper, *args, **kwargs)