changeset 1143:4506ca5dbf70

Trigger next AES round on the whole state, not only on the last byte.
author Marcel Keller <mkeller@cs.au.dk>
date Mon, 23 Feb 2009 17:22:30 +0100
parents 73b8246fbe5b
children 28c946f07e18
files viff/aes.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Mon Feb 23 14:04:15 2009 +0100
+++ b/viff/aes.py	Mon Feb 23 17:22:30 2009 +0100
@@ -358,10 +358,7 @@
         prep_progress(0, start)
 
         def get_trigger(state):
-            return state[3][self.n_b-1]
-
-        def get_last(state):
-            return state[3][self.n_b-1]
+            return gather_shares(reduce(operator.add, state))
 
         def round(_, state, i):
             start_round = time.time()
@@ -372,14 +369,13 @@
             self.add_round_key(state, expanded_key[i*self.n_b:(i+1)*self.n_b])
 
             if (not prepare_at_once):
-                get_last(state).addCallback(progress, i, time.time())
+                trigger = get_trigger(state)
+                trigger.addCallback(progress, i, time.time())
 
                 if (i < self.rounds - 1):
-                    self.runtime.schedule_callback(get_trigger(state),
-                                                   round, state, i + 1)
+                    self.runtime.schedule_callback(trigger, round, state, i + 1)
                 else:
-                    self.runtime.schedule_callback(get_trigger(state),
-                                                   final_round, state)
+                    self.runtime.schedule_callback(trigger, final_round, state)
 
             prep_progress(i, start_round)
 
@@ -392,10 +388,11 @@
             self.shift_row(state)
             self.add_round_key(state, expanded_key[self.rounds*self.n_b:])
 
-            get_last(state).addCallback(progress, self.rounds, time.time())
+            trigger = get_trigger(state)
+            trigger.addCallback(progress, self.rounds, time.time())
 
             if (benchmark):
-                get_trigger(state).addCallback(finish, state)
+                trigger.addCallback(finish, state)
 
             # connect to final result
             for a, b in zip(reduce(operator.add, zip(*state)), result):