#endif
/* Set non-default library initialisation settings */
- OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN
- | OPENSSL_INIT_LOAD_CONFIG, NULL);
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN
+ | OPENSSL_INIT_LOAD_CONFIG, NULL))
+ return 0;
setup_ui_method();
static async_ctx *async_get_ctx(void)
{
- OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL);
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
+ return NULL;
return async_arch_get_ctx();
}
return 0;
}
- OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL);
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
+ ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_NOT_INITED);
+ return 0;
+ }
if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
- ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
+ ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_NOT_INITED);
return 0;
}
&& p_inflateInit_ && p_deflateEnd
&& p_deflate && p_deflateInit_ && p_zError)
zlib_loaded++;
+
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ZLIB, NULL)) {
+ COMP_zlib_cleanup();
+ return meth;
+ }
if (zlib_loaded)
meth = &zlib_stateful_method;
- OPENSSL_init_crypto(OPENSSL_INIT_ZLIB, NULL);
}
}
#endif
* the first one that we just replaced.
*/
ERR_STATE_free(tmpp);
+
+ /* Ignore failures from these */
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
- /* Ignore failures from this */
ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
}
return ret;
{
const EVP_CIPHER *cp;
- OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL);
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL))
+ return NULL;
cp = (const EVP_CIPHER *)OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH);
return (cp);
{
const EVP_MD *cp;
- OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);
+ if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL))
+ return NULL;
cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
return (cp);
{
struct doall_cipher dc;
+ /* Ignore errors */
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL);
dc.fn = fn;
{
struct doall_cipher dc;
+ /* Ignore errors */
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL);
dc.fn = fn;
{
struct doall_md dc;
+ /* Ignore errors */
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);
dc.fn = fn;
* called prior to any threads making calls to any OpenSSL functions,
* i.e. passing a non-null settings value is assumed to be single-threaded.
*/
-void OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
+int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
{
- /* XXX TODO WARNING To be updated to return a value not assert. */
- assert(!stopped);
+ if (stopped)
+ return 0;
ossl_init_once_run(&base, ossl_init_base);
if (opts & OPENSSL_INIT_ZLIB) {
ossl_init_once_run(&zlib, ossl_init_zlib);
}
+
+ return 1;
}
int OPENSSL_atexit(void (*handler)(void))
#include <openssl/crypto.h>
void OPENSSL_cleanup(void);
- void OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
int OPENSSL_atexit(void (*handler)(void));
void OPENSSL_thread_stop(void);
=head1 RETURN VALUES
-The function OPENSSL_atexit() returns 1 on success or 0 on
-error.
+The functions OPENSSL_init_crypto and OPENSSL_atexit() returns 1 on success or
+0 on error.
=head1 SEE ALSO
#include <openssl/ssl.h>
- void OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
=head1 DESCRIPTION
L<OPENSSL_init_crypto(3)>, so this parameter can also be used to
provide libcrypto settings values.
+=head1 RETURN VALUES
+
+The function OPENSSL_init_ssl() returns 1 on success or 0 on error.
+
=head1 SEE ALSO
L<OPENSSL_init_crypto(3)>
/* Library initialisation functions */
void OPENSSL_cleanup(void);
-void OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
int OPENSSL_atexit(void (*handler)(void));
void OPENSSL_thread_stop(void);
# define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
# define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
# define ERR_R_DISABLED (5|ERR_R_FATAL)
+# define ERR_R_NOT_INITED (6|ERR_R_FATAL)
/*
* 99 is the maximum possible ERR_R_... code, higher values are reserved for
#define OPENSSL_INIT_SSL_DEFAULT \
(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS)
-void OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
# ifndef OPENSSL_NO_UNIT_TEST
__owur const struct openssl_ssl_test_functions *SSL_test_functions(void);
* called prior to any threads making calls to any OpenSSL functions,
* i.e. passing a non-null settings value is assumed to be single-threaded.
*/
-void OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
+int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
{
- /* XXX TODO WARNING To be updated to return a value not assert. */
- assert(!stopped);
+ if (stopped)
+ return 0;
- OPENSSL_init_crypto(opts | OPENSSL_INIT_ADD_ALL_CIPHERS
- | OPENSSL_INIT_ADD_ALL_DIGESTS, settings);
+ if (!OPENSSL_init_crypto(opts | OPENSSL_INIT_ADD_ALL_CIPHERS
+ | OPENSSL_INIT_ADD_ALL_DIGESTS, settings))
+ return 0;
ossl_init_once_run(&ssl_base, ossl_init_ssl_base);
if (opts & OPENSSL_INIT_LOAD_SSL_STRINGS)
ossl_init_once_run(&ssl_strings, ossl_init_load_ssl_strings);
+
+ return 1;
}
return (NULL);
}
- OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
+ if (!OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL))
+ return NULL;
if (FIPS_mode() && (meth->version < TLS1_VERSION)) {
SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE);