http://hg.viff.dk/viff/rev/c1b3ced5bf05
changeset: 1082:c1b3ced5bf05
user:      Marcel Keller <[email protected]>
date:      Wed Jan 14 18:33:33 2009 +0100
summary:   Merged.

diffstat:

1 file changed, 16 insertions(+), 9 deletions(-)
viff/aes.py |   25 ++++++++++++++++---------

diffs (60 lines):

diff -r e3b5d98cdbda -r c1b3ced5bf05 viff/aes.py
--- a/viff/aes.py       Wed Jan 14 18:16:47 2009 +0100
+++ b/viff/aes.py       Wed Jan 14 18:33:33 2009 +0100
@@ -212,7 +212,7 @@
                     "or of shares thereof."
             return input
 
-    def encrypt(self, cleartext, key):
+    def encrypt(self, cleartext, key, benchmark=False):
         """Rijndael encryption.
 
         Cleartext and key should be either a string or a list of bytes 
@@ -227,16 +227,20 @@
         state = [cleartext[i::4] for i in xrange(4)]
         key = [key[4*i:4*i+4] for i in xrange(self.n_k)]
 
-        import time
-        start = time.time()
+        if (benchmark):
+            import time
+            start = time.time()
 
-        def progress(x, i):
-            print "Round %d: %f" % (i, time.time() - start)
-            return x
+            def progress(x, i):
+                print "Round %2d: %f" % (i, time.time() - start)
+                return x
+        else:
+            progress = lambda x, i: x
 
         expanded_key = self.key_expansion(key)
 
-        print "Key expansion preparation: %f" % (time.time() - start)
+        if (benchmark):
+            print "Key expansion preparation: %f" % (time.time() - start)
 
         self.add_round_key(state, expanded_key[0:self.n_b])
 
@@ -258,7 +262,8 @@
             else:
                 get_trigger(state).addCallback(final_round, state)
 
-            print "Round %d preparation: %f" % (i, time.time() - start)
+            if (benchmark):
+                print "Round %2d preparation: %f" % (i, time.time() - start)
 
             return _
 
@@ -271,7 +276,9 @@
 
             get_trigger(state).addCallback(finish, state)
 
-            print "Round %d preparation: %f" % (self.rounds, time.time() - 
start)
+            if (benchmark):
+                print "Round %2d preparation: %f" % (self.rounds, 
+                                                     time.time() - start)
 
             return _
 
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to