http://hg.viff.dk/viff/rev/cecc7b3c6eb0
changeset: 1138:cecc7b3c6eb0
user:      Marcel Keller <[email protected]>
date:      Wed Feb 18 14:32:24 2009 +0100
summary:   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.

diffstat:

1 file changed, 13 insertions(+), 4 deletions(-)
apps/aes.py |   17 +++++++++++++----

diffs (37 lines):

diff -r b6d229859b5b -r cecc7b3c6eb0 apps/aes.py
--- 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]
 
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to