[Cryptech-Commits] [sw/libhal] 04/05: Preliminary libhal.py test code superseded by unit-tests.py

git at cryptech.is git at cryptech.is
Sun Oct 30 20:16:57 UTC 2016


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/libhal.

commit 641a95fd9b3a61dc405084e88f5ef6bd25030ca7
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Oct 30 16:13:52 2016 -0400

    Preliminary libhal.py test code superseded by unit-tests.py
---
 libhal.py | 47 -----------------------------------------------
 1 file changed, 47 deletions(-)

diff --git a/libhal.py b/libhal.py
index 41fb799..50209f9 100644
--- a/libhal.py
+++ b/libhal.py
@@ -641,50 +641,3 @@ class HSM(object):
     def pkey_delete_attribute(self, pkey, attr_type):
         with self.rpc(RPC_FUNC_PKEY_DELETE_ATTRIBUTE, pkey, attr_type):
             return
-
-if __name__ == "__main__":
-
-    import argparse
-
-    def hexstr(s):
-        return "".join("{:02x}".format(ord(c)) for c in s)
-
-    parser = argparse.ArgumentParser()
-    parser.add_argument("--device", default = os.getenv("CRYPTECH_RPC_CLIENT_SERIAL_DEVICE", "/dev/ttyUSB0"))
-    parser.add_argument("--pin", default = "fnord")
-    args = parser.parse_args()
-
-    hsm = HSM(device = args.device)
-
-    print "Version:", hex(hsm.get_version())
-
-    print "Random:", hexstr(hsm.get_random(16))
-
-    h = hsm.hash_initialize(HAL_DIGEST_ALGORITHM_SHA256)
-    h.update("Hi, Mom")
-    print "Hash:", hexstr(h.finalize())
-
-    h = hsm.hash_initialize(HAL_DIGEST_ALGORITHM_SHA256, key = "secret")
-    h.update("Hi, Dad")
-    print "HMAC:", hexstr(h.finalize())
-
-    print "Logging in"
-    hsm.login(HAL_USER_NORMAL, args.pin)
-
-    print "Generating key"
-    k = hsm.pkey_generate_ec(HAL_CURVE_P256)
-    print "PKey: {0.uuid} {0.key_type} {0.key_flags} {1}".format(k, hexstr(k.public_key))
-    hsm.pkey_close(k)
-
-    for flags in (0, HAL_KEY_FLAG_TOKEN):
-        for t, c, f, u in hsm.pkey_list(flags = flags):
-            print "List:", u, t, c, f
-
-    for f in (HAL_KEY_FLAG_TOKEN, 0):
-        for u in hsm.pkey_match(flags = f):
-            print "Match:", u
-
-    k = hsm.pkey_find(k.uuid)
-    hsm.pkey_delete(k)
-
-    hsm.logout()



More information about the Commits mailing list