aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-08 00:52:44 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-03 11:29:48 -0500
commitc46ff3ec79420a6d94207cbe0d4e4d08208ccc4c (patch)
treeaf359a09798445e200e437fe9564e75deee8dc2b /src/or
parent839016ac791de98c02ad7eab50092deedde0ad55 (diff)
downloadtor-c46ff3ec79420a6d94207cbe0d4e4d08208ccc4c.tar
tor-c46ff3ec79420a6d94207cbe0d4e4d08208ccc4c.tar.gz
Add reference implementation for ntor, plus compatibility test
Before I started coding ntor in C, I did another one in Python. Turns out, they interoperate just fine.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/onion_ntor.c18
-rw-r--r--src/or/onion_ntor.h19
2 files changed, 21 insertions, 16 deletions
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index 3f4faf3fa..8eab55acf 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -3,26 +3,12 @@
#include "orconfig.h"
-#include "onion_ntor.h"
#include "crypto.h"
+#define ONION_NTOR_PRIVATE
+#include "onion_ntor.h"
#include "torlog.h"
#include "util.h"
-/** Storage held by a client while waiting for an ntor reply from a server. */
-struct ntor_handshake_state_t {
- /** Identity digest of the router we're talking to. */
- uint8_t router_id[DIGEST_LEN];
- /** Onion key of the router we're talking to. */
- curve25519_public_key_t pubkey_B;
-
- /**
- * Short-lived keypair for use with this handshake.
- * @{ */
- curve25519_secret_key_t seckey_x;
- curve25519_public_key_t pubkey_X;
- /** @} */
-};
-
/** Free storage held in an ntor handshake state. */
void
ntor_handshake_state_free(ntor_handshake_state_t *state)
diff --git a/src/or/onion_ntor.h b/src/or/onion_ntor.h
index a5cceb94d..61ff5c0ad 100644
--- a/src/or/onion_ntor.h
+++ b/src/or/onion_ntor.h
@@ -38,6 +38,25 @@ int onion_skin_ntor_client_handshake(
const uint8_t *handshake_reply,
uint8_t *key_out,
size_t key_out_len);
+
+#ifdef ONION_NTOR_PRIVATE
+
+/** Storage held by a client while waiting for an ntor reply from a server. */
+struct ntor_handshake_state_t {
+ /** Identity digest of the router we're talking to. */
+ uint8_t router_id[DIGEST_LEN];
+ /** Onion key of the router we're talking to. */
+ curve25519_public_key_t pubkey_B;
+
+ /**
+ * Short-lived keypair for use with this handshake.
+ * @{ */
+ curve25519_secret_key_t seckey_x;
+ curve25519_public_key_t pubkey_X;
+ /** @} */
+};
+#endif
+
#endif
#endif