summaryrefslogtreecommitdiff
path: root/src/or/onion_fast.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-04 16:51:31 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-03 11:29:02 -0500
commit5fa1c7484cba293e6467acbca06a4143ce9da68d (patch)
tree5a7c2003488b5882882bb8a31b9080c03080291a /src/or/onion_fast.c
parentf7e590df05b1b3568a68ee3eae3965cb58e13de7 (diff)
downloadtor-5fa1c7484cba293e6467acbca06a4143ce9da68d.tar.gz
tor-5fa1c7484cba293e6467acbca06a4143ce9da68d.zip
Refactor the CREATE_FAST handshake code to match the others.
Diffstat (limited to 'src/or/onion_fast.c')
-rw-r--r--src/or/onion_fast.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/or/onion_fast.c b/src/or/onion_fast.c
index 8d09de7b7c..f33b048c28 100644
--- a/src/or/onion_fast.c
+++ b/src/or/onion_fast.c
@@ -12,6 +12,28 @@
#include "or.h"
#include "onion_fast.h"
+/**DOCDOC*/
+void
+fast_handshake_state_free(fast_handshake_state_t *victim)
+{
+ if (! victim)
+ return;
+ memwipe(victim, 0, sizeof(fast_handshake_state_t));
+ tor_free(victim);
+}
+
+/** DOCDOC */
+int
+fast_onionskin_create(fast_handshake_state_t **handshake_state_out,
+ uint8_t *handshake_out)
+{
+ fast_handshake_state_t *s;
+ *handshake_state_out = s =tor_malloc(sizeof(fast_handshake_state_t));
+ crypto_rand((char*)s->state, sizeof(s->state));
+ memcpy(handshake_out, s->state, DIGEST_LEN);
+ return 0;
+}
+
/** Implement the server side of the CREATE_FAST abbreviated handshake. The
* client has provided DIGEST_LEN key bytes in <b>key_in</b> ("x"). We
* generate a reply of DIGEST_LEN*2 bytes in <b>key_out</b>, consisting of a
@@ -63,7 +85,7 @@ fast_server_handshake(const uint8_t *key_in, /* DIGEST_LEN bytes */
* and protected by TLS).
*/
int
-fast_client_handshake(const uint8_t *handshake_state,/*DIGEST_LEN bytes*/
+fast_client_handshake(const fast_handshake_state_t *handshake_state,
const uint8_t *handshake_reply_out,/*DIGEST_LEN*2 bytes*/
uint8_t *key_out,
size_t key_out_len)
@@ -73,7 +95,7 @@ fast_client_handshake(const uint8_t *handshake_state,/*DIGEST_LEN bytes*/
size_t out_len;
int r = -1;
- memcpy(tmp, handshake_state, DIGEST_LEN);
+ memcpy(tmp, handshake_state->state, DIGEST_LEN);
memcpy(tmp+DIGEST_LEN, handshake_reply_out, DIGEST_LEN);
out_len = key_out_len+DIGEST_LEN;
out = tor_malloc(out_len);