diff options
-rw-r--r-- | unit_tests.py | 25 |
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() |