[or-cvs] Remove IVs from cipher code, since AES-ctr has none.
Nick Mathewson
nickm at seul.org
Wed Apr 28 20:31:34 UTC 2004
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv17813/src/common
Modified Files:
crypto.c crypto.h util.h
Log Message:
Remove IVs from cipher code, since AES-ctr has none.
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- crypto.c 28 Apr 2004 20:22:37 -0000 1.85
+++ crypto.c 28 Apr 2004 20:31:32 -0000 1.86
@@ -78,7 +78,6 @@
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 @@
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 @@
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 @@
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 @@
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);
Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- crypto.h 26 Apr 2004 18:09:49 -0000 1.41
+++ crypto.h 28 Apr 2004 20:31:32 -0000 1.42
@@ -9,7 +9,6 @@
#define DIGEST_LEN 20
#define CIPHER_KEY_LEN 16
-#define CIPHER_IV_LEN 0
#define PK_BITS 1024
#define PK_BYTES (PK_BITS/8)
#define DH_BITS 1024
@@ -90,7 +89,6 @@
/* symmetric crypto */
int crypto_cipher_generate_key(crypto_cipher_env_t *env);
-int crypto_cipher_set_iv(crypto_cipher_env_t *env, const unsigned char *iv);
int crypto_cipher_set_key(crypto_cipher_env_t *env, const unsigned char *key);
int crypto_cipher_encrypt_init_cipher(crypto_cipher_env_t *env);
int crypto_cipher_decrypt_init_cipher(crypto_cipher_env_t *env);
@@ -103,8 +101,8 @@
int crypto_cipher_rewind(crypto_cipher_env_t *env, long delta);
int crypto_cipher_advance(crypto_cipher_env_t *env, long delta);
-/* convenience function: wraps crypto_create_crypto_env, set_key, set_iv, and init. */
-crypto_cipher_env_t *crypto_create_init_cipher(const char *key, const char *iv, int encrypt_mode);
+/* convenience function: wraps crypto_create_crypto_env, set_key, and init. */
+crypto_cipher_env_t *crypto_create_init_cipher(const char *key, int encrypt_mode);
/* SHA-1 */
int crypto_digest(const unsigned char *m, int len, unsigned char *digest);
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- util.h 28 Apr 2004 20:18:22 -0000 1.59
+++ util.h 28 Apr 2004 20:31:32 -0000 1.60
@@ -36,14 +36,12 @@
#define strncasecmp strnicmp
#define strcasecmp stricmp
#define INLINE __inline
-#define _ARRAYSIZE(x) (((x)==0)?1:(x))
/* Windows compilers before VC7 don't have __FUNCTION__. */
#if _MSC_VER < 1300
#define __FUNCTION__ "???"
#endif
#else
#define INLINE inline
-#define _ARRAYSIZE(x) (x)
#endif
#ifdef NDEBUG
More information about the tor-commits
mailing list