aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pkcs11_high_level.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_pkcs11_high_level.cpp')
-rw-r--r--src/tests/test_pkcs11_high_level.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/tests/test_pkcs11_high_level.cpp b/src/tests/test_pkcs11_high_level.cpp
index b91cf6ca0..7b4be9e08 100644
--- a/src/tests/test_pkcs11_high_level.cpp
+++ b/src/tests/test_pkcs11_high_level.cpp
@@ -602,7 +602,7 @@ Test::Result test_rsa_privkey_import()
// create private key
RSA_PrivateKey priv_key(Test::rng(), 2048);
- result.confirm("Key self test OK", priv_key.check_key(Test::rng(), 2048));
+ result.confirm("Key self test OK", priv_key.check_key(Test::rng(), true));
// import to card
RSA_PrivateKeyImportProperties props(priv_key.get_n(), priv_key.get_d());
@@ -620,6 +620,7 @@ Test::Result test_rsa_privkey_import()
PKCS11_RSA_PrivateKey pk(test_session.session(), props);
result.test_success("RSA private key import was successful");
+ result.confirm("PK self test OK", pk.check_key(Test::rng(), true));
pk.destroy();
return result;
@@ -651,10 +652,11 @@ Test::Result test_rsa_privkey_export()
props.set_sensitive(false);
PKCS11_RSA_PrivateKey pk(test_session.session(), props);
+ result.confirm("Check PK11 key", pk.check_key(Test::rng(), true));
RSA_PrivateKey exported = pk.export_key();
result.test_success("RSA private key export was successful");
- result.test_eq("pkcs8 private key", pk.pkcs8_private_key(), priv_key.pkcs8_private_key());
+ result.confirm("Check exported key", exported.check_key(Test::rng(), true));
pk.destroy();
return result;
@@ -677,6 +679,7 @@ Test::Result test_rsa_pubkey_import()
PKCS11_RSA_PublicKey pk(test_session.session(), props);
result.test_success("RSA public key import was successful");
+ result.confirm("Check PK11 key", pk.check_key(Test::rng(), true));
pk.destroy();
@@ -878,8 +881,9 @@ Test::Result test_ecdsa_privkey_import()
props.set_label(label);
PKCS11_ECDSA_PrivateKey pk(test_session.session(), props);
- result.confirm("P11 key self test OK", pk.check_key(Test::rng(), true));
result.test_success("ECDSA private key import was successful");
+ pk.set_public_point(priv_key.public_point());
+ result.confirm("P11 key self test OK", pk.check_key(Test::rng(), false));
pk.destroy();
return result;
@@ -895,6 +899,7 @@ Test::Result test_ecdsa_privkey_export()
ECDSA_PrivateKey priv_key(Test::rng(), EC_Group("secp256r1"));
priv_key.set_parameter_encoding(EC_Group_Encoding::EC_DOMPAR_ENC_OID);
+ result.confirm("Check ECDSA key", priv_key.check_key(Test::rng(), true));
// import to card
EC_PrivateKeyImportProperties props(priv_key.DER_domain(), priv_key.private_value());
props.set_token(true);
@@ -907,9 +912,13 @@ Test::Result test_ecdsa_privkey_export()
props.set_label(label);
PKCS11_ECDSA_PrivateKey pk(test_session.session(), props);
+ pk.set_public_point(priv_key.public_point());
+ result.confirm("Check PK11 key", pk.check_key(Test::rng(), false));
ECDSA_PrivateKey exported = pk.export_key();
result.test_success("ECDSA private key export was successful");
+ result.confirm("Check exported key valid", exported.check_key(Test::rng(), true));
+ result.test_eq("Check exported key contents", exported.pkcs8_private_key(), priv_key.pkcs8_private_key());
pk.destroy();
return result;