aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops/crypto_init.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-02 11:21:06 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commit50436ccea4bd200e45196ccce7acff28f293a4de (patch)
tree97385995bcd29d7bf8d8b9a49bdeb884675369ae /src/lib/crypt_ops/crypto_init.c
parentcfe5b35edb38cef6312ef0b4ae44fb0e20342706 (diff)
downloadtor-50436ccea4bd200e45196ccce7acff28f293a4de.tar.gz
tor-50436ccea4bd200e45196ccce7acff28f293a4de.zip
Add crypto module as a subsystem.
Diffstat (limited to 'src/lib/crypt_ops/crypto_init.c')
-rw-r--r--src/lib/crypt_ops/crypto_init.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c
index 9d6e2da0d0..cc7865ef72 100644
--- a/src/lib/crypt_ops/crypto_init.c
+++ b/src/lib/crypt_ops/crypto_init.c
@@ -20,6 +20,9 @@
#include "lib/crypt_ops/crypto_openssl_mgt.h"
#include "lib/crypt_ops/crypto_nss_mgt.h"
#include "lib/crypt_ops/crypto_rand.h"
+#include "lib/crypt_ops/crypto_sys.h"
+
+#include "lib/subsys/subsys.h"
#include "siphash.h"
@@ -202,3 +205,26 @@ tor_is_using_nss(void)
return 0;
#endif
}
+
+static int
+init_crypto_sys(void)
+{
+ if (crypto_early_init() < 0)
+ return -1;
+ crypto_dh_init();
+ return 0;
+}
+
+static void
+shutdown_crypto_sys(void)
+{
+ crypto_global_cleanup();
+}
+
+const struct subsys_fns_t sys_crypto = {
+ .name = "crypto",
+ .supported = true,
+ .level = -60,
+ .initialize = init_crypto_sys,
+ .shutdown = shutdown_crypto_sys,
+};