changeset 1198:c15bc2925969

Added possibility to specify key length by a parameter.
author Marcel Keller <mkeller@cs.au.dk>
date Fri, 03 Jul 2009 10:48:59 +0200
parents b1ee0d5e116f
children f640ea5f0920
files apps/aes.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/apps/aes.py	Wed May 27 16:12:42 2009 +0200
+++ b/apps/aes.py	Fri Jul 03 10:48:59 2009 +0200
@@ -35,6 +35,9 @@
 
 
 parser = OptionParser(usage="Usage: %prog [options] config_file")
+parser.add_option("-K", "--keylength", action="store", type="int",
+                  help="Key length: 128, 192, or 256. Defaults to 128.")
+parser.set_defaults(keylength=128)
 parser.add_option("-e", "--exponentiation", action="store", type="int",
                   metavar="variant",
                   help="Use exponentiation to invert bytes. "
@@ -67,7 +70,7 @@
     start = time.time()
     print "Started at %f." % start
 
-    aes = AES(rt, 192, use_exponentiation=options.exponentiation)
+    aes = AES(rt, options.keylength, use_exponentiation=options.exponentiation)
 
     ciphertext = []
 
@@ -88,7 +91,7 @@
 def share_key(rt):
     key =  []
 
-    for i in range(24):
+    for i in range(options.keylength / 8):
         inputter = i % 3 + 1
         if (inputter == id):
             key.append(rt.input([inputter], GF256, ord("b")))