Tor 0.5.0.0-alpha-dev
Loading...
Searching...
No Matches
Functions
crypto_cipher.c File Reference

Symmetric cryptography (low-level) with AES. More...

#include "orconfig.h"
#include "lib/crypt_ops/crypto_cipher.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/cc/torint.h"
#include "lib/crypt_ops/aes.h"
#include <string.h>

Go to the source code of this file.

Functions

crypto_cipher_t * crypto_cipher_new_with_iv_and_bits (const uint8_t *key, const uint8_t *iv, int bits)
 
crypto_cipher_t * crypto_cipher_new_with_iv (const char *key, const char *iv)
 
crypto_cipher_t * crypto_cipher_new_with_bits (const char *key, int bits)
 
crypto_cipher_t * crypto_cipher_new (const char *key)
 
void crypto_cipher_free_ (crypto_cipher_t *env)
 
int crypto_cipher_encrypt (crypto_cipher_t *env, char *to, const char *from, size_t fromlen)
 
int crypto_cipher_decrypt (crypto_cipher_t *env, char *to, const char *from, size_t fromlen)
 
void crypto_cipher_crypt_inplace (crypto_cipher_t *env, char *buf, size_t len)
 
int crypto_cipher_encrypt_with_iv (const char *key, char *to, size_t tolen, const char *from, size_t fromlen)
 
int crypto_cipher_decrypt_with_iv (const char *key, char *to, size_t tolen, const char *from, size_t fromlen)
 

Detailed Description

Symmetric cryptography (low-level) with AES.

Definition in file crypto_cipher.c.

Function Documentation

◆ crypto_cipher_crypt_inplace()

void crypto_cipher_crypt_inplace ( crypto_cipher_t *  env,
char *  buf,
size_t  len 
)

Encrypt len bytes on from using the cipher in env; on success. Does not check for failure.

Definition at line 125 of file crypto_cipher.c.

Referenced by crypto_fast_rng_getbytes(), crypto_fast_rng_refill(), crypto_pwbox(), onion_skin_ntor3_create_nokeygen(), onion_skin_ntor3_server_handshake_part2_nokeygen(), sum_values_from_cipher(), and tor1_crypt_one_payload().

◆ crypto_cipher_decrypt()

int crypto_cipher_decrypt ( crypto_cipher_t *  env,
char *  to,
const char *  from,
size_t  fromlen 
)

Decrypt fromlen bytes from from using the cipher env; on success, store the result to to and return 0. Does not check for failure.

Definition at line 108 of file crypto_cipher.c.

Referenced by crypto_pk_obsolete_private_hybrid_decrypt(), crypto_unpwbox(), decrypt_desc_layer(), decrypt_descriptor_cookie(), decrypt_introduce2(), onion_ntor3_client_handshake(), and onion_skin_ntor3_server_handshake_part1().

◆ crypto_cipher_decrypt_with_iv()

int crypto_cipher_decrypt_with_iv ( const char *  key,
char *  to,
size_t  tolen,
const char *  from,
size_t  fromlen 
)

Decrypt fromlen bytes (at least 1+CIPHER_IV_LEN) from from with the key in key to the buffer in to of length tolen. tolen must be at least fromlen minus CIPHER_IV_LEN bytes for the initialization vector. On success, return the number of bytes written, on failure, return -1.

Definition at line 170 of file crypto_cipher.c.

◆ crypto_cipher_encrypt()

int crypto_cipher_encrypt ( crypto_cipher_t *  env,
char *  to,
const char *  from,
size_t  fromlen 
)

Encrypt fromlen bytes from from using the cipher env; on success, store the result to to and return 0. Does not check for failure.

Definition at line 88 of file crypto_cipher.c.

Referenced by build_encrypted(), crypto_cipher_decrypt_with_iv(), crypto_cipher_encrypt_with_iv(), crypto_pk_obsolete_public_hybrid_encrypt(), hs_desc_build_authorized_client(), and introduce1_encrypt_and_encode().

◆ crypto_cipher_encrypt_with_iv()

int crypto_cipher_encrypt_with_iv ( const char *  key,
char *  to,
size_t  tolen,
const char *  from,
size_t  fromlen 
)

Encrypt fromlen bytes (at least 1) from from with the key in key to the buffer in to of length tolen. tolen must be at least fromlen plus CIPHER_IV_LEN bytes for the initialization vector. On success, return the number of bytes written, on failure, return -1.

Definition at line 138 of file crypto_cipher.c.

◆ crypto_cipher_free_()

void crypto_cipher_free_ ( crypto_cipher_t *  env)

Free a symmetric cipher.

Definition at line 73 of file crypto_cipher.c.

◆ crypto_cipher_new()

crypto_cipher_t * crypto_cipher_new ( const char *  key)

Return a new crypto_cipher_t with the provided key (of CIPHER_KEY_LEN bytes) and an IV of all zero bytes.

Definition at line 65 of file crypto_cipher.c.

Referenced by crypto_pk_obsolete_private_hybrid_decrypt(), and crypto_pk_obsolete_public_hybrid_encrypt().

◆ crypto_cipher_new_with_bits()

crypto_cipher_t * crypto_cipher_new_with_bits ( const char *  key,
int  bits 
)

Return a new crypto_cipher_t with the provided key and an IV of all zero bytes and key length bits. Key length must be 128, 192, or

Definition at line 54 of file crypto_cipher.c.

Referenced by crypto_cipher_new(), decrypt_introduce2(), introduce1_encrypt_and_encode(), onion_ntor3_client_handshake(), onion_skin_ntor3_create_nokeygen(), onion_skin_ntor3_server_handshake_part1(), onion_skin_ntor3_server_handshake_part2_nokeygen(), and tor1_crypt_init().

◆ crypto_cipher_new_with_iv()

crypto_cipher_t * crypto_cipher_new_with_iv ( const char *  key,
const char *  iv 
)

Allocate and return a new symmetric cipher using the provided key and iv. The key is CIPHER_KEY_LEN bytes; the IV is CIPHER_IV_LEN bytes. Both must be provided.

Definition at line 44 of file crypto_cipher.c.

Referenced by crypto_cipher_decrypt_with_iv(), crypto_cipher_encrypt_with_iv(), crypto_pwbox(), and crypto_unpwbox().

◆ crypto_cipher_new_with_iv_and_bits()

crypto_cipher_t * crypto_cipher_new_with_iv_and_bits ( const uint8_t *  key,
const uint8_t *  iv,
int  bits 
)

Allocate and return a new symmetric cipher using the provided key and iv. The key is bits bits long; the IV is CIPHER_IV_LEN bytes. Both must be provided. Key length must be 128, 192, or 256

Definition at line 29 of file crypto_cipher.c.

Referenced by build_encrypted(), cipher_from_seed(), crypto_cipher_new_with_bits(), crypto_cipher_new_with_iv(), decrypt_desc_layer(), decrypt_descriptor_cookie(), hs_desc_build_authorized_client(), and ope_get_cipher().