viff

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 diff
     1.1 --- a/apps/aes.py	Wed May 27 16:12:42 2009 +0200
     1.2 +++ b/apps/aes.py	Fri Jul 03 10:48:59 2009 +0200
     1.3 @@ -35,6 +35,9 @@
     1.4  
     1.5  
     1.6  parser = OptionParser(usage="Usage: %prog [options] config_file")
     1.7 +parser.add_option("-K", "--keylength", action="store", type="int",
     1.8 +                  help="Key length: 128, 192, or 256. Defaults to 128.")
     1.9 +parser.set_defaults(keylength=128)
    1.10  parser.add_option("-e", "--exponentiation", action="store", type="int",
    1.11                    metavar="variant",
    1.12                    help="Use exponentiation to invert bytes. "
    1.13 @@ -67,7 +70,7 @@
    1.14      start = time.time()
    1.15      print "Started at %f." % start
    1.16  
    1.17 -    aes = AES(rt, 192, use_exponentiation=options.exponentiation)
    1.18 +    aes = AES(rt, options.keylength, use_exponentiation=options.exponentiation)
    1.19  
    1.20      ciphertext = []
    1.21  
    1.22 @@ -88,7 +91,7 @@
    1.23  def share_key(rt):
    1.24      key =  []
    1.25  
    1.26 -    for i in range(24):
    1.27 +    for i in range(options.keylength / 8):
    1.28          inputter = i % 3 + 1
    1.29          if (inputter == id):
    1.30              key.append(rt.input([inputter], GF256, ord("b")))