tor  0.4.0.0-alpha-dev
Functions | Variables
crypto_init.c File Reference
#include "orconfig.h"
#include "lib/crypt_ops/crypto_init.h"
#include "lib/crypt_ops/crypto_curve25519.h"
#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 "lib/crypt_ops/crypto_sys.h"
#include "lib/subsys/subsys.h"
#include "ext/siphash.h"

Go to the source code of this file.

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)
 

Variables

static int crypto_early_initialized_ = 0
 
static int crypto_global_initialized_ = 0
 
static int have_seeded_siphash = 0
 
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.

Function Documentation

◆ crypto_early_init()

int crypto_early_init ( void  )

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

Definition at line 54 of file crypto_init.c.

References crypto_early_initialized_, and crypto_openssl_early_init().

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 188 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 162 of file crypto_init.c.

◆ 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 175 of file crypto_init.c.

◆ crypto_global_cleanup()

int crypto_global_cleanup ( void  )

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

Definition at line 121 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 81 of file crypto_init.c.

References crypto_early_init(), and crypto_global_initialized_.

◆ 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 39 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 153 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 143 of file crypto_init.c.

◆ crypto_thread_cleanup()

void crypto_thread_cleanup ( void  )

Free crypto resources held by this thread.

Definition at line 109 of file crypto_init.c.

References crypto_openssl_thread_cleanup().

◆ tor_is_using_nss()

int tor_is_using_nss ( void  )

Return true iff Tor is using the NSS library.

Definition at line 200 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 30 of file crypto_init.c.

Referenced by crypto_early_init().

◆ crypto_global_initialized_

int crypto_global_initialized_ = 0
static

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

Definition at line 33 of file crypto_init.c.

Referenced by crypto_global_init().

◆ 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,
}

Definition at line 242 of file crypto_init.c.