viff

changeset 1079:8d946965e46f

Added benchmarking output in AES encryption.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 13 Jan 2009 19:00:40 +0100
parents 395273e73571
children d0c7ced69d2d e3b5d98cdbda
files viff/aes.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Mon Jan 12 19:22:37 2009 +0100
     1.2 +++ b/viff/aes.py	Tue Jan 13 19:00:40 2009 +0100
     1.3 @@ -227,18 +227,35 @@
     1.4          state = [cleartext[i::4] for i in xrange(4)]
     1.5          key = [key[4*i:4*i+4] for i in xrange(self.n_k)]
     1.6  
     1.7 +        import time
     1.8 +        start = time.time()
     1.9 +
    1.10 +        def progress(x, i):
    1.11 +            print "Round %2d: %f" % (i, time.time() - start)
    1.12 +            return x
    1.13 +
    1.14          expanded_key = self.key_expansion(key)
    1.15  
    1.16 +        print "Key expansion preparation: %f" % (time.time() - start)
    1.17 +
    1.18          self.add_round_key(state, expanded_key[0:self.n_b])
    1.19  
    1.20 +        state[0][0].addCallback(progress, 0)
    1.21 +
    1.22          for i in xrange(1, self.rounds):
    1.23              self.byte_sub(state)
    1.24              self.shift_row(state)
    1.25              self.mix_column(state)
    1.26              self.add_round_key(state, expanded_key[i*self.n_b:(i+1)*self.n_b])
    1.27  
    1.28 +            state[0][0].addCallback(progress, i)
    1.29 +            print "Round %d preparation: %f" % (i, time.time() - start)
    1.30 +
    1.31          self.byte_sub(state)
    1.32          self.shift_row(state)
    1.33          self.add_round_key(state, expanded_key[self.rounds*self.n_b:])
    1.34  
    1.35 +        state[0][0].addCallback(progress, self.rounds)
    1.36 +        print "Preparation: %f" % (time.time() - start)
    1.37 +
    1.38          return [byte for word in zip(*state) for byte in word]