]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
remove engine references from evp_extra_test
authorNeil Horman <nhorman@openssl.org>
Thu, 11 Sep 2025 18:46:18 +0000 (14:46 -0400)
committerNeil Horman <nhorman@openssl.org>
Fri, 3 Oct 2025 17:01:38 +0000 (13:01 -0400)
The evp_extra_test code makes use of the dasync engine to ensure that we
can do evp operations (signatures and ciphers) with an engine.

The dasync engine is used for this purpose, but it does not exercize any
specific pipeline functionality.

Given that engines are getting removed, the engine tests here I think
can just be removed.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28525)

test/evp_extra_test.c

index 2070f33ecb2a82a72d9f35454c28040c212cf23c..4fe9a316f4daac19071279531d8c8d7ee9a17a04 100644 (file)
@@ -30,7 +30,6 @@
 #include <openssl/aes.h>
 #include <openssl/decoder.h>
 #include <openssl/rsa.h>
-#include <openssl/engine.h>
 #include <openssl/proverr.h>
 #include <openssl/rand.h>
 # include <crypto/ml_kem.h>
@@ -3392,7 +3391,6 @@ static int test_CMAC_keygen(void)
 
     /*
      * This is a legacy method for CMACs, but should still work.
-     * This verifies that it works without an ENGINE.
      */
     kctx = EVP_PKEY_CTX_new_id(EVP_PKEY_CMAC, NULL);
 
@@ -6055,151 +6053,6 @@ static int test_custom_ciph_meth(void)
     return testresult;
 }
 
-# ifdef TODO_REWRITE_ME_DASYNC_PROVIDER
-/* Test we can create a signature keys with an associated ENGINE */
-static int test_signatures_with_engine(int tst)
-{
-    ENGINE *e;
-    const char *engine_id = "dasync";
-    EVP_PKEY *pkey = NULL;
-    const unsigned char badcmackey[] = { 0x00, 0x01 };
-    const unsigned char cmackey[] = {
-        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
-        0x0c, 0x0d, 0x0e, 0x0f
-    };
-    const unsigned char ed25519key[] = {
-        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
-        0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-        0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
-    };
-    const unsigned char msg[] = { 0x00, 0x01, 0x02, 0x03 };
-    int testresult = 0;
-    EVP_MD_CTX *ctx = NULL;
-    unsigned char *mac = NULL;
-    size_t maclen = 0;
-    int ret;
-
-#  ifdef OPENSSL_NO_CMAC
-    /* Skip CMAC tests in a no-cmac build */
-    if (tst <= 1)
-        return 1;
-#  endif
-#  ifdef OPENSSL_NO_ECX
-    /* Skip ECX tests in a no-ecx build */
-    if (tst == 2)
-        return 1;
-#  endif
-
-    if (!TEST_ptr(e = ENGINE_by_id(engine_id)))
-        return 0;
-
-    if (!TEST_true(ENGINE_init(e))) {
-        ENGINE_free(e);
-        return 0;
-    }
-
-    switch (tst) {
-    case 0:
-        pkey = EVP_PKEY_new_CMAC_key(e, cmackey, sizeof(cmackey),
-                                     EVP_aes_128_cbc());
-        break;
-    case 1:
-        pkey = EVP_PKEY_new_CMAC_key(e, badcmackey, sizeof(badcmackey),
-                                     EVP_aes_128_cbc());
-        break;
-    case 2:
-        pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, e, ed25519key,
-                                            sizeof(ed25519key));
-        break;
-    default:
-        TEST_error("Invalid test case");
-        goto err;
-    }
-    if (!TEST_ptr(pkey))
-        goto err;
-
-    if (!TEST_ptr(ctx = EVP_MD_CTX_new()))
-        goto err;
-
-    ret = EVP_DigestSignInit(ctx, NULL, tst == 2 ? NULL : EVP_sha256(), NULL,
-                             pkey);
-    if (tst == 0) {
-        if (!TEST_true(ret))
-            goto err;
-
-        if (!TEST_true(EVP_DigestSignUpdate(ctx, msg, sizeof(msg)))
-                || !TEST_true(EVP_DigestSignFinal(ctx, NULL, &maclen)))
-            goto err;
-
-        if (!TEST_ptr(mac = OPENSSL_malloc(maclen)))
-            goto err;
-
-        if (!TEST_true(EVP_DigestSignFinal(ctx, mac, &maclen)))
-            goto err;
-    } else {
-        /* We used a bad key. We expect a failure here */
-        if (!TEST_false(ret))
-            goto err;
-    }
-
-    testresult = 1;
- err:
-    EVP_MD_CTX_free(ctx);
-    OPENSSL_free(mac);
-    EVP_PKEY_free(pkey);
-    ENGINE_finish(e);
-    ENGINE_free(e);
-
-    return testresult;
-}
-
-static int test_cipher_with_engine(void)
-{
-    ENGINE *e;
-    const char *engine_id = "dasync";
-    const unsigned char keyiv[] = {
-        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
-        0x0c, 0x0d, 0x0e, 0x0f
-    };
-    const unsigned char msg[] = { 0x00, 0x01, 0x02, 0x03 };
-    int testresult = 0;
-    EVP_CIPHER_CTX *ctx = NULL, *ctx2 = NULL;
-    unsigned char buf[AES_BLOCK_SIZE];
-    int len = 0;
-
-    if (!TEST_ptr(e = ENGINE_by_id(engine_id)))
-        return 0;
-
-    if (!TEST_true(ENGINE_init(e))) {
-        ENGINE_free(e);
-        return 0;
-    }
-
-    if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new())
-            || !TEST_ptr(ctx2 = EVP_CIPHER_CTX_new()))
-        goto err;
-
-    if (!TEST_true(EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), e, keyiv, keyiv)))
-        goto err;
-
-    /* Copy the ctx, and complete the operation with the new ctx */
-    if (!TEST_true(EVP_CIPHER_CTX_copy(ctx2, ctx)))
-        goto err;
-
-    if (!TEST_true(EVP_EncryptUpdate(ctx2, buf, &len, msg, sizeof(msg)))
-            || !TEST_true(EVP_EncryptFinal_ex(ctx2, buf + len, &len)))
-        goto err;
-
-    testresult = 1;
- err:
-    EVP_CIPHER_CTX_free(ctx);
-    EVP_CIPHER_CTX_free(ctx2);
-    ENGINE_finish(e);
-    ENGINE_free(e);
-
-    return testresult;
-}
-# endif /* TODO_REWRITE_ME_DASYNC_PROVIDER */
 #endif /* OPENSSL_NO_DEPRECATED_3_0 */
 
 #ifndef OPENSSL_NO_ECX
@@ -7018,18 +6871,6 @@ int setup_tests(void)
     ADD_TEST(test_evp_md_cipher_meth);
     ADD_TEST(test_custom_md_meth);
     ADD_TEST(test_custom_ciph_meth);
-
-# ifdef TODO_REWRITE_ME_DASYNC_PROVIDER
-    /* Tests only support the default libctx */
-    if (testctx == NULL) {
-#  ifndef OPENSSL_NO_EC
-        ADD_ALL_TESTS(test_signatures_with_engine, 3);
-#  else
-        ADD_ALL_TESTS(test_signatures_with_engine, 2);
-#  endif
-        ADD_TEST(test_cipher_with_engine);
-    }
-# endif
 #endif
 
 #ifndef OPENSSL_NO_ECX