DEFINE[evp_test]=NO_LEGACY_MODULE
ENDIF
- SOURCE[evp_extra_test]=evp_extra_test.c fake_rsaprov.c fake_pipelineprov.c
+ SOURCE[evp_extra_test]=evp_extra_test.c fake_rsaprov.c fake_pipelineprov.c helpers/predefined_dsaparams.c
INCLUDE[evp_extra_test]=../include ../apps/include \
../providers/common/include \
../providers/implementations/include
INCLUDE[dsatest]=../include ../apps/include
DEPEND[dsatest]=../libcrypto.a libtestutil.a
- SOURCE[dsa_no_digest_size_test]=dsa_no_digest_size_test.c
+ SOURCE[dsa_no_digest_size_test]=dsa_no_digest_size_test.c helpers/predefined_dsaparams.c
INCLUDE[dsa_no_digest_size_test]=../include ../apps/include
DEPEND[dsa_no_digest_size_test]=../libcrypto.a libtestutil.a
#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
+#include "helpers/predefined_dsaparams.h"
static DSA *dsakey;
-/*
- * These parameters are from test/recipes/04-test_pem_data/dsaparam.pem,
- * converted using dsaparam -C
- */
-static DSA *load_dsa_params(void)
-{
- static unsigned char dsap_2048[] = {
- 0xAE, 0x35, 0x7D, 0x4E, 0x1D, 0x96, 0xE2, 0x9F, 0x00, 0x96,
- 0x60, 0x5A, 0x6E, 0x4D, 0x07, 0x8D, 0xA5, 0x7C, 0xBC, 0xF9,
- 0xAD, 0xD7, 0x9F, 0xD5, 0xE9, 0xEE, 0xA6, 0x33, 0x51, 0xDE,
- 0x7B, 0x72, 0xD2, 0x75, 0xAA, 0x71, 0x77, 0xF1, 0x63, 0xFB,
- 0xB6, 0xEC, 0x5A, 0xBA, 0x0D, 0x72, 0xA2, 0x1A, 0x1C, 0x64,
- 0xB8, 0xE5, 0x89, 0x09, 0x6D, 0xC9, 0x6F, 0x0B, 0x7F, 0xD2,
- 0xCE, 0x9F, 0xEF, 0x87, 0x5A, 0xB6, 0x67, 0x2F, 0xEF, 0xEE,
- 0xEB, 0x59, 0xF5, 0x5E, 0xFF, 0xA8, 0x28, 0x84, 0x9E, 0x5B,
- 0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,
- 0xF5, 0xEC, 0x55, 0xCE, 0x73, 0xDB, 0xBE, 0xA7, 0x8D, 0x3A,
- 0x9F, 0x7A, 0xED, 0x4F, 0xAF, 0xA2, 0x80, 0x4C, 0x30, 0x9E,
- 0x28, 0x49, 0x65, 0x40, 0xF0, 0x03, 0x45, 0x56, 0x99, 0xA2,
- 0x93, 0x1B, 0x9C, 0x46, 0xDE, 0xBD, 0xA8, 0xAB, 0x5F, 0x90,
- 0x3F, 0xB7, 0x3F, 0xD4, 0x6F, 0x8D, 0x5A, 0x30, 0xE1, 0xD4,
- 0x63, 0x3A, 0x6A, 0x7C, 0x8F, 0x24, 0xFC, 0xD9, 0x14, 0x28,
- 0x09, 0xE4, 0x84, 0x4E, 0x17, 0x43, 0x56, 0xB8, 0xD4, 0x4B,
- 0xA2, 0x29, 0x45, 0xD3, 0x13, 0xF0, 0xC2, 0x76, 0x9B, 0x01,
- 0xA0, 0x80, 0x6E, 0x93, 0x63, 0x5E, 0x87, 0x24, 0x20, 0x2A,
- 0xFF, 0xBB, 0x9F, 0xA8, 0x99, 0x6C, 0xA7, 0x9A, 0x00, 0xB9,
- 0x7D, 0xDA, 0x66, 0xC9, 0xC0, 0x72, 0x72, 0x22, 0x0F, 0x1A,
- 0xCC, 0x23, 0xD9, 0xB7, 0x5F, 0x1B
- };
- DSA *dsa = DSA_new();
- BIGNUM *p, *q, *g;
-
- if (dsa == NULL)
- return NULL;
- if (!DSA_set0_pqg(dsa, p = BN_bin2bn(dsap_2048, sizeof(dsap_2048), NULL),
- q = BN_bin2bn(dsaq_2048, sizeof(dsaq_2048), NULL),
- g = BN_bin2bn(dsag_2048, sizeof(dsag_2048), NULL))) {
- DSA_free(dsa);
- BN_free(p);
- BN_free(q);
- BN_free(g);
- return NULL;
- }
- return dsa;
-}
-
static int genkeys(void)
{
if (!TEST_ptr(dsakey = load_dsa_params()))
#include "fake_rsaprov.h"
#include "fake_pipelineprov.h"
+#ifndef OPENSSL_NO_DSA
+#include "helpers/predefined_dsaparams.h"
+#endif
+
#ifdef STATIC_LEGACY
OSSL_provider_init_fn ossl_legacy_provider_init;
#endif
return testresult;
}
-static int priv_enc_hits = 0;
-static int (*orig_priv_enc)(int, const unsigned char *, unsigned char *, RSA *, int);
+static int sign_hits = 0;
+
+static int do_sign_with_method(EVP_PKEY *pkey)
+{
+ const unsigned char msg[] = "Hello, World!";
+ unsigned char sig[128];
+ unsigned int siglen;
+ EVP_MD_CTX *ctx = NULL;
+ int ret = 0;
+
+ sign_hits = 0;
+ ctx = EVP_MD_CTX_new();
+ if (!TEST_ptr(ctx))
+ return 0;
+ if (!TEST_true(EVP_SignInit(ctx, EVP_sha256())))
+ goto err;
+ if (!TEST_true(EVP_SignUpdate(ctx, msg, sizeof(msg) - 1)))
+ goto err;
+ if (!TEST_true(EVP_SignFinal(ctx, sig, &siglen, pkey)))
+ goto err;
+ /* We expect to see our custom sign function called once */
+ if (!TEST_int_eq(sign_hits, 1))
+ goto err;
+
+ ret = 1;
+err:
+ EVP_MD_CTX_free(ctx);
+ return ret;
+}
+
+static int (*orig_rsa_priv_enc)(int, const unsigned char *, unsigned char *, RSA *, int);
-static int tst_priv_enc(int flen, const unsigned char *from, unsigned char *to,
+static int tst_rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to,
RSA *rsa, int padding)
{
- priv_enc_hits++;
- return orig_priv_enc(flen, from, to, rsa, padding);
+ sign_hits++;
+ return orig_rsa_priv_enc(flen, from, to, rsa, padding);
}
-/* Test that a low level method still gets used even with a provider */
-static int test_low_level_method(void)
+/* Test that a low level RSA method still gets used even with a provider */
+static int test_low_level_rsa_method(void)
{
- const unsigned char msg[] = "Hello, World!";
- unsigned char sig[128];
- unsigned int siglen;
BIGNUM *e = BN_new();
RSA *rsa = NULL;
const RSA_METHOD *def = RSA_get_default_method();
RSA_METHOD *method = RSA_meth_dup(def);
EVP_PKEY *pkey = NULL;
- EVP_MD_CTX *ctx = NULL;
int testresult = 0;
if (nullprov != NULL) {
if (!TEST_true(RSA_generate_key_ex(rsa, 1024, e, NULL)))
goto err;
- orig_priv_enc = RSA_meth_get_priv_enc(def);
- if (!TEST_true(RSA_meth_set_priv_enc(method, tst_priv_enc)))
+ orig_rsa_priv_enc = RSA_meth_get_priv_enc(def);
+ if (!TEST_true(RSA_meth_set_priv_enc(method, tst_rsa_priv_enc)))
goto err;
if (!TEST_true(RSA_set_method(rsa, method)))
goto err;
goto err;
rsa = NULL;
- priv_enc_hits = 0;
- ctx = EVP_MD_CTX_new();
- if (!TEST_ptr(ctx))
+ if (!do_sign_with_method(pkey))
goto err;
- if (!TEST_true(EVP_SignInit(ctx, EVP_sha256())))
+
+ testresult = 1;
+err:
+ BN_free(e);
+ RSA_free(rsa);
+ EVP_PKEY_free(pkey);
+ RSA_meth_free(method);
+ return testresult;
+}
+
+#ifndef OPENSSL_NO_DSA
+static DSA_SIG *(*orig_dsa_sign)(const unsigned char *, int, DSA *);
+
+static DSA_SIG *tst_dsa_sign(const unsigned char *buf, int len, DSA *dsa)
+{
+ sign_hits++;
+ return orig_dsa_sign(buf, len, dsa);
+}
+
+/* Test that a low level DSA method still gets used even with a provider */
+static int test_low_level_dsa_method(void)
+{
+ DSA *dsa = NULL;
+ const DSA_METHOD *def = DSA_get_default_method();
+ DSA_METHOD *method = DSA_meth_dup(def);
+ EVP_PKEY *pkey = NULL;
+ int testresult = 0;
+
+ if (nullprov != NULL) {
+ testresult = TEST_skip("Test does not support a non-default library context");
goto err;
- if (!TEST_true(EVP_SignUpdate(ctx, msg, sizeof(msg) - 1)))
+ }
+
+ if (!TEST_ptr(method))
goto err;
- if (!TEST_true(EVP_SignFinal(ctx, sig, &siglen, pkey)))
+
+ dsa = load_dsa_params();
+ if (!TEST_ptr(dsa))
+ goto err;
+ if (!TEST_true(DSA_generate_key(dsa)))
+ goto err;
+
+ orig_dsa_sign = DSA_meth_get_sign(def);
+ if (!TEST_true(DSA_meth_set_sign(method, tst_dsa_sign)))
+ goto err;
+ if (!TEST_true(DSA_set_method(dsa, method)))
goto err;
- /* We expect to see our custom private encryption function called once */
- if (!TEST_int_eq(priv_enc_hits, 1))
+ pkey = EVP_PKEY_new();
+ if (!TEST_ptr(pkey))
+ goto err;
+ if (!TEST_int_gt(EVP_PKEY_assign_DSA(pkey, dsa), 0))
+ goto err;
+ dsa = NULL;
+
+ if (!do_sign_with_method(pkey))
goto err;
testresult = 1;
err:
- BN_free(e);
- RSA_free(rsa);
+ DSA_free(dsa);
EVP_PKEY_free(pkey);
- RSA_meth_free(method);
- EVP_MD_CTX_free(ctx);
+ DSA_meth_free(method);
return testresult;
}
+#endif
int setup_tests(void)
{
ADD_ALL_TESTS(test_ml_dsa_seed_only, 2);
#endif
- ADD_TEST(test_low_level_method);
+ ADD_TEST(test_low_level_rsa_method);
+#ifndef OPENSSL_NO_DSA
+ ADD_TEST(test_low_level_dsa_method);
+#endif
return 1;
}
--- /dev/null
+/*
+ * Copyright 2018-2026 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*
+ * DSA low level APIs are deprecated for public use, but still ok for
+ * internal use.
+ */
+#include "internal/deprecated.h"
+
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#include <openssl/bn.h>
+#include "predefined_dsaparams.h"
+
+/*
+ * These parameters are from test/recipes/04-test_pem_data/dsaparam.pem,
+ * converted using dsaparam -C
+ */
+DSA *load_dsa_params(void)
+{
+ static unsigned char dsap_2048[] = {
+ 0xAE, 0x35, 0x7D, 0x4E, 0x1D, 0x96, 0xE2, 0x9F, 0x00, 0x96,
+ 0x60, 0x5A, 0x6E, 0x4D, 0x07, 0x8D, 0xA5, 0x7C, 0xBC, 0xF9,
+ 0xAD, 0xD7, 0x9F, 0xD5, 0xE9, 0xEE, 0xA6, 0x33, 0x51, 0xDE,
+ 0x7B, 0x72, 0xD2, 0x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= DSA_new();
+ BIGNUM *p, *q, *g;
+
+ if (dsa == NULL)
+ return NULL;
+ if (!DSA_set0_pqg(dsa, p = BN_bin2bn(dsap_2048, sizeof(dsap_2048), NULL),
+ q = BN_bin2bn(dsaq_2048, sizeof(dsaq_2048), NULL),
+ g = BN_bin2bn(dsag_2048, sizeof(dsag_2048), NULL))) {
+ DSA_free(dsa);
+ BN_free(p);
+ BN_free(q);
+ BN_free(g);
+ return NULL;
+ }
+ return dsa;
+}
+#else
+NON_EMPTY_TRANSLATION_UNIT
+#endif /* OPENSSL_NO_DSA */
--- /dev/null
+/*
+ * Copyright 2018-2026 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/dsa.h>
+
+DSA *load_dsa_params(void);