summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2023-08-02 10:41:22 +1000
committerPauli <pauli@openssl.org>2023-08-04 11:58:32 +1000
commit61eafa8d27303f0b87d7951bf95ed81f57db8b37 (patch)
tree692bbdb8c750cc92aa28ed60acd924baa604ab6e /test
parent21f0c0d6c3f812b7bd34b69166fabca54428b882 (diff)
PBE test: load providers if auto config load is turned off
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/21621) (cherry picked from commit 52ea255d9d560513f69c3f7f3f21513a693c865c)
Diffstat (limited to 'test')
-rw-r--r--test/pbetest.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/pbetest.c b/test/pbetest.c
index d73ae66fa5..7bf0680785 100644
--- a/test/pbetest.c
+++ b/test/pbetest.c
@@ -15,6 +15,8 @@
#include <openssl/x509.h>
#include <openssl/rc4.h>
#include <openssl/md5.h>
+#include <openssl/configuration.h>
+#include <openssl/provider.h>
#if !defined OPENSSL_NO_RC4 && !defined OPENSSL_NO_MD5 \
|| !defined OPENSSL_NO_DES && !defined OPENSSL_NO_SHA1
@@ -123,8 +125,27 @@ static int test_pkcs5_pbe_des_sha1(void)
}
#endif
+#ifdef OPENSSL_NO_AUTOLOAD_CONFIG
+/*
+ * For configurations where we are not autoloading configuration, we need
+ * to access the legacy provider. The easiest way is to load both the
+ * legacy and default providers directly and unload them on termination.
+ */
+static OSSL_PROVIDER *legacy, *dflt;
+#endif
+
int setup_tests(void)
{
+#ifdef OPENSSL_NO_AUTOLOAD_CONFIG
+ /* Load required providers if not done via configuration */
+ legacy = OSSL_PROVIDER_load(NULL, "legacy");
+ dflt = OSSL_PROVIDER_load(NULL, "default");
+ if (!TEST_ptr(legacy) || !TEST_ptr(dflt)) {
+ cleanup_tests();
+ return -1;
+ }
+#endif
+
#if !defined OPENSSL_NO_RC4 && !defined OPENSSL_NO_MD5
ADD_TEST(test_pkcs5_pbe_rc4_md5);
#endif
@@ -134,3 +155,13 @@ int setup_tests(void)
return 1;
}
+
+#ifdef OPENSSL_NO_AUTOLOAD_CONFIG
+void cleanup_tests(void)
+{
+ /* Dispose of providers */
+ OSSL_PROVIDER_unload(legacy);
+ OSSL_PROVIDER_unload(dflt);
+ legacy = dflt = NULL;
+}
+#endif