[or-cvs] Do first half of Alice-side of DH handshake.
Nick Mathewson
nickm at seul.org
Mon Apr 5 20:30:55 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv20209/src/or
Modified Files:
rendclient.c
Log Message:
Do first half of Alice-side of DH handshake.
Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rendclient.c 5 Apr 2004 18:22:00 -0000 1.13
+++ rendclient.c 5 Apr 2004 20:30:53 -0000 1.14
@@ -50,6 +50,7 @@
char payload[LEN_REND_INTRODUCE1];
char tmp[20+20+128];
rend_service_descriptor_t *parsed=NULL;
+ crypt_path_t *cpath;
assert(introcirc->purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
assert(rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY);
@@ -73,12 +74,25 @@
goto err;
}
+ /* Initialize the pending_final_cpath and start the DH handshake. */
+ cpath = rendcirc->build_state->pending_final_cpath =
+ tor_malloc_zero(sizeof(crypt_path_t));
+ if (!(cpath->handshake_state = crypto_dh_new())) {
+ log_fn(LOG_WARN, "Couldn't allocate DH");
+ goto err;
+ }
+ if (crypto_dh_generate_public(cpath->handshake_state)<0) {
+ log_fn(LOG_WARN, "Couldn't generate g^x");
+ goto err;
+ }
+
/* write the remaining items into tmp */
strncpy(tmp, rendcirc->build_state->chosen_exit, 20); /* nul pads */
memcpy(tmp+20, rendcirc->rend_cookie, 20);
- memset(tmp+40, 0, 128); /* XXX g^x is all zero's for now */
-
- /* XXX copy the appropriate stuff into rendcirc's pending_final_cpath */
+ if (crypto_dh_get_public(cpath->handshake_state, tmp+40, 128)<0) {
+ log_fn(LOG_WARN, "Couldn't extract g^x");
+ goto err;
+ }
if(crypto_pk_public_hybrid_encrypt(parsed->pk, tmp,
20+20+128, payload+20,
More information about the tor-commits
mailing list