[Cryptech-Commits] [sw/libhal] 05/05: Test pkey_match() attribute handling.

git at cryptech.is git at cryptech.is
Wed Nov 2 05:32:29 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 8b0b27be4ee4824bba59273fecdfd3226d4076b5
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Wed Nov 2 01:32:03 2016 -0400

    Test pkey_match() attribute handling.
---
 unit-tests.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/unit-tests.py b/unit-tests.py
index 53d4d02..5077662 100644
--- a/unit-tests.py
+++ b/unit-tests.py
@@ -513,6 +513,7 @@ class TestPKeyList(TestCaseLoggedIn):
     def load_keys(self, flags):
         for keytype, curve in static_keys:
             obj = static_keys[keytype, curve]
+            atr = (str(keytype), str(curve))
             if keytype in (HAL_KEY_TYPE_RSA_PRIVATE, HAL_KEY_TYPE_RSA_PUBLIC):
                 curve = HAL_CURVE_NONE
                 der   = obj.exportKey("DER")
@@ -523,6 +524,8 @@ class TestPKeyList(TestCaseLoggedIn):
             k = hsm.pkey_load(keytype, curve, der, flags)
             self.addCleanup(lambda uuid: hsm.pkey_find(uuid, flags = flags).delete(),
                             k.uuid)
+            for i, a in enumerate(atr):
+                k.set_attribute(i, a)
             k.close()
 
     def ks_list(self, flags):
@@ -540,7 +543,8 @@ class TestPKeyList(TestCaseLoggedIn):
         kwargs.update(flags = flags)
         for uuid in hsm.pkey_match(**kwargs):
             with hsm.pkey_find(uuid, flags) as k:
-                print "{0.uuid}  0x{0.key_flags:02x}  {0.key_curve}  {0.key_type}".format(k)
+                print "{k.uuid} 0x{k.key_flags:02x}  {k.key_curve}  {k.key_type}  {a[0]}  {a[1]}".format(
+                    k = k, a = [k.get_attribute(i) for i in xrange(2)])
 
     def ks_match(self, flags):
         self.load_keys(flags)
@@ -557,6 +561,10 @@ class TestPKeyList(TestCaseLoggedIn):
             print "Curve:", curve
             self.ks_print(flags = flags, curve = curve)
             print
+        for keylen in sorted(set(kl for kt, kl in static_keys if not isinstance(kl, Enum))):
+            print "Keylen:", keylen
+            self.ks_print(flags = flags, attributes = [Attribute(1, str(keylen))])
+            print
 
     def test_ks_match_token(self):
         self.ks_match(HAL_KEY_FLAG_TOKEN)



More information about the Commits mailing list