aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops/crypto_init.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-11 14:46:28 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-13 12:35:22 -0400
commitc317e78dd75b6bf9c195c9bef5a0b8300d55411a (patch)
treed6d235c23036bcdebe7f24db60fde7dde1bb3846 /src/lib/crypt_ops/crypto_init.c
parentf45107e7de7ff15c630dedcdd1f9bc524423838f (diff)
downloadtor-c317e78dd75b6bf9c195c9bef5a0b8300d55411a.tar.gz
tor-c317e78dd75b6bf9c195c9bef5a0b8300d55411a.zip
Initialize and shut down NSS.
This is largely conjectural, based on online documentation for NSS and NSPR.
Diffstat (limited to 'src/lib/crypt_ops/crypto_init.c')
-rw-r--r--src/lib/crypt_ops/crypto_init.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c
index 01d5baf5be..7f5a63219b 100644
--- a/src/lib/crypt_ops/crypto_init.c
+++ b/src/lib/crypt_ops/crypto_init.c
@@ -18,6 +18,7 @@
#include "lib/crypt_ops/crypto_dh.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "lib/crypt_ops/crypto_openssl_mgt.h"
+#include "lib/crypt_ops/crypto_nss_mgt.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "siphash.h"
@@ -56,6 +57,9 @@ crypto_early_init(void)
#ifdef ENABLE_OPENSSL
crypto_openssl_early_init();
#endif
+#ifdef ENABLE_NSS
+ crypto_nss_early_init();
+#endif
if (crypto_seed_rng() < 0)
return -1;
@@ -80,7 +84,12 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
crypto_global_initialized_ = 1;
#ifdef ENABLE_OPENSSL
- return crypto_openssl_late_init(useAccel, accelName, accelDir);
+ if (crypto_openssl_late_init(useAccel, accelName, accelDir) < 0)
+ return -1;
+#endif
+#ifdef ENABLE_NSS
+ if (crypto_nss_late_init() < 0)
+ return -1;
#endif
}
return 0;
@@ -90,8 +99,8 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
void
crypto_thread_cleanup(void)
{
-#ifndef NEW_THREAD_API
- ERR_remove_thread_state(NULL);
+#ifdef ENABLE_OPENSSL
+ crypto_openssl_thread_cleanup();
#endif
}
@@ -107,6 +116,9 @@ crypto_global_cleanup(void)
#ifdef ENABLE_OPENSSL
crypto_openssl_global_cleanup();
#endif
+#ifdef ENABLE_NSS
+ crypto_nss_global_cleanup();
+#endif
crypto_early_initialized_ = 0;
crypto_global_initialized_ = 0;