mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add support for AES256 and AES192
(This will be used by prop224)
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
||||
|
||||
/* We have five strategies for implementing AES counter mode.
|
||||
*
|
||||
* Best with x86 and x86_64: Use EVP_aes_ctr128() and EVP_EncryptUpdate().
|
||||
* Best with x86 and x86_64: Use EVP_aes_*_ctr() and EVP_EncryptUpdate().
|
||||
* This is possible with OpenSSL 1.0.1, where the counter-mode implementation
|
||||
* can use bit-sliced or vectorized AES or AESNI as appropriate.
|
||||
*
|
||||
|
||||
+29
-10
@@ -541,6 +541,20 @@ crypto_pk_free(crypto_pk_t *env)
|
||||
tor_free(env);
|
||||
}
|
||||
|
||||
/** Allocate and return a new symmetric cipher using the provided key and iv.
|
||||
* The key is <b>bits</b> bits long; the IV is CIPHER_IV_LEN bytes. Both
|
||||
* must be provided. Key length must be 128, 192, or 256 */
|
||||
crypto_cipher_t *
|
||||
crypto_cipher_new_with_iv_and_bits(const uint8_t *key,
|
||||
const uint8_t *iv,
|
||||
int bits)
|
||||
{
|
||||
tor_assert(key);
|
||||
tor_assert(iv);
|
||||
|
||||
return aes_new_cipher((const uint8_t*)key, (const uint8_t*)iv, bits);
|
||||
}
|
||||
|
||||
/** 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.
|
||||
@@ -548,23 +562,28 @@ crypto_pk_free(crypto_pk_t *env)
|
||||
crypto_cipher_t *
|
||||
crypto_cipher_new_with_iv(const char *key, const char *iv)
|
||||
{
|
||||
crypto_cipher_t *env;
|
||||
tor_assert(key);
|
||||
tor_assert(iv);
|
||||
|
||||
env = aes_new_cipher((const uint8_t*)key, (const uint8_t*)iv, 128);
|
||||
|
||||
return env;
|
||||
return crypto_cipher_new_with_iv_and_bits((uint8_t*)key, (uint8_t*)iv,
|
||||
128);
|
||||
}
|
||||
|
||||
/** Return a new crypto_cipher_t with the provided <b>key</b> and an IV of all
|
||||
* zero bytes. */
|
||||
* zero bytes and key length <b>bits</b>. Key length must be 128, 192, or
|
||||
* 256. */
|
||||
crypto_cipher_t *
|
||||
crypto_cipher_new(const char *key)
|
||||
crypto_cipher_new_with_bits(const char *key, int bits)
|
||||
{
|
||||
char zeroiv[CIPHER_IV_LEN];
|
||||
memset(zeroiv, 0, sizeof(zeroiv));
|
||||
return crypto_cipher_new_with_iv(key, zeroiv);
|
||||
return crypto_cipher_new_with_iv_and_bits((uint8_t*)key, (uint8_t*)zeroiv,
|
||||
bits);
|
||||
}
|
||||
|
||||
/** Return a new crypto_cipher_t with the provided <b>key</b> (of
|
||||
* CIPHER_KEY_LEN bytes) and an IV of all zero bytes. */
|
||||
crypto_cipher_t *
|
||||
crypto_cipher_new(const char *key)
|
||||
{
|
||||
return crypto_cipher_new_with_bits(key, 128);
|
||||
}
|
||||
|
||||
/** Free a symmetric cipher.
|
||||
|
||||
@@ -138,7 +138,11 @@ void crypto_pk_free(crypto_pk_t *env);
|
||||
|
||||
void crypto_set_tls_dh_prime(void);
|
||||
crypto_cipher_t *crypto_cipher_new(const char *key);
|
||||
crypto_cipher_t *crypto_cipher_new_with_bits(const char *key, int bits);
|
||||
crypto_cipher_t *crypto_cipher_new_with_iv(const char *key, const char *iv);
|
||||
crypto_cipher_t *crypto_cipher_new_with_iv_and_bits(const uint8_t *key,
|
||||
const uint8_t *iv,
|
||||
int bits);
|
||||
void crypto_cipher_free(crypto_cipher_t *env);
|
||||
|
||||
/* public key crypto */
|
||||
|
||||
Reference in New Issue
Block a user