http://hg.viff.dk/viff/rev/28c946f07e18
changeset: 1144:28c946f07e18
user:      Marcel Keller <[email protected]>
date:      Tue Feb 24 11:24:48 2009 +0100
summary:   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.

diffstat:

2 files changed, 6 insertions(+), 4 deletions(-)
viff/aes.py     |    4 +++-
viff/runtime.py |    6 +++---

diffs (46 lines):

diff -r 4506ca5dbf70 -r 28c946f07e18 viff/aes.py
--- 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.
 
diff -r 4506ca5dbf70 -r 28c946f07e18 viff/runtime.py
--- 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)
 
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to