aboutsummaryrefslogtreecommitdiff
path: root/test/provider_pkey_test.c
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2025-09-30 19:12:11 +0000
committerEnji Cooper <ngie@FreeBSD.org>2025-09-30 19:13:17 +0000
commit8e12a5c4eb3507846b507d0afe87d115af41df40 (patch)
tree2f170ce535a803881e0df7dd2ab3e7ccb5fac99d /test/provider_pkey_test.c
parentaed904c48f330dc76da942a8ee2d6eef9d11f572 (diff)
This change adds OpenSSL 3.5.4 from upstream [1]. The 3.5.4 artifact was been verified via PGP key [2] and by SHA256 checksum [3]. This is a security release, but also contains several bugfixes. More information about the release (from a high level) can be found in the release notes [4]. 1. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz 2. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz.asc 3. https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz.sha256 4. https://github.com/openssl/openssl/blob/openssl-3.5.4/NEWS.md
Diffstat (limited to 'test/provider_pkey_test.c')
-rw-r--r--test/provider_pkey_test.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/provider_pkey_test.c b/test/provider_pkey_test.c
index cb656a62a650..9ffe3581d62a 100644
--- a/test/provider_pkey_test.c
+++ b/test/provider_pkey_test.c
@@ -239,6 +239,77 @@ end:
return ret;
}
+static int test_pkey_can_sign(void)
+{
+ OSSL_PROVIDER *fake_rsa = NULL;
+ EVP_PKEY *pkey_fake = NULL;
+ EVP_PKEY_CTX *ctx = NULL;
+ OSSL_PARAM *params = NULL;
+ int ret = 0;
+
+ if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
+ return 0;
+
+ /*
+ * Ensure other tests did not forget to reset fake_rsa_query_operation_name
+ * to its default value: 0
+ */
+ if (!TEST_int_eq(fake_rsa_query_operation_name, 0))
+ goto end;
+
+ if (!TEST_ptr(params = fake_rsa_key_params(0))
+ || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
+ "provider=fake-rsa"))
+ || !TEST_true(EVP_PKEY_fromdata_init(ctx))
+ || !TEST_true(EVP_PKEY_fromdata(ctx, &pkey_fake, EVP_PKEY_PUBLIC_KEY,
+ params))
+ || !TEST_true(EVP_PKEY_can_sign(pkey_fake))
+ || !TEST_ptr(pkey_fake))
+ goto end;
+
+ EVP_PKEY_CTX_free(ctx);
+ ctx = NULL;
+ EVP_PKEY_free(pkey_fake);
+ pkey_fake = NULL;
+ OSSL_PARAM_free(params);
+ params = NULL;
+
+ /*
+ * Documented behavior for OSSL_FUNC_keymgmt_query_operation_name()
+ * allows it to return NULL, in which case the fallback should be to use
+ * EVP_KEYMGMT_get0_name(). That is exactly the thing we are testing here.
+ */
+ fake_rsa_query_operation_name = 1;
+
+ if (!TEST_ptr(params = fake_rsa_key_params(0))
+ || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA",
+ "provider=fake-rsa"))
+ || !TEST_true(EVP_PKEY_fromdata_init(ctx))
+ || !TEST_true(EVP_PKEY_fromdata(ctx, &pkey_fake, EVP_PKEY_PUBLIC_KEY,
+ params))
+ || !TEST_true(EVP_PKEY_can_sign(pkey_fake))
+ || !TEST_ptr(pkey_fake))
+ goto end;
+
+ EVP_PKEY_CTX_free(ctx);
+ ctx = NULL;
+ EVP_PKEY_free(pkey_fake);
+ pkey_fake = NULL;
+ OSSL_PARAM_free(params);
+ params = NULL;
+
+ ret = 1;
+end:
+
+ EVP_PKEY_CTX_free(ctx);
+ EVP_PKEY_free(pkey_fake);
+ OSSL_PARAM_free(params);
+ fake_rsa_query_operation_name = 0;
+
+ fake_rsa_finish(fake_rsa);
+ return ret;
+}
+
static int test_pkey_store(int idx)
{
OSSL_PROVIDER *deflt = NULL;
@@ -719,6 +790,7 @@ int setup_tests(void)
ADD_TEST(test_pkey_sig);
ADD_TEST(test_alternative_keygen_init);
ADD_TEST(test_pkey_eq);
+ ADD_TEST(test_pkey_can_sign);
ADD_ALL_TESTS(test_pkey_store, 2);
ADD_TEST(test_pkey_delete);
ADD_TEST(test_pkey_store_open_ex);