changeset 1139:6b80efc3bfc5

Encrypting several blocks in parallel possible in AES example application.
author Marcel Keller <mkeller@cs.au.dk>
date Wed, 18 Feb 2009 20:13:57 +0100
parents cecc7b3c6eb0
children cbdcba8630c5
files apps/aes.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/apps/aes.py	Wed Feb 18 14:32:24 2009 +0100
+++ b/apps/aes.py	Wed Feb 18 20:13:57 2009 +0100
@@ -48,6 +48,9 @@
 parser.set_defaults(exponentiation=1)
 parser.add_option("-o", "--at-once", action="store_true",help="Prepare "
                   "the whole computation at once instead of round-wise.")
+parser.add_option("-c", "--count", action="store", type="int",
+                  help="Number of blocks to encrypt. Defaults to 1.")
+parser.set_defaults(count=1)
 
 # Add standard VIFF options.
 Runtime.add_options(parser)
@@ -64,8 +67,12 @@
     print "Started at %f." % start
 
     aes = AES(rt, 192, use_exponentiation=options.exponentiation)
-    ciphertext = aes.encrypt("a" * 16, key, True, 
-                             prepare_at_once=options.at_once)
+
+    ciphertext = []
+
+    for i in range(options.count):
+        ciphertext += aes.encrypt("a" * 16, key, True, 
+                                  prepare_at_once=options.at_once)
 
     opened_ciphertext = [rt.open(c) for c in ciphertext]