diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-28 20:31:32 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-28 20:31:32 +0000 |
commit | ddb15b8f679c0c6b095a734947fe3ae668607887 (patch) | |
tree | c60355dee5276253aff49bf5adf782e4fcba79ed /src/common/crypto.c | |
parent | 5d1510883ea583b12b1d66156c31f03700c79245 (diff) | |
download | tor-ddb15b8f679c0c6b095a734947fe3ae668607887.tar.gz tor-ddb15b8f679c0c6b095a734947fe3ae668607887.zip |
Remove IVs from cipher code, since AES-ctr has none.
svn:r1742
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index cc88f9686a..99d6d79367 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -78,7 +78,6 @@ struct crypto_pk_env_t struct crypto_cipher_env_t { unsigned char key[CIPHER_KEY_LEN]; - unsigned char iv[_ARRAYSIZE(CIPHER_IV_LEN)]; aes_cnt_cipher_t *cipher; }; @@ -214,13 +213,12 @@ void crypto_free_pk_env(crypto_pk_env_t *env) free(env); } - /* Create a new crypto_cipher_env_t for a given onion cipher type, key, * iv, and encryption flag (1=encrypt, 0=decrypt). Return the crypto object * on success; NULL on failure. */ crypto_cipher_env_t * -crypto_create_init_cipher(const char *key, const char *iv, int encrypt_mode) +crypto_create_init_cipher(const char *key, int encrypt_mode) { int r; crypto_cipher_env_t *crypto = NULL; @@ -235,11 +233,6 @@ crypto_create_init_cipher(const char *key, const char *iv, int encrypt_mode) goto error; } - if (crypto_cipher_set_iv(crypto, iv)) { - crypto_log_errors(LOG_WARN, "setting IV"); - goto error; - } - if (encrypt_mode) r = crypto_cipher_encrypt_init_cipher(crypto); else @@ -653,7 +646,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env, log_fn(LOG_WARN, "No room for a symmetric key"); return -1; } - cipher = crypto_create_init_cipher(buf, NULL, 0); + cipher = crypto_create_init_cipher(buf, 0); if (!cipher) { return -1; } @@ -800,21 +793,6 @@ int crypto_cipher_generate_key(crypto_cipher_env_t *env) return crypto_rand(CIPHER_KEY_LEN, env->key); } -int crypto_cipher_set_iv(crypto_cipher_env_t *env, const unsigned char *iv) -{ - tor_assert(env && (CIPHER_IV_LEN==0 || iv)); - - if (!CIPHER_IV_LEN) - return 0; - - if (!env->iv) - return -1; - - memcpy(env->iv, iv, CIPHER_IV_LEN); - - return 0; -} - int crypto_cipher_set_key(crypto_cipher_env_t *env, const unsigned char *key) { tor_assert(env && key); |