aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-11-02 01:32:03 -0400
committerRob Austein <sra@hactrn.net>2016-11-02 01:32:03 -0400
commit8b0b27be4ee4824bba59273fecdfd3226d4076b5 (patch)
tree9e82c89820ef40b9e5a2ec9f986f153ac6273efb
parentc593d44af2ad0d9c5c56b78c575a938badea8038 (diff)
Test pkey_match() attribute handling.
-rw-r--r--unit-tests.py10
1 files changed, 9 insertions, 1 deletions
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)