changeset 1138:cecc7b3c6eb0

Added options to the AES test application. One can now choose different variants of inversion by exponentiation and whether the whole computation should be prepared at once.
author Marcel Keller <mkeller@cs.au.dk>
date Wed, 18 Feb 2009 14:32:24 +0100
parents b6d229859b5b
children 6b80efc3bfc5
files apps/aes.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/apps/aes.py	Tue Feb 17 18:15:32 2009 +0100
+++ b/apps/aes.py	Wed Feb 18 14:32:24 2009 +0100
@@ -34,12 +34,20 @@
 
 
 parser = OptionParser(usage="Usage: %prog [options] config_file")
-parser.add_option("-e", "--exponentiation", action="store_true",
-                  help="Use exponentiation to invert bytes (default).")
+parser.add_option("-e", "--exponentiation", action="store", type="int",
+                  metavar="variant", 
+                  help="Use exponentiation to invert bytes. "
+                  "Default is the shortest sequential chain. "
+                  "Possibilities:                             " +
+                  "\n".join(["%d: %s                           " % 
+                             (i, s) for (i, s) 
+                             in enumerate(AES.exponentiation_variants)]))
 parser.add_option("-m", "--masking", action="store_false", 
                   dest="exponentiation", 
                   help="Use masking to invert bytes.")
-parser.set_defaults(exponentiation=True)
+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.")
 
 # Add standard VIFF options.
 Runtime.add_options(parser)
@@ -56,7 +64,8 @@
     print "Started at %f." % start
 
     aes = AES(rt, 192, use_exponentiation=options.exponentiation)
-    ciphertext = aes.encrypt("a" * 16, key, True)
+    ciphertext = aes.encrypt("a" * 16, key, True, 
+                             prepare_at_once=options.at_once)
 
     opened_ciphertext = [rt.open(c) for c in ciphertext]