[Cryptech-Commits] [sw/libhal] 01/04: Key generation timing.
git at cryptech.is
git at cryptech.is
Mon Jul 24 15:51:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.
commit 42bc8400c1c0e8cee79f26175c7ff0d688112b21
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Tue Jun 27 11:57:44 2017 -0400
Key generation timing.
Initial version, very basic, RSA-only. Gussy up later.
---
tests/time-keygen.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tests/time-keygen.py b/tests/time-keygen.py
new file mode 100644
index 0000000..fcd47c6
--- /dev/null
+++ b/tests/time-keygen.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+"""
+Time libhal RSA key generation
+"""
+
+from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
+from datetime import datetime, timedelta
+
+from cryptech.libhal import *
+
+parser = ArgumentParser(description = __doc__, formatter_class = 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("-t", "--token", action = "store_true", help = "store key on token")
+parser.add_argument("-k", "--keylen", default = 2048, type = int, help = "key length")
+args = parser.parse_args()
+
+hsm = HSM()
+hsm.login(HAL_USER_NORMAL, args.pin)
+
+flags = HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE | (HAL_KEY_FLAG_TOKEN if args.token else 0)
+sum = timedelta()
+
+for n in xrange(1, args.iterations):
+
+ t0 = datetime.now()
+
+ k = hsm.pkey_generate_rsa(args.keylen, flags)
+
+ t1 = datetime.now()
+
+ k.delete()
+
+ sum += t1 - t0
+
+ print "{:4d} this {} mean {}".format(n, t1 - t0, sum / n)
More information about the Commits
mailing list