[Cryptech-Commits] [sw/pkcs11] branch ksng updated: Test all key types by default.

git at cryptech.is git at cryptech.is
Wed Mar 1 22:08:44 UTC 2017


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/pkcs11.

The following commit(s) were added to refs/heads/ksng by this push:
     new 314a6d2  Test all key types by default.
314a6d2 is described below

commit 314a6d2d6fd3ab0c1cc70146acccaa03e6dfe06d
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Wed Mar 1 17:08:26 2017 -0500

    Test all key types by default.
---
 scripts/time-signature.py | 55 +++++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/scripts/time-signature.py b/scripts/time-signature.py
index 1ec7535..8b4cc5f 100755
--- a/scripts/time-signature.py
+++ b/scripts/time-signature.py
@@ -83,47 +83,50 @@ class ECDSAKey(object):
 
 
 def main():
-    #key_choices = tuple(k for k in key_table if k.startswith("rsa_"))
-    key_choices = tuple(key_table)
-    key_default = key_choices[0]
-
     parser = argparse.ArgumentParser(description = __doc__,
                                      formatter_class = argparse.ArgumentDefaultsHelpFormatter)
-    parser.add_argument("-i", "--iterations", default = 100, type = int,      help = "iterations")
-    parser.add_argument("-p", "--pin",        default = "fnord",              help = "user PIN")
-    parser.add_argument("-s", "--slot",       default = 0, type = int,        help = "slot number")
-    parser.add_argument("-t", "--token",      action = "store_true",          help = "store key on token")
-    parser.add_argument("-l", "--libpkcs11",  default = libpkcs11_default,    help = "PKCS #11 library")
-    parser.add_argument("-k", "--key",        default = key_default,
-                                              choices = key_choices,          help = "test key")
+    parser.add_argument("-i", "--iterations", default = 100, type = int,                help = "iterations")
+    parser.add_argument("-p", "--pin",        default = "fnord",                        help = "user PIN")
+    parser.add_argument("-s", "--slot",       default = 0, type = int,                  help = "slot number")
+    parser.add_argument("-t", "--token",      action = "store_true",                    help = "store key on token")
+    parser.add_argument("-l", "--libpkcs11",  default = libpkcs11_default,              help = "PKCS #11 library")
+    parser.add_argument("-k", "--key",        choices = tuple(key_table), nargs = 1,    help = "test just one key")
+    parser.add_argument("-q", "--quiet",      action = "store_true",                    help = "be less chatty")
     args = parser.parse_args()
 
     p11 = PKCS11(args.libpkcs11)
 
-    print "Starting test with key {}, {} iterations".format(args.key, args.iterations)
+    if not args.quiet:
+        print "Initializing"
 
     p11.C_Initialize()
     session = p11.C_OpenSession(args.slot)
     p11.C_Login(session, CKU_USER, args.pin)
 
-    k = key_table[args.key]
-    k.create(args, p11, session, "Your mother was a hamster")
+    for name in args.key or key_table:
+
+        print "Starting test with key {}, {} iterations".format(name, args.iterations)
+
+        k = key_table[name]
+        k.create(args, p11, session, "Your mother was a hamster")
+
+        mean = datetime.timedelta(seconds = 0)
 
-    mean = datetime.timedelta(seconds = 0)
+        for i in xrange(args.iterations):
+            t0  = datetime.datetime.now()
+            p11.C_SignInit(session, k.ckm, k.handle)
+            sig = p11.C_Sign(session, k.tbs)
+            t1  = datetime.datetime.now()
+            k.verify(sig)
+            if not args.quiet:
+                print "{:4d} {}".format(i, t1 - t0)
+            mean += t1 - t0
 
-    for i in xrange(args.iterations):
-        t0  = datetime.datetime.now()
-        p11.C_SignInit(session, k.ckm, k.handle)
-        sig = p11.C_Sign(session, k.tbs)
-        t1  = datetime.datetime.now()
-        k.verify(sig)
-        print "{:4d} {}".format(i, t1 - t0)
-        mean += t1 - t0
+        mean /= args.iterations
+        print "mean {}".format(mean)
 
-    mean /= args.iterations
-    print "mean {}".format(mean)
+        p11.C_DestroyObject(session, k.handle)
 
-    p11.C_DestroyObject(session, k.handle)
     p11.C_CloseAllSessions(args.slot)
     p11.C_Finalize()
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list