Tor 0.4.9.0-alpha-dev
Functions | Variables
crypto_openssl_mgt.c File Reference

Block of functions related to operations from OpenSSL. More...

#include "lib/crypt_ops/compat_openssl.h"
#include "lib/crypt_ops/crypto_openssl_mgt.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/aes.h"
#include "lib/string/util_string.h"
#include "lib/lock/compat_mutex.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/testsupport/testsupport.h"
#include "lib/thread/threads.h"
#include <openssl/err.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/rand.h>
#include <openssl/bn.h>
#include <openssl/dh.h>
#include <openssl/conf.h>
#include <openssl/hmac.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <string.h>

Go to the source code of this file.

Functions

STATIC char * parse_openssl_version_str (const char *raw_version)
 
STATIC void openssl_locking_cb_ (int mode, int n, const char *file, int line)
 
STATIC void tor_set_openssl_thread_id (CRYPTO_THREADID *threadid)
 
void crypto_openssl_log_errors (int severity, const char *doing)
 
const char * crypto_openssl_get_version_str (void)
 
const char * crypto_openssl_get_header_version_str (void)
 
static int setup_openssl_threading (void)
 
static void crypto_openssl_free_all (void)
 
void crypto_openssl_early_init (void)
 
static ENGINE * try_load_engine (const char *path, const char *engine)
 
static void log_engine (const char *fn, ENGINE *e)
 
static int crypto_openssl_init_engines (const char *accelName, const char *accelDir)
 
int crypto_openssl_late_init (int useAccel, const char *accelName, const char *accelDir)
 
void crypto_openssl_thread_cleanup (void)
 
void crypto_openssl_global_cleanup (void)
 

Variables

static tor_mutex_t ** openssl_mutexes_ = NULL
 
static int n_openssl_mutexes_ = 0
 
static char * crypto_openssl_version_str = NULL
 
static char * crypto_openssl_header_version_str = NULL
 

Detailed Description

Block of functions related to operations from OpenSSL.

Definition in file crypto_openssl_mgt.c.

Function Documentation

◆ crypto_openssl_early_init()

void crypto_openssl_early_init ( void  )

Perform early (pre-configuration) initialization tasks for OpenSSL.

Definition at line 216 of file crypto_openssl_mgt.c.

Referenced by crypto_early_init().

◆ crypto_openssl_free_all()

static void crypto_openssl_free_all ( void  )
static

free OpenSSL variables

Definition at line 190 of file crypto_openssl_mgt.c.

Referenced by crypto_openssl_global_cleanup().

◆ crypto_openssl_get_header_version_str()

const char * crypto_openssl_get_header_version_str ( void  )

Definition at line 129 of file crypto_openssl_mgt.c.

◆ crypto_openssl_get_version_str()

const char * crypto_openssl_get_version_str ( void  )

Definition at line 107 of file crypto_openssl_mgt.c.

◆ crypto_openssl_global_cleanup()

void crypto_openssl_global_cleanup ( void  )

Clean up global resources held by openssl.

Definition at line 414 of file crypto_openssl_mgt.c.

◆ crypto_openssl_init_engines()

static int crypto_openssl_init_engines ( const char *  accelName,
const char *  accelDir 
)
static

Initialize engines for openssl (if enabled). Load all the built-in engines, along with the one called accelName (which may be NULL). If accelName is prefixed with "!", then it is required: return -1 if it can't be loaded. Otherwise return 0.

If accelDir is not NULL, it is the path from which the engine should be loaded.

Definition at line 300 of file crypto_openssl_mgt.c.

Referenced by crypto_openssl_late_init().

◆ crypto_openssl_late_init()

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

Perform late (post-init) initialization tasks for OpenSSL

Definition at line 382 of file crypto_openssl_mgt.c.

◆ crypto_openssl_log_errors()

void crypto_openssl_log_errors ( int  severity,
const char *  doing 
)

Log all pending crypto errors at level severity. Use doing to describe our current activities.

Definition at line 66 of file crypto_openssl_mgt.c.

Referenced by crypto_dh_generate_public(), and new_openssl_dh_from_params().

◆ crypto_openssl_thread_cleanup()

void crypto_openssl_thread_cleanup ( void  )

Free crypto resources held by this thread.

Definition at line 405 of file crypto_openssl_mgt.c.

Referenced by crypto_thread_cleanup().

◆ log_engine()

static void log_engine ( const char *  fn,
ENGINE *  e 
)
static

Log any OpenSSL engines we're using at NOTICE.

Definition at line 278 of file crypto_openssl_mgt.c.

◆ openssl_locking_cb_()

STATIC void openssl_locking_cb_ ( int  mode,
int  n,
const char *  file,
int  line 
)

Helper: OpenSSL uses this callback to manipulate mutexes.

Definition at line 148 of file crypto_openssl_mgt.c.

◆ parse_openssl_version_str()

STATIC char * parse_openssl_version_str ( const char *  raw_version)

Declare STATIC functions

Definition at line 87 of file crypto_openssl_mgt.c.

◆ setup_openssl_threading()

static int setup_openssl_threading ( void  )
static

Helper: Construct mutexes, and set callbacks to help OpenSSL handle being multithreaded. Returns 0.

Definition at line 173 of file crypto_openssl_mgt.c.

Referenced by crypto_openssl_early_init().

◆ tor_set_openssl_thread_id()

STATIC void tor_set_openssl_thread_id ( CRYPTO_THREADID *  threadid)

Definition at line 164 of file crypto_openssl_mgt.c.

◆ try_load_engine()

static ENGINE * try_load_engine ( const char *  path,
const char *  engine 
)
static

Try to load an engine in a shared library via fully qualified path.

Definition at line 259 of file crypto_openssl_mgt.c.

Variable Documentation

◆ crypto_openssl_header_version_str

char* crypto_openssl_header_version_str = NULL
static

Definition at line 125 of file crypto_openssl_mgt.c.

◆ crypto_openssl_version_str

char* crypto_openssl_version_str = NULL
static

Definition at line 104 of file crypto_openssl_mgt.c.

◆ n_openssl_mutexes_

int n_openssl_mutexes_ = 0
static

How many mutexes have we allocated for use by OpenSSL?

Definition at line 52 of file crypto_openssl_mgt.c.

Referenced by setup_openssl_threading().

◆ openssl_mutexes_

tor_mutex_t** openssl_mutexes_ = NULL
static

A number of preallocated mutexes for use by OpenSSL.

Definition at line 50 of file crypto_openssl_mgt.c.

Referenced by openssl_locking_cb_(), and setup_openssl_threading().