aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-05-19 02:14:20 -0400
committerRob Austein <sra@hactrn.net>2016-05-19 02:14:20 -0400
commitdbd082f37ae7067c86982f153d2f555d9c21c340 (patch)
tree4d229df53c8768d1ad8a4d599a21cda0df19ab49
parent1011308ae39ad624a3d93941bf0c1cb9039134bf (diff)
Add test case using public key via C_CreateObject() to verify signature created by earlier keypair.
-rw-r--r--unit_tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/unit_tests.py b/unit_tests.py
index 2aefedc..27d938a 100644
--- a/unit_tests.py
+++ b/unit_tests.py
@@ -382,6 +382,31 @@ class TestKeys(unittest.TestCase):
p11.C_VerifyInit(self.session, CKM_ECDSA, handle)
p11.C_Verify(self.session, H, r + s)
+ def test_gen_sign_verify_reload_ecdsa_p256_sha256(self):
+ public_key, private_key = p11.C_GenerateKeyPair(self.session, CKM_EC_KEY_PAIR_GEN,
+ CKA_ID = "EC-P256", CKA_EC_PARAMS = self.oid_p256,
+ CKA_SIGN = True, CKA_VERIFY = True)
+ self.assertIsKeypair(public_key, private_key)
+ hamster = "Your mother was a hamster"
+ p11.C_SignInit(self.session, CKM_ECDSA_SHA256, private_key)
+ sig = p11.C_Sign(self.session, hamster)
+ self.assertIsInstance(sig, str)
+ p11.C_VerifyInit(self.session, CKM_ECDSA_SHA256, public_key)
+ p11.C_Verify(self.session, hamster, sig)
+
+ a = p11.C_GetAttributeValue(self.session, public_key,
+ CKA_CLASS, CKA_KEY_TYPE, CKA_VERIFY, CKA_TOKEN,
+ CKA_EC_PARAMS, CKA_EC_POINT)
+
+ for handle in p11.FindObjects(self.session):
+ p11.C_DestroyObject(self.session, handle)
+ p11.C_CloseAllSessions(args.slot)
+ self.session = p11.C_OpenSession(args.slot)
+ p11.C_Login(self.session, CKU_USER, args.user_pin)
+
+ o = p11.C_CreateObject(self.session, a)
+ p11.C_VerifyInit(self.session, CKM_ECDSA_SHA256, o)
+ p11.C_Verify(self.session, hamster, sig)
if __name__ == "__main__":
main()