viff

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 diff
     1.1 --- a/viff/aes.py	Mon Feb 23 14:04:15 2009 +0100
     1.2 +++ b/viff/aes.py	Mon Feb 23 17:22:30 2009 +0100
     1.3 @@ -358,10 +358,7 @@
     1.4          prep_progress(0, start)
     1.5  
     1.6          def get_trigger(state):
     1.7 -            return state[3][self.n_b-1]
     1.8 -
     1.9 -        def get_last(state):
    1.10 -            return state[3][self.n_b-1]
    1.11 +            return gather_shares(reduce(operator.add, state))
    1.12  
    1.13          def round(_, state, i):
    1.14              start_round = time.time()
    1.15 @@ -372,14 +369,13 @@
    1.16              self.add_round_key(state, expanded_key[i*self.n_b:(i+1)*self.n_b])
    1.17  
    1.18              if (not prepare_at_once):
    1.19 -                get_last(state).addCallback(progress, i, time.time())
    1.20 +                trigger = get_trigger(state)
    1.21 +                trigger.addCallback(progress, i, time.time())
    1.22  
    1.23                  if (i < self.rounds - 1):
    1.24 -                    self.runtime.schedule_callback(get_trigger(state),
    1.25 -                                                   round, state, i + 1)
    1.26 +                    self.runtime.schedule_callback(trigger, round, state, i + 1)
    1.27                  else:
    1.28 -                    self.runtime.schedule_callback(get_trigger(state),
    1.29 -                                                   final_round, state)
    1.30 +                    self.runtime.schedule_callback(trigger, final_round, state)
    1.31  
    1.32              prep_progress(i, start_round)
    1.33  
    1.34 @@ -392,10 +388,11 @@
    1.35              self.shift_row(state)
    1.36              self.add_round_key(state, expanded_key[self.rounds*self.n_b:])
    1.37  
    1.38 -            get_last(state).addCallback(progress, self.rounds, time.time())
    1.39 +            trigger = get_trigger(state)
    1.40 +            trigger.addCallback(progress, self.rounds, time.time())
    1.41  
    1.42              if (benchmark):
    1.43 -                get_trigger(state).addCallback(finish, state)
    1.44 +                trigger.addCallback(finish, state)
    1.45  
    1.46              # connect to final result
    1.47              for a, b in zip(reduce(operator.add, zip(*state)), result):