aboutsummaryrefslogtreecommitdiff
path: root/unit-tests.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-11-04 16:41:11 -0400
committerRob Austein <sra@hactrn.net>2016-11-04 16:41:11 -0400
commit8ffe3e5451fa0a4494d4d15ee3ed58245b287b19 (patch)
tree2a1f1b66745d3ab95348f410bb04c169d471987e /unit-tests.py
parent620671dee92e836420ca997a11ab3c203f8f4cc3 (diff)
.set_attribute() speed tests.
Diffstat (limited to 'unit-tests.py')
-rw-r--r--unit-tests.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/unit-tests.py b/unit-tests.py
index 5f472fd..3f74b36 100644
--- a/unit-tests.py
+++ b/unit-tests.py
@@ -614,6 +614,57 @@ class TestPKeyAttribute(TestCaseLoggedIn):
self.load_and_fill(HAL_KEY_FLAG_TOKEN, n_attrs = 16, n_fill = 1024)
+class TestPKeyAttributeSpeedToken(TestCaseLoggedIn):
+ """
+ Attribute speed tests.
+ """
+
+ def setUp(self):
+ der = PreloadedKey.db[HAL_KEY_TYPE_EC_PRIVATE, HAL_CURVE_P256].der
+ self.k = hsm.pkey_load(HAL_KEY_TYPE_EC_PRIVATE, HAL_CURVE_P256, der, HAL_KEY_FLAG_TOKEN)
+ self.addCleanup(self.k.delete)
+ super(TestPKeyAttributeSpeedToken, self).setUp()
+
+ def set_attributes(self, n_attrs):
+ pinwheel = Pinwheel()
+ for i in xrange(n_attrs):
+ pinwheel()
+ self.k.set_attribute(i, "Attribute {}".format(i))
+
+ def test_set_1_attribute(self):
+ self.set_attributes(1)
+
+ def test_set_6_attributes(self):
+ self.set_attributes(6)
+
+ def test_set_12_attributes(self):
+ self.set_attributes(12)
+
+class TestPKeyAttributeSpeedVolatile(TestCaseLoggedIn):
+ """
+ Attribute speed tests.
+ """
+
+ def setUp(self):
+ der = PreloadedKey.db[HAL_KEY_TYPE_EC_PRIVATE, HAL_CURVE_P256].der
+ self.k = hsm.pkey_load(HAL_KEY_TYPE_EC_PRIVATE, HAL_CURVE_P256, der, 0)
+ self.addCleanup(self.k.delete)
+ super(TestPKeyAttributeSpeedVolatile, self).setUp()
+
+ def set_attributes(self, n_attrs):
+ for i in xrange(n_attrs):
+ self.k.set_attribute(i, "Attribute {}".format(i))
+
+ def test_set_1_attribute(self):
+ self.set_attributes(1)
+
+ def test_set_6_attributes(self):
+ self.set_attributes(6)
+
+ def test_set_12_attributes(self):
+ self.set_attributes(12)
+
+
@unittest.skipUnless(ecdsa_loaded, "Requires Python ECDSA package")
class TestPkeyECDSAVerificationNIST(TestCaseLoggedIn):
"""