Commit b21a12d278 for openssl.org

commit b21a12d278617018f44050eb34af3c33630de3a3
Author: Dr. David von Oheimb <dev@ddvo.net>
Date:   Thu May 1 15:34:53 2025 +0200

    test/fake_rsa: fix invalid scheme name to 'fake-rsa'

    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Simo Sorce <simo@redhat.com>
    MergeDate: Thu Sep 10 13:32:59 2026
    (Merged from https://github.com/openssl/openssl/pull/27507)

diff --git a/test/fake_rsaprov.c b/test/fake_rsaprov.c
index eb9f92af15..c81377acf2 100644
--- a/test/fake_rsaprov.c
+++ b/test/fake_rsaprov.c
@@ -540,8 +540,8 @@ static OSSL_FUNC_store_eof_fn fake_rsa_st_eof;
 static OSSL_FUNC_store_close_fn fake_rsa_st_close;
 static OSSL_FUNC_store_delete_fn fake_rsa_st_delete;

-static const char fake_rsa_scheme[] = "fake_rsa:";
-static const char fake_rsa_openpwtest[] = "fake_rsa:openpwtest";
+static const char fake_rsa_scheme[] = "fake-rsa:";
+static const char fake_rsa_openpwtest[] = "fake-rsa:openpwtest";
 static const char fake_rsa_prompt[] = "Fake Prompt Info";

 static void *fake_rsa_st_open_ex(void *provctx, const char *uri,
@@ -703,7 +703,7 @@ static const OSSL_DISPATCH fake_rsa_store_funcs[] = {
 };

 static const OSSL_ALGORITHM fake_rsa_store_algs[] = {
-    { "fake_rsa", "provider=fake-rsa", fake_rsa_store_funcs },
+    { "fake-rsa", "provider=fake-rsa", fake_rsa_store_funcs },
     { NULL, NULL, NULL }
 };

diff --git a/test/provider_pkey_test.c b/test/provider_pkey_test.c
index c7397c33e6..fc6856ea6f 100644
--- a/test/provider_pkey_test.c
+++ b/test/provider_pkey_test.c
@@ -328,13 +328,12 @@ static int test_pkey_store(int idx)
     if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
         goto end;

-    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
-                      propq)))
+    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake-rsa", propq)))
         goto end;

     OSSL_STORE_LOADER_free(loader);

-    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
+    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake-rsa:test", libctx, propq,
                       NULL, NULL, NULL, NULL, NULL)))
         goto end;

@@ -378,14 +377,13 @@ static int test_pkey_delete(void)
     if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
         goto end;

-    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
-                      propq)))
+    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake-rsa", propq)))
         goto end;

     OSSL_STORE_LOADER_free(loader);

     /* First iteration: load key, check it, delete it */
-    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
+    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake-rsa:test", libctx, propq,
                       NULL, NULL, NULL, NULL, NULL)))
         goto end;

@@ -403,7 +401,7 @@ static int test_pkey_delete(void)
     EVP_PKEY_free(pkey);
     pkey = NULL;

-    if (!TEST_int_eq(OSSL_STORE_delete("fake_rsa:test", libctx, propq,
+    if (!TEST_int_eq(OSSL_STORE_delete("fake-rsa:test", libctx, propq,
                          NULL, NULL, NULL),
             1))
         goto end;
@@ -411,7 +409,7 @@ static int test_pkey_delete(void)
         goto end;

     /* Second iteration: load key should fail */
-    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:test", libctx, propq,
+    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake-rsa:test", libctx, propq,
                       NULL, NULL, NULL, NULL, NULL)))
         goto end;

@@ -461,8 +459,7 @@ static int test_pkey_store_open_ex(void)
     if (!TEST_ptr(fake_rsa = fake_rsa_start(libctx)))
         goto end;

-    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake_rsa",
-                      propq)))
+    if (!TEST_ptr(loader = OSSL_STORE_LOADER_fetch(libctx, "fake-rsa", propq)))
         goto end;

     OSSL_STORE_LOADER_free(loader);
@@ -473,15 +470,19 @@ static int test_pkey_store_open_ex(void)
     if (UI_method_set_reader(ui_method, fake_pw_read_string))
         goto end;

-    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake_rsa:openpwtest", libctx, propq,
+    if (!TEST_ptr(ctx = OSSL_STORE_open_ex("fake-rsa:openpwtest", libctx, propq,
                       ui_method, NULL, NULL, NULL, NULL)))
         goto end;

     /* retry w/o ui_method to ensure we actually enter pw checks and fail */
     OSSL_STORE_close(ctx);
+    if (!TEST_ptr_null(ctx = OSSL_STORE_open_ex("fake-rsa:openpwtest", libctx,
+                           propq, NULL, NULL, NULL, NULL, NULL)))
+        goto end;
+
+    /* retrying with invalid scheme name syntax (note the '_') will fail */
     if (!TEST_ptr_null(ctx = OSSL_STORE_open_ex("fake_rsa:openpwtest", libctx,
-                           propq, NULL, NULL, NULL, NULL,
-                           NULL)))
+                           propq, ui_method, NULL, NULL, NULL, NULL)))
         goto end;

     ret = 1;