[or-cvs] Make crypto structures private to crypto.c

Nick Mathewson nickm at seul.org
Wed Sep 10 00:47:27 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv20645/src/or

Modified Files:
	connection_or.c test.c 
Log Message:
Make crypto structures private to crypto.c

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- connection_or.c	8 Sep 2003 10:59:00 -0000	1.43
+++ connection_or.c	10 Sep 2003 00:47:24 -0000	1.44
@@ -249,9 +249,9 @@
   /* compose the message */
   *(uint16_t *)(message) = htons(HANDSHAKE_AS_OP);
   memcpy((void *)(message+FLAGS_LEN), 
-         (void *)conn->f_crypto->key, 16);
+         (void *)crypto_cipher_get_key(conn->f_crypto), 16);
   memcpy((void *)(message+FLAGS_LEN+KEY_LEN), 
-         (void *)conn->b_crypto->key, 16);
+         (void *)crypto_cipher_get_key(conn->b_crypto), 16);
 
   /* encrypt with RSA */
   if(crypto_pk_public_encrypt(conn->pkey, message, sizeof(message), cipher, RSA_PKCS1_PADDING) < 0) {
@@ -322,9 +322,9 @@
   *(uint32_t*)(buf+FLAGS_LEN+ADDR_LEN+PORT_LEN) = htonl(conn->addr); /* remote address */
   *(uint16_t*)(buf+FLAGS_LEN+ADDR_LEN+PORT_LEN+ADDR_LEN) = htons(conn->port); /* remote port */
   memcpy(buf+FLAGS_LEN+ADDR_LEN+PORT_LEN+ADDR_LEN+PORT_LEN,
-         conn->f_crypto->key,16); /* keys */
+         crypto_cipher_get_key(conn->f_crypto),16); /* keys */
   memcpy(buf+FLAGS_LEN+ADDR_LEN+PORT_LEN+ADDR_LEN+PORT_LEN+KEY_LEN,
-         conn->b_crypto->key,16);
+         crypto_cipher_get_key(conn->b_crypto),16);
   log(LOG_DEBUG,"or_handshake_client_send_auth() : Generated first authentication message.");
 
   /* encrypt message */
@@ -406,8 +406,8 @@
     log(LOG_ERR,"client_process_auth: Router %s:%u: bad address info.", conn->address,conn->port);
     return -1;
   }
-  if ( (memcmp(conn->f_crypto->key, buf+12, 16)) || /* keys */
-       (memcmp(conn->b_crypto->key, buf+28, 16)) ) {
+  if ( (memcmp(crypto_cipher_get_key(conn->f_crypto), buf+12, 16)) ||/* keys */
+       (memcmp(crypto_cipher_get_key(conn->b_crypto), buf+28, 16)) ) {
     log(LOG_ERR,"client_process_auth: Router %s:%u: bad key info.",conn->address,conn->port);
     return -1;
   }

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- test.c	28 Aug 2003 04:21:57 -0000	1.36
+++ test.c	10 Sep 2003 00:47:24 -0000	1.37
@@ -269,7 +269,7 @@
     test_neq(env2, 0);
     j = crypto_cipher_generate_key(env1);
     if (str_ciphers[i] != CRYPTO_CIPHER_IDENTITY) {
-      crypto_cipher_set_key(env2, env1->key);
+      crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
     }
     crypto_cipher_set_iv(env1, "12345678901234567890");
     crypto_cipher_set_iv(env2, "12345678901234567890");
@@ -309,7 +309,7 @@
     env2 = crypto_new_cipher_env(str_ciphers[i]);
     test_neq(env2, 0);
     if (str_ciphers[i] != CRYPTO_CIPHER_IDENTITY) {
-      crypto_cipher_set_key(env2, env1->key);
+      crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
     }
     crypto_cipher_set_iv(env2, "12345678901234567890");
     crypto_cipher_encrypt_init_cipher(env2);



More information about the tor-commits mailing list