Tor 0.4.9.8
Loading...
Searching...
No Matches
crypto_init.c File Reference

Initialize and shut down Tor's crypto library and subsystem. More...

Go to the source code of this file.

Macros

#define CRYPTO_PRIVATE
 
#define CRYPTO_OPTIONS_MAGIC   0x68757368
 
#define CONF_CONTEXT   LL_TABLE
 

Functions

int crypto_init_siphash_key (void)
 
int crypto_early_init (void)
 
int crypto_global_init (int useAccel, const char *accelName, const char *accelDir)
 
void crypto_thread_cleanup (void)
 
int crypto_global_cleanup (void)
 
void crypto_prefork (void)
 
void crypto_postfork (void)
 
const char * crypto_get_library_name (void)
 
const char * crypto_get_library_version_string (void)
 
const char * crypto_get_header_version_string (void)
 
int tor_is_using_nss (void)
 
static int subsys_crypto_initialize (void)
 
static void subsys_crypto_shutdown (void)
 
static void subsys_crypto_prefork (void)
 
static void subsys_crypto_postfork (void)
 
static void subsys_crypto_thread_cleanup (void)
 
static int crypto_options_validate (const void *arg, char **msg_out)
 
static int crypto_set_options (void *arg)
 

Variables

static int crypto_early_initialized_ = 0
 
static int crypto_global_initialized_ = 0
 
static int have_seeded_siphash = 0
 
static const config_format_t crypto_options_fmt
 
const struct subsys_fns_t sys_crypto
 

Detailed Description

Initialize and shut down Tor's crypto library and subsystem.

Definition in file crypto_init.c.

Macro Definition Documentation

◆ CONF_CONTEXT

#define CONF_CONTEXT   LL_TABLE

Definition at line 285 of file crypto_init.c.

◆ CRYPTO_OPTIONS_MAGIC

#define CRYPTO_OPTIONS_MAGIC   0x68757368

Magic number for crypto_options_t.

Definition at line 262 of file crypto_init.c.

Referenced by crypto_options_validate().

◆ CRYPTO_PRIVATE

#define CRYPTO_PRIVATE

Definition at line 15 of file crypto_init.c.

Function Documentation

◆ crypto_early_init()

int crypto_early_init ( void )

Initialize the crypto library. Return 0 on success, -1 on failure.

Definition at line 60 of file crypto_init.c.

Referenced by crypto_global_init().

◆ crypto_get_header_version_string()

const char * crypto_get_header_version_string ( void )

Return the version of the crypto library we're using, as given in the headers.

Definition at line 207 of file crypto_init.c.

◆ crypto_get_library_name()

const char * crypto_get_library_name ( void )

Return the name of the crypto library we're using.

Definition at line 181 of file crypto_init.c.

Referenced by options_init_from_torrc(), and tor_init().

◆ crypto_get_library_version_string()

const char * crypto_get_library_version_string ( void )

Return the version of the crypto library we are using, as given in the library.

Definition at line 194 of file crypto_init.c.

Referenced by options_init_from_torrc(), and tor_init().

◆ crypto_global_cleanup()

int crypto_global_cleanup ( void )

Uninitialize the crypto library. Return 0 on success. Does not detect failure.

Definition at line 132 of file crypto_init.c.

◆ crypto_global_init()

int crypto_global_init ( int useAccel,
const char * accelName,
const char * accelDir )

Initialize the crypto library. Return 0 on success, -1 on failure.

Definition at line 91 of file crypto_init.c.

Referenced by crypto_set_options().

◆ crypto_init_siphash_key()

int crypto_init_siphash_key ( void )

Set up the siphash key if we haven't already done so.

Definition at line 45 of file crypto_init.c.

Referenced by crypto_early_init().

◆ crypto_options_validate()

static int crypto_options_validate ( const void * arg,
char ** msg_out )
static

Return 0 if arg is a valid crypto_options_t. Otherwise return -1 and set *msg_out to a freshly allocated error string.

Definition at line 269 of file crypto_init.c.

◆ crypto_postfork()

void crypto_postfork ( void )

Run operations that the crypto library requires to be happy again after forking.

Definition at line 172 of file crypto_init.c.

◆ crypto_prefork()

void crypto_prefork ( void )

Run operations that the crypto library requires to be happy again after forking.

Definition at line 156 of file crypto_init.c.

◆ crypto_set_options()

static int crypto_set_options ( void * arg)
static

Invoked from subsysmgr.c when a new set of options arrives.

Definition at line 305 of file crypto_init.c.

◆ crypto_thread_cleanup()

void crypto_thread_cleanup ( void )

Free crypto resources held by this thread.

Definition at line 119 of file crypto_init.c.

◆ subsys_crypto_initialize()

static int subsys_crypto_initialize ( void )
static

Definition at line 229 of file crypto_init.c.

◆ subsys_crypto_postfork()

static void subsys_crypto_postfork ( void )
static

Definition at line 250 of file crypto_init.c.

◆ subsys_crypto_prefork()

static void subsys_crypto_prefork ( void )
static

Definition at line 244 of file crypto_init.c.

◆ subsys_crypto_shutdown()

static void subsys_crypto_shutdown ( void )
static

Definition at line 238 of file crypto_init.c.

◆ subsys_crypto_thread_cleanup()

static void subsys_crypto_thread_cleanup ( void )
static

Definition at line 256 of file crypto_init.c.

◆ tor_is_using_nss()

int tor_is_using_nss ( void )

Return true iff Tor is using the NSS library.

Definition at line 219 of file crypto_init.c.

Variable Documentation

◆ crypto_early_initialized_

int crypto_early_initialized_ = 0
static

Boolean: has our crypto library been initialized? (early phase)

Definition at line 36 of file crypto_init.c.

Referenced by crypto_early_init(), and crypto_global_cleanup().

◆ crypto_global_initialized_

int crypto_global_initialized_ = 0
static

Boolean: has our crypto library been initialized? (late phase)

Definition at line 39 of file crypto_init.c.

Referenced by crypto_global_cleanup(), and crypto_global_init().

◆ crypto_options_fmt

const config_format_t crypto_options_fmt
static
Initial value:
= {
.size = sizeof(crypto_options_t),
.magic = { "crypto_options_t",
offsetof(crypto_options_t, magic) },
.vars = crypto_options_t_vars,
.validate_fn = crypto_options_validate,
}
static int crypto_options_validate(const void *arg, char **msg_out)
#define CRYPTO_OPTIONS_MAGIC

Declares the configuration options for this module.

Definition at line 292 of file crypto_init.c.

◆ have_seeded_siphash

int have_seeded_siphash = 0
static

Definition at line 41 of file crypto_init.c.

◆ sys_crypto

const struct subsys_fns_t sys_crypto
Initial value:
= {
.name = "crypto",
.supported = true,
.level = -60,
.initialize = subsys_crypto_initialize,
.shutdown = subsys_crypto_shutdown,
.prefork = subsys_crypto_prefork,
.postfork = subsys_crypto_postfork,
.thread_cleanup = subsys_crypto_thread_cleanup,
.options_format = &crypto_options_fmt,
.set_options = crypto_set_options,
}
static const config_format_t crypto_options_fmt
static int crypto_set_options(void *arg)
#define SUBSYS_DECLARE_LOCATION()
Definition subsys.h:211

Definition at line 321 of file crypto_init.c.