diff options
author | Richard Levitte <levitte@openssl.org> | 2018-10-24 18:34:53 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-10-29 13:35:19 +0100 |
commit | 0145dd324e8fcfd2c0dfe296c12586101f0cf3b9 (patch) | |
tree | c0e710f0d9996e094525037357fe23839dcee6c4 /crypto | |
parent | 567db2c17d4ea8a0164d7abd8aed65b7a634bb40 (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')
-rw-r--r-- | crypto/evp/build.info | 2 | ||||
-rw-r--r-- | crypto/evp/c_allm.c | 15 | ||||
-rw-r--r-- | crypto/include/internal/evp_int.h | 1 | ||||
-rw-r--r-- | crypto/init.c | 25 |
4 files changed, 42 insertions, 1 deletions
diff --git a/crypto/evp/build.info b/crypto/evp/build.info index 6967fe9dc1..e4fdedf3cc 100644 --- a/crypto/evp/build.info +++ b/crypto/evp/build.info @@ -13,7 +13,7 @@ SOURCE[../../libcrypto]=\ e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c \ e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \ e_chacha20_poly1305.c cmeth_lib.c \ - mac_lib.c + mac_lib.c c_allm.c INCLUDE[e_aes.o]=.. ../modes INCLUDE[e_aes_cbc_hmac_sha1.o]=../modes diff --git a/crypto/evp/c_allm.c b/crypto/evp/c_allm.c new file mode 100644 index 0000000000..d5eb858cc3 --- /dev/null +++ b/crypto/evp/c_allm.c @@ -0,0 +1,15 @@ +/* + * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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/evp.h> +#include "internal/evp_int.h" + +void openssl_add_all_macs_int(void) +{ +} diff --git a/crypto/include/internal/evp_int.h b/crypto/include/internal/evp_int.h index 5bc9408676..dadade33c9 100644 --- a/crypto/include/internal/evp_int.h +++ b/crypto/include/internal/evp_int.h @@ -448,6 +448,7 @@ struct evp_pkey_st { void openssl_add_all_ciphers_int(void); void openssl_add_all_digests_int(void); +void openssl_add_all_macs_int(void); void evp_cleanup_int(void); void evp_app_cleanup_int(void); 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; |