[Cryptech-Commits] [sw/pkcs11] 01/02: Add test case using public key via C_CreateObject() to verify signature created by earlier keypair.

git at cryptech.is git at cryptech.is
Thu May 26 04:12:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch rpc
in repository sw/pkcs11.

commit dbd082f37ae7067c86982f153d2f555d9c21c340
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu May 19 02:14:20 2016 -0400

    Add test case using public key via C_CreateObject() to verify signature created by earlier keypair.
---
 unit_tests.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

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()



More information about the Commits mailing list