[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master] crypto_cipher_set_key cannot fail



Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date: Tue, 27 Oct 2009 04:31:23 +0100
Subject: crypto_cipher_set_key cannot fail
Commit: 70abd843fd006cd25dadd388e5f4ff753c3a4668

In 5e4d53d535a3cc9903250b3df0caa829f1c5e4bf we made it so that
crypto_cipher_set_key cannot fail. The call will now
always succeed, to returning a boolean for success/failure makes
no sense.
---
 src/common/crypto.c |    9 ++-------
 src/common/crypto.h |    2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index 4c880f6..bc1eb38 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -426,10 +426,7 @@ crypto_create_init_cipher(const char *key, int encrypt_mode)
     return NULL;
   }
 
-  if (crypto_cipher_set_key(crypto, key)) {
-    crypto_log_errors(LOG_WARN, "setting symmetric key");
-    goto error;
-  }
+  crypto_cipher_set_key(crypto, key);
 
   if (encrypt_mode)
     r = crypto_cipher_encrypt_init_cipher(crypto);
@@ -1252,16 +1249,14 @@ crypto_cipher_generate_key(crypto_cipher_env_t *env)
 
 /** Set the symmetric key for the cipher in <b>env</b> to the first
  * CIPHER_KEY_LEN bytes of <b>key</b>. Does not initialize the cipher.
- * Return 0 on success, -1 on failure.
  */
-int
+void
 crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key)
 {
   tor_assert(env);
   tor_assert(key);
 
   memcpy(env->key, key, CIPHER_KEY_LEN);
-  return 0;
 }
 
 /** Generate an initialization vector for our AES-CTR cipher; store it
diff --git a/src/common/crypto.h b/src/common/crypto.h
index d9adb16..239acb5 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -151,7 +151,7 @@ int crypto_pk_check_fingerprint_syntax(const char *s);
 
 /* symmetric crypto */
 int crypto_cipher_generate_key(crypto_cipher_env_t *env);
-int crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key);
+void crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key);
 void crypto_cipher_generate_iv(char *iv_out);
 int crypto_cipher_set_iv(crypto_cipher_env_t *env, const char *iv);
 const char *crypto_cipher_get_key(crypto_cipher_env_t *env);
-- 
1.5.6.5