summaryrefslogtreecommitdiffstats
path: root/crypto/init.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-10-24 18:34:53 +0200
committerRichard Levitte <levitte@openssl.org>2018-10-29 13:35:19 +0100
commit0145dd324e8fcfd2c0dfe296c12586101f0cf3b9 (patch)
treec0e710f0d9996e094525037357fe23839dcee6c4 /crypto/init.c
parent567db2c17d4ea8a0164d7abd8aed65b7a634bb40 (diff)
Add automatic initializations support for EVP_MAC objects
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/7393)
Diffstat (limited to 'crypto/init.c')
-rw-r--r--crypto/init.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto/init.c b/crypto/init.c
index 209d1a483d..fc6aade191 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -235,6 +235,23 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_digests)
return 1;
}
+static CRYPTO_ONCE add_all_macs = CRYPTO_ONCE_STATIC_INIT;
+DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_macs)
+{
+ /*
+ * OPENSSL_NO_AUTOALGINIT is provided here to prevent at compile time
+ * pulling in all the macs during static linking
+ */
+#ifndef OPENSSL_NO_AUTOALGINIT
+# ifdef OPENSSL_INIT_DEBUG
+ fprintf(stderr, "OPENSSL_INIT: ossl_init_add_all_macs: "
+ "openssl_add_all_macs_int()\n");
+# endif
+ openssl_add_all_macs_int();
+#endif
+ return 1;
+}
+
DEFINE_RUN_ONCE_STATIC(ossl_init_no_add_algs)
{
/* Do nothing */
@@ -619,6 +636,14 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
&& !RUN_ONCE(&add_all_digests, ossl_init_add_all_digests))
return 0;
+ if ((opts & OPENSSL_INIT_NO_ADD_ALL_MACS)
+ && !RUN_ONCE(&add_all_macs, ossl_init_no_add_algs))
+ return 0;
+
+ if ((opts & OPENSSL_INIT_ADD_ALL_MACS)
+ && !RUN_ONCE(&add_all_macs, ossl_init_add_all_macs))
+ return 0;
+
if ((opts & OPENSSL_INIT_ATFORK)
&& !openssl_init_fork_handlers())
return 0;