Tor 0.4.9.2-alpha-dev
|
Use OpenSSL to implement AES_CTR. More...
#include "orconfig.h"
#include "lib/crypt_ops/aes.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/log/util_bug.h"
#include "lib/arch/bytes.h"
#include "lib/crypt_ops/compat_openssl.h"
#include <openssl/opensslv.h>
#include "lib/crypt_ops/crypto_openssl_mgt.h"
#include <stdlib.h>
#include <string.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/modes.h>
#include "lib/log/log.h"
#include "lib/ctime/di_ops.h"
Go to the source code of this file.
Macros | |
#define | USE_AES_RAW |
#define | TOR_AES_PRIVATE |
#define | RESOLVE_CIPHER(c) EVP_CIPHER_fetch(NULL, OBJ_nid2sn(EVP_CIPHER_get_nid(c)), "") |
#define | INIT_CIPHERS() |
#define | aes_raw_free(cipher) FREE_AND_NULL(aes_raw_t, aes_raw_free_, (cipher)) |
Functions | |
static void | init_ciphers (void) |
aes_cnt_cipher_t * | aes_new_cipher (const uint8_t *key, const uint8_t *iv, int key_bits) |
void | aes_cipher_free_ (aes_cnt_cipher_t *cipher_) |
void | aes_cipher_set_key (aes_cnt_cipher_t *cipher_, const uint8_t *key, int key_bits) |
void | aes_cipher_set_iv_aligned (aes_cnt_cipher_t *cipher_, const uint8_t *iv) |
void | aes_crypt_inplace (aes_cnt_cipher_t *cipher_, char *data, size_t len) |
aes_raw_t * | aes_raw_new (const uint8_t *key, int key_bits, bool encrypt) |
void | aes_raw_set_key (aes_raw_t **cipher_, const uint8_t *key, int key_bits, bool encrypt) |
void | aes_raw_free_ (aes_raw_t *cipher_) |
void | aes_raw_encrypt (const aes_raw_t *cipher, uint8_t *block) |
void | aes_raw_decrypt (const aes_raw_t *cipher, uint8_t *block) |
Variables | |
static const EVP_CIPHER * | aes128ctr = NULL |
static const EVP_CIPHER * | aes192ctr = NULL |
static const EVP_CIPHER * | aes256ctr = NULL |
static const EVP_CIPHER * | aes128ecb = NULL |
static const EVP_CIPHER * | aes192ecb = NULL |
static const EVP_CIPHER * | aes256ecb = NULL |
Use OpenSSL to implement AES_CTR.
Definition in file aes_openssl.c.
#define aes_raw_free | ( | cipher | ) | FREE_AND_NULL(aes_raw_t, aes_raw_free_, (cipher)) |
Definition at line 252 of file aes_openssl.c.
#define INIT_CIPHERS | ( | ) |
Definition at line 76 of file aes_openssl.c.
#define RESOLVE_CIPHER | ( | c | ) | EVP_CIPHER_fetch(NULL, OBJ_nid2sn(EVP_CIPHER_get_nid(c)), "") |
Definition at line 57 of file aes_openssl.c.
#define TOR_AES_PRIVATE |
Definition at line 13 of file aes_openssl.c.
#define USE_AES_RAW |
Definition at line 12 of file aes_openssl.c.
void aes_cipher_free_ | ( | aes_cnt_cipher_t * | cipher_ | ) |
Definition at line 119 of file aes_openssl.c.
void aes_cipher_set_iv_aligned | ( | aes_cnt_cipher_t * | cipher_, |
const uint8_t * | iv | ||
) |
Change the IV of this stream cipher without changing the key.
Requires that the cipher stream position is at an even multiple of 16 bytes.
Definition at line 153 of file aes_openssl.c.
Referenced by cgo_prf_xor_t0().
void aes_cipher_set_key | ( | aes_cnt_cipher_t * | cipher_, |
const uint8_t * | key, | ||
int | key_bits | ||
) |
Changes the key of the cipher; sets the IV to 0.
Definition at line 132 of file aes_openssl.c.
Referenced by cgo_prf_set_key().
void aes_crypt_inplace | ( | aes_cnt_cipher_t * | cipher_, |
char * | data, | ||
size_t | len | ||
) |
Definition at line 166 of file aes_openssl.c.
aes_cnt_cipher_t * aes_new_cipher | ( | const uint8_t * | key, |
const uint8_t * | iv, | ||
int | key_bits | ||
) |
Definition at line 104 of file aes_openssl.c.
void aes_raw_decrypt | ( | const aes_raw_t * | cipher, |
uint8_t * | block | ||
) |
Decrypt a single 16-byte block with 'cipher', which must have been initialized for decryption.
Definition at line 271 of file aes_openssl.c.
Referenced by cgo_et_decrypt().
void aes_raw_encrypt | ( | const aes_raw_t * | cipher, |
uint8_t * | block | ||
) |
Encrypt a single 16-byte block with 'cipher', which must have been initialized for encryption.
Definition at line 259 of file aes_openssl.c.
Referenced by cgo_et_encrypt().
void aes_raw_free_ | ( | aes_raw_t * | cipher_ | ) |
Release storage held by 'cipher'.
Definition at line 240 of file aes_openssl.c.
aes_raw_t * aes_raw_new | ( | const uint8_t * | key, |
int | key_bits, | ||
bool | encrypt | ||
) |
Create a new instance of AES using a key of length 'key_bits' for raw block encryption.
This is even more low-level than counter-mode, and you should only use it with extreme caution.
Definition at line 193 of file aes_openssl.c.
Referenced by cgo_et_init().
void aes_raw_set_key | ( | aes_raw_t ** | cipher_, |
const uint8_t * | key, | ||
int | key_bits, | ||
bool | encrypt | ||
) |
Replace the key on an existing aes_raw_t.
This may be faster than freeing and reallocating.
Definition at line 219 of file aes_openssl.c.
Referenced by cgo_et_set_key().
|
static |
Pre-fetch the versions of every AES cipher with its associated provider.
Definition at line 67 of file aes_openssl.c.
|
static |
Definition at line 48 of file aes_openssl.c.
|
static |
Definition at line 51 of file aes_openssl.c.
|
static |
Definition at line 49 of file aes_openssl.c.
|
static |
Definition at line 52 of file aes_openssl.c.
|
static |
Definition at line 50 of file aes_openssl.c.
|
static |
Definition at line 53 of file aes_openssl.c.