[or-cvs] Make init_cpath_crypto able to handle both sides of handsha...

Nick Mathewson nickm at seul.org
Mon Apr 5 20:53:06 UTC 2004


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

Modified Files:
	circuit.c 
Log Message:
Make init_cpath_crypto able to handle both sides of handshake, by adding a "reverse" flag

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- circuit.c	5 Apr 2004 00:47:47 -0000	1.182
+++ circuit.c	5 Apr 2004 20:53:04 -0000	1.183
@@ -1398,10 +1398,15 @@
  *       20 to initialize b_digest
  *       16 to key f_crypto
  *       16 to key b_crypto
+ *
+ * (If 'reverse' is true, then f_XX and b_XX are swapped.)
  */
-int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data)
+int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
 {
   unsigned char iv[CIPHER_IV_LEN];
+  crypto_digest_env_t *tmp_digest;
+  crypto_cipher_env_t *tmp_crypto;
+
   assert(cpath && key_data);
   assert(!(cpath->f_crypto || cpath->b_crypto ||
            cpath->f_digest || cpath->b_digest));
@@ -1426,6 +1431,15 @@
     return -1;
   }
 
+  if (reverse) {
+    tmp_digest = cpath->f_digest;
+    cpath->f_digest = cpath->b_digest;
+    cpath->b_digest = tmp_digest;
+    tmp_crypto = cpath->f_crypto;
+    cpath->f_crypto = cpath->b_crypto;
+    cpath->b_crypto = tmp_crypto;
+  }
+
   return 0;
 }
 
@@ -1457,7 +1471,7 @@
   /* Remember hash of g^xy */
   memcpy(hop->handshake_digest, reply+DH_KEY_LEN, DIGEST_LEN);
 
-  if (circuit_init_cpath_crypto(hop, keys)<0) {
+  if (circuit_init_cpath_crypto(hop, keys, 0)<0) {
     return -1;
   }
 



More information about the tor-commits mailing list