]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add command line option for setting propquery in evp_test
authorVeronika Hanulíková <vhanulik@redhat.com>
Fri, 8 Sep 2023 09:44:27 +0000 (11:44 +0200)
committerDmitry Belyavskiy <beldmit@gmail.com>
Thu, 21 Sep 2023 18:30:01 +0000 (20:30 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22151)

test/evp_test.c

index f998c21426c27bf70a019c41fc2f95d3d7637a65..309ab94c21b540ae63c85e5c642ffeffc92d09b8 100644 (file)
@@ -74,6 +74,7 @@ typedef enum OPTION_choice {
     OPT_CONFIG_FILE,
     OPT_IN_PLACE,
     OPT_PROVIDER_NAME,
+    OPT_PROV_PROPQUERY,
     OPT_TEST_ENUM
 } OPTION_CHOICE;
 
@@ -116,6 +117,7 @@ static int memory_err_compare(EVP_TEST *t, const char *err,
 
 /* Option specific for evp test */
 static int process_mode_in_place;
+static const char *propquery = NULL;
 
 static int evp_test_process_mode(char *mode)
 {
@@ -367,7 +369,7 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
         return 1;
     }
 
-    if ((digest = fetched_digest = EVP_MD_fetch(libctx, alg, NULL)) == NULL
+    if ((digest = fetched_digest = EVP_MD_fetch(libctx, alg, propquery)) == NULL
         && (digest = EVP_get_digestbyname(alg)) == NULL)
         return 0;
     if (!TEST_ptr(mdat = OPENSSL_zalloc(sizeof(*mdat))))
@@ -596,7 +598,7 @@ static int cipher_test_init(EVP_TEST *t, const char *alg)
     }
 
     ERR_set_mark();
-    if ((cipher = fetched_cipher = EVP_CIPHER_fetch(libctx, alg, NULL)) == NULL
+    if ((cipher = fetched_cipher = EVP_CIPHER_fetch(libctx, alg, propquery)) == NULL
         && (cipher = EVP_get_cipherbyname(alg)) == NULL) {
         /* a stitched cipher might not be available */
         if (strstr(alg, "HMAC") != NULL) {
@@ -1244,7 +1246,7 @@ static int mac_test_init(EVP_TEST *t, const char *alg)
         t->skip = 1;
         return 1;
     }
-    if ((mac = EVP_MAC_fetch(libctx, alg, NULL)) == NULL) {
+    if ((mac = EVP_MAC_fetch(libctx, alg, propquery)) == NULL) {
         /*
          * Since we didn't find an EVP_MAC, we check for known EVP_PKEY methods
          * For debugging purposes, we allow 'NNNN by EVP_PKEY' to force running
@@ -1421,7 +1423,7 @@ static int mac_test_run_pkey(EVP_TEST *t)
             t->err = NULL;
             goto err;
         }
-        if (!TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, expected->alg, NULL))) {
+        if (!TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, expected->alg, propquery))) {
             t->err = "MAC_KEY_CREATE_ERROR";
             goto err;
         }
@@ -1794,7 +1796,7 @@ static int pkey_test_init(EVP_TEST *t, const char *name,
         return 0;
     }
     kdata->keyop = keyop;
-    if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, NULL))) {
+    if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, propquery))) {
         EVP_PKEY_free(pkey);
         OPENSSL_free(kdata);
         return 0;
@@ -2293,7 +2295,7 @@ static int pbe_test_run(EVP_TEST *t)
 #endif
     } else if (expected->pbe_type == PBE_TYPE_PKCS12) {
         fetched_digest = EVP_MD_fetch(libctx, EVP_MD_get0_name(expected->md),
-                                      NULL);
+                                      propquery);
         if (fetched_digest == NULL) {
             t->err = "PKCS12_ERROR";
             goto err;
@@ -2533,7 +2535,7 @@ static int rand_test_init(EVP_TEST *t, const char *name)
     if (!EVP_RAND_CTX_set_params(rdata->parent, params))
         goto err;
 
-    rand = EVP_RAND_fetch(libctx, name, NULL);
+    rand = EVP_RAND_fetch(libctx, name, propquery);
     if (rand == NULL)
         goto err;
     rdata->ctx = EVP_RAND_CTX_new(rand, rdata->parent);
@@ -2785,7 +2787,7 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
     kdata->p = kdata->params;
     *kdata->p = OSSL_PARAM_construct_end();
 
-    kdf = EVP_KDF_fetch(libctx, name, NULL);
+    kdf = EVP_KDF_fetch(libctx, name, propquery);
     if (kdf == NULL) {
         OPENSSL_free(kdata);
         return 0;
@@ -2994,7 +2996,7 @@ static int pkey_kdf_test_init(EVP_TEST *t, const char *name)
     if (!TEST_ptr(kdata = OPENSSL_zalloc(sizeof(*kdata))))
         return 0;
 
-    kdata->ctx = EVP_PKEY_CTX_new_from_name(libctx, name, NULL);
+    kdata->ctx = EVP_PKEY_CTX_new_from_name(libctx, name, propquery);
     if (kdata->ctx == NULL
         || EVP_PKEY_derive_init(kdata->ctx) <= 0)
         goto err;
@@ -3222,7 +3224,7 @@ static int keygen_test_init(EVP_TEST *t, const char *alg)
         t->skip = 1;
         return 1;
     }
-    if (!TEST_ptr(genctx = EVP_PKEY_CTX_new_from_name(libctx, alg, NULL)))
+    if (!TEST_ptr(genctx = EVP_PKEY_CTX_new_from_name(libctx, alg, propquery)))
         goto err;
 
     if (EVP_PKEY_keygen_init(genctx) <= 0) {
@@ -4121,6 +4123,8 @@ const OPTIONS *test_get_options(void)
           "Mode for data processing by cipher tests [in_place/both], both by default"},
         { "provider", OPT_PROVIDER_NAME, 's',
           "The provider to load (when no configuration file, the default value is 'default')" },
+        { "propquery", OPT_PROV_PROPQUERY, 's',
+          "Property query used when fetching algorithms" },
         { OPT_HELP_STR, 1, '-', "file\tFile to run tests on.\n" },
         { NULL }
     };
@@ -4147,6 +4151,9 @@ int setup_tests(void)
         case OPT_PROVIDER_NAME:
             provider_name = opt_arg();
             break;
+        case OPT_PROV_PROPQUERY:
+            propquery = opt_arg();
+            break;
         case OPT_TEST_CASES:
             break;
         default: