summaryrefslogtreecommitdiffstats
path: root/apps/lib/app_provider.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-04-09 12:47:46 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-04-09 12:47:46 +1000
commitf5056577ba08b3694aab2722eae1c97bf00acc80 (patch)
tree00492b31c1e6b69164d5a3be50557bac18cdcd2e /apps/lib/app_provider.c
parentcc45a884bd499e8b84de0c0133746591c3712f4c (diff)
Move legacy ciphers into the legacy provider
DES, idea, seed, rc2, rc4, rc5, cast and blowfish have been moved out of the default provider. Code shared between desx and tdes has been moved into a seperate file (cipher_tdes_common.c). 3 test recipes failed due to using app/openssl calls that used legacy ciphers. These calls have been updated to supply both the default and legacy providers. Fixed openssl app '-provider' memory leak Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11419)
Diffstat (limited to 'apps/lib/app_provider.c')
-rw-r--r--apps/lib/app_provider.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/lib/app_provider.c b/apps/lib/app_provider.c
index ac01e8826b..ca24328a2e 100644
--- a/apps/lib/app_provider.c
+++ b/apps/lib/app_provider.c
@@ -10,12 +10,17 @@
#include "apps.h"
#include <openssl/err.h>
#include <openssl/provider.h>
+#include <openssl/safestack.h>
+
+DEFINE_STACK_OF(OSSL_PROVIDER)
/*
* See comments in opt_verify for explanation of this.
*/
enum prov_range { OPT_PROV_ENUM };
+static STACK_OF(OSSL_PROVIDER) *app_providers = NULL;
+
static int opt_provider_load(const char *provider)
{
OSSL_PROVIDER *prov;
@@ -26,9 +31,27 @@ static int opt_provider_load(const char *provider)
opt_getprog(), provider);
return 0;
}
+ if (app_providers == NULL)
+ app_providers = sk_OSSL_PROVIDER_new_null();
+ if (app_providers == NULL
+ || !sk_OSSL_PROVIDER_push(app_providers, prov)) {
+ app_providers_cleanup();
+ return 0;
+ }
return 1;
}
+static void provider_free(OSSL_PROVIDER *prov)
+{
+ OSSL_PROVIDER_unload(prov);
+}
+
+void app_providers_cleanup(void)
+{
+ sk_OSSL_PROVIDER_pop_free(app_providers, provider_free);
+ app_providers = NULL;
+}
+
static int opt_provider_path(const char *path)
{
if (path != NULL && *path == '\0')