diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-30 13:18:56 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-30 13:18:56 -0500 |
commit | 60b41cd435c0acef274209a2a9b494b5f42964f6 (patch) | |
tree | ad7f6dabafa8c59600510f9ddf6d603cb2a75a1b | |
parent | 29db095a35db715f1d84aacae24f00b54aad2507 (diff) | |
parent | 02708b7d8077801c44c944687d8c9f90321a4655 (diff) | |
download | tor-60b41cd435c0acef274209a2a9b494b5f42964f6.tar.gz tor-60b41cd435c0acef274209a2a9b494b5f42964f6.zip |
Merge branch 'bug4538_v2'
-rw-r--r-- | src/common/crypto.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index ebaa0122fd..62b0bcec6c 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -291,37 +291,6 @@ crypto_thread_cleanup(void) ERR_remove_state(0); } -/** Uninitialize the crypto library. Return 0 on success, -1 on failure. - */ -int -crypto_global_cleanup(void) -{ - EVP_cleanup(); - ERR_remove_state(0); - ERR_free_strings(); - -#ifndef DISABLE_ENGINES - ENGINE_cleanup(); -#endif - - CONF_modules_unload(1); - CRYPTO_cleanup_all_ex_data(); -#ifdef TOR_IS_MULTITHREADED - if (_n_openssl_mutexes) { - int n = _n_openssl_mutexes; - tor_mutex_t **ms = _openssl_mutexes; - int i; - _openssl_mutexes = NULL; - _n_openssl_mutexes = 0; - for (i=0;i<n;++i) { - tor_mutex_free(ms[i]); - } - tor_free(ms); - } -#endif - return 0; -} - /** used by tortls.c: wrap an RSA* in a crypto_pk_env_t. */ crypto_pk_env_t * _crypto_new_pk_env_rsa(RSA *rsa) @@ -3090,5 +3059,44 @@ setup_openssl_threading(void) return 0; } #endif + +/** Uninitialize the crypto library. Return 0 on success, -1 on failure. + */ +int +crypto_global_cleanup(void) +{ + EVP_cleanup(); + ERR_remove_state(0); + ERR_free_strings(); + + if (dh_param_p) + BN_free(dh_param_p); + if (dh_param_p_tls) + BN_free(dh_param_p_tls); + if (dh_param_g) + BN_free(dh_param_g); + +#ifndef DISABLE_ENGINES + ENGINE_cleanup(); +#endif + + CONF_modules_unload(1); + CRYPTO_cleanup_all_ex_data(); +#ifdef TOR_IS_MULTITHREADED + if (_n_openssl_mutexes) { + int n = _n_openssl_mutexes; + tor_mutex_t **ms = _openssl_mutexes; + int i; + _openssl_mutexes = NULL; + _n_openssl_mutexes = 0; + for (i=0;i<n;++i) { + tor_mutex_free(ms[i]); + } + tor_free(ms); + } +#endif + return 0; +} + /** @} */ |