summaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-03-20 15:35:43 -0400
committerNick Mathewson <nickm@torproject.org>2012-03-27 22:37:56 -0400
commitde0dca0de76d9d50aeb5955fe3f435c6c190f8d7 (patch)
tree8d7005e768bc04ac1695b72cf3970d552570016f /src/or/rendcommon.c
parent00b4784575c88d5de15886b440096c1e2b9fb080 (diff)
downloadtor-de0dca0de76d9d50aeb5955fe3f435c6c190f8d7.tar.gz
tor-de0dca0de76d9d50aeb5955fe3f435c6c190f8d7.zip
Refactor the API for setting up a block cipher.
It allows us more flexibility on the backend if the user needs to specify the key and IV at setup time.
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 9c7bf518d1..20bbdafec9 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -290,11 +290,10 @@ rend_encrypt_v2_intro_points_basic(char **encrypted_out,
enc[1] = (uint8_t)client_blocks;
/* Encrypt with random session key. */
- cipher = crypto_create_init_cipher(session_key, 1);
- enclen = crypto_cipher_encrypt_with_iv(cipher,
+ enclen = crypto_cipher_encrypt_with_iv(session_key,
enc + 2 + client_entries_len,
CIPHER_IV_LEN + strlen(encoded), encoded, strlen(encoded));
- crypto_cipher_free(cipher);
+
if (enclen < 0) {
log_warn(LD_REND, "Could not encrypt introduction point string.");
goto done;
@@ -307,7 +306,7 @@ rend_encrypt_v2_intro_points_basic(char **encrypted_out,
SMARTLIST_FOREACH_BEGIN(client_cookies, const char *, cookie) {
client_part = tor_malloc_zero(REND_BASIC_AUTH_CLIENT_ENTRY_LEN);
/* Encrypt session key. */
- cipher = crypto_create_init_cipher(cookie, 1);
+ cipher = crypto_cipher_new(cookie);
if (crypto_cipher_encrypt(cipher, client_part +
REND_BASIC_AUTH_CLIENT_ID_LEN,
session_key, CIPHER_KEY_LEN) < 0) {
@@ -374,18 +373,16 @@ rend_encrypt_v2_intro_points_stealth(char **encrypted_out,
const char *descriptor_cookie)
{
int r = -1, enclen;
- crypto_cipher_t *cipher;
char *enc;
tor_assert(encoded);
tor_assert(descriptor_cookie);
enc = tor_malloc_zero(1 + CIPHER_IV_LEN + strlen(encoded));
enc[0] = 0x02; /* Auth type */
- cipher = crypto_create_init_cipher(descriptor_cookie, 1);
- enclen = crypto_cipher_encrypt_with_iv(cipher, enc + 1,
+ enclen = crypto_cipher_encrypt_with_iv(descriptor_cookie,
+ enc + 1,
CIPHER_IV_LEN+strlen(encoded),
encoded, strlen(encoded));
- crypto_cipher_free(cipher);
if (enclen < 0) {
log_warn(LD_REND, "Could not encrypt introduction point string.");
goto done;