[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/or
In directory moria.mit.edu:/tmp/cvs-serv17813/src/or

Modified Files:
	circuit.c test.c 
Log Message:
Remove IVs from cipher code, since AES-ctr has none.

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -d -r1.226 -r1.227
--- circuit.c	28 Apr 2004 20:13:21 -0000	1.226
+++ circuit.c	28 Apr 2004 20:31:32 -0000	1.227
@@ -1627,7 +1627,6 @@
  */
 int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
 {
-  unsigned char iv[_ARRAYSIZE(CIPHER_IV_LEN)];
   crypto_digest_env_t *tmp_digest;
   crypto_cipher_env_t *tmp_crypto;
 
@@ -1635,8 +1634,6 @@
   tor_assert(!(cpath->f_crypto || cpath->b_crypto ||
              cpath->f_digest || cpath->b_digest));
 
-  memset(iv, 0, CIPHER_IV_LEN);
-
   log_fn(LOG_DEBUG,"hop init digest forward 0x%.8x, backward 0x%.8x.",
          (unsigned int)*(uint32_t*)key_data, (unsigned int)*(uint32_t*)(key_data+20));
   cpath->f_digest = crypto_new_digest_env();
@@ -1647,12 +1644,12 @@
   log_fn(LOG_DEBUG,"hop init cipher forward 0x%.8x, backward 0x%.8x.",
          (unsigned int)*(uint32_t*)(key_data+40), (unsigned int)*(uint32_t*)(key_data+40+16));
   if (!(cpath->f_crypto =
-        crypto_create_init_cipher(key_data+(2*DIGEST_LEN),iv,1))) {
+        crypto_create_init_cipher(key_data+(2*DIGEST_LEN),1))) {
     log(LOG_WARN,"forward cipher initialization failed.");
     return -1;
   }
   if (!(cpath->b_crypto =
-     crypto_create_init_cipher(key_data+(2*DIGEST_LEN)+CIPHER_KEY_LEN,iv,0))) {
+     crypto_create_init_cipher(key_data+(2*DIGEST_LEN)+CIPHER_KEY_LEN,0))) {
     log(LOG_WARN,"backward cipher initialization failed.");
     return -1;
   }

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- test.c	26 Apr 2004 18:09:50 -0000	1.84
+++ test.c	28 Apr 2004 20:31:32 -0000	1.85
@@ -260,7 +260,6 @@
   env1 = crypto_new_cipher_env(CRYPTO_CIPHER_IDENTITY);
   test_neq(env1, 0);
   test_eq(crypto_cipher_generate_key(env1), 0);
-  test_eq(crypto_cipher_set_iv(env1, ""), 0);
   test_eq(crypto_cipher_encrypt_init_cipher(env1), 0);
   for(i = 0; i < 1024; ++i) {
     data1[i] = (char) i*73;
@@ -283,8 +282,6 @@
   test_neq(env2, 0);
   j = crypto_cipher_generate_key(env1);
   crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
-  crypto_cipher_set_iv(env1, "12345678901234567890");
-  crypto_cipher_set_iv(env2, "12345678901234567890");
   crypto_cipher_encrypt_init_cipher(env1);
   crypto_cipher_decrypt_init_cipher(env2);
 
@@ -318,7 +315,6 @@
   env2 = crypto_new_cipher_env();
   test_neq(env2, 0);
   crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
-  crypto_cipher_set_iv(env2, "12345678901234567890");
   crypto_cipher_encrypt_init_cipher(env2);
   for (j = 0; j < 1024-16; j += 17) {
     crypto_cipher_encrypt(env2, data1+j, 17, data3+j);



More information about the tor-commits mailing list