mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add crypto module as a subsystem.
This commit is contained in:
@@ -12,6 +12,7 @@ lib/malloc/*.h
|
||||
lib/intmath/*.h
|
||||
lib/sandbox/*.h
|
||||
lib/string/*.h
|
||||
lib/subsys/*.h
|
||||
lib/testsupport/testsupport.h
|
||||
lib/thread/*.h
|
||||
lib/log/*.h
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/* Copyright (c) 2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file log_crypto.h
|
||||
* \brief Declare subsystem object for the crypto module.
|
||||
**/
|
||||
|
||||
#ifndef TOR_CRYPTO_SYS_H
|
||||
#define TOR_CRYPTO_SYS_H
|
||||
|
||||
extern const struct subsys_fns_t sys_crypto;
|
||||
|
||||
#endif /* !defined(TOR_CRYPTO_SYS_H) */
|
||||
@@ -66,5 +66,6 @@ noinst_HEADERS += \
|
||||
src/lib/crypt_ops/crypto_rand.h \
|
||||
src/lib/crypt_ops/crypto_rsa.h \
|
||||
src/lib/crypt_ops/crypto_s2k.h \
|
||||
src/lib/crypt_ops/crypto_sys.h \
|
||||
src/lib/crypt_ops/crypto_util.h \
|
||||
src/lib/crypt_ops/digestset.h
|
||||
|
||||
Reference in New Issue
Block a user