Tor  0.4.6.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 211 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 185 of file crypto_openssl_mgt.c.

Referenced by crypto_openssl_global_cleanup().

◆ crypto_openssl_global_cleanup()

void crypto_openssl_global_cleanup ( void  )

Clean up global resources held by openssl.

Definition at line 409 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 295 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 377 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 61 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 400 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 273 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 143 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 82 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 168 of file crypto_openssl_mgt.c.

Referenced by crypto_openssl_early_init().

◆ 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 254 of file crypto_openssl_mgt.c.

Variable Documentation

◆ n_openssl_mutexes_

int n_openssl_mutexes_ = 0
static

How many mutexes have we allocated for use by OpenSSL?

Definition at line 47 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 45 of file crypto_openssl_mgt.c.

Referenced by openssl_locking_cb_(), and setup_openssl_threading().