commit b1bdecd703879ca09bf63bf1453a70c4b80ac96d Merge: ee41826 d3de0b9 Author: Nick Mathewson nickm@torproject.org Date: Thu Jan 3 11:52:41 2013 -0500
Merge branch 'ntor-resquashed'
Conflicts: src/or/cpuworker.c src/or/or.h src/test/bench.c
.gitignore | 7 +- changes/ntor | 40 + configure.ac | 99 +++ doc/tor.1.txt | 10 + src/common/crypto.c | 163 +++- src/common/crypto.h | 13 +- src/common/crypto_curve25519.c | 180 ++++ src/common/crypto_curve25519.h | 61 ++ src/common/di_ops.c | 89 ++ src/common/di_ops.h | 16 + src/common/include.am | 26 +- src/ext/README | 5 +- src/ext/curve25519_donna/README | 44 + src/ext/curve25519_donna/curve25519-donna-c64.c | 449 ++++++++++ src/ext/curve25519_donna/curve25519-donna.c | 730 ++++++++++++++++ src/or/channeltls.c | 2 + src/or/circuitbuild.c | 330 +++++--- src/or/circuitbuild.h | 16 +- src/or/circuitlist.c | 13 +- src/or/circuituse.c | 4 +- src/or/command.c | 75 ++- src/or/config.c | 1 + src/or/cpuworker.c | 205 +++-- src/or/cpuworker.h | 3 +- src/or/dirserv.c | 3 +- src/or/dirvote.c | 9 + src/or/dirvote.h | 6 +- src/or/entrynodes.c | 2 +- src/or/include.am | 15 +- src/or/microdesc.c | 1 + src/or/nodelist.c | 12 + src/or/nodelist.h | 1 + src/or/onion.c | 1032 +++++++++++++++++------ src/or/onion.h | 118 ++- src/or/onion_fast.c | 123 +++ src/or/onion_fast.h | 38 + src/or/onion_ntor.c | 295 +++++++ src/or/onion_ntor.h | 63 ++ src/or/onion_tap.c | 218 +++++ src/or/onion_tap.h | 37 + src/or/or.h | 64 +- src/or/relay.c | 28 +- src/or/rendclient.c | 14 +- src/or/rendmid.c | 4 +- src/or/rendservice.c | 14 +- src/or/router.c | 224 +++++- src/or/router.h | 6 + src/or/routerlist.c | 1 + src/or/routerparse.c | 36 + src/test/bench.c | 143 ++++- src/test/include.am | 19 +- src/test/ntor_ref.py | 387 +++++++++ src/test/test.c | 77 ++- src/test/test_cell_formats.c | 502 +++++++++++ src/test/test_containers.c | 45 + src/test/test_crypto.c | 181 ++++ src/test/test_ntor_cl.c | 166 ++++ src/test/test_util.c | 10 + src/tools/include.am | 2 + 59 files changed, 5876 insertions(+), 601 deletions(-)
diff --cc src/or/config.c index 6086621,979d09c..9905a94 --- a/src/or/config.c +++ b/src/or/config.c @@@ -388,8 -382,8 +388,9 @@@ static config_var_t option_vars_[] = V(UpdateBridgesFromAuthority, BOOL, "0"), V(UseBridges, BOOL, "0"), V(UseEntryGuards, BOOL, "1"), + V(UseEntryGuardsAsDirGuards, BOOL, "1"), V(UseMicrodescriptors, AUTOBOOL, "auto"), + V(UseNTorHandshake, AUTOBOOL, "auto"), V(User, STRING, NULL), V(UserspaceIOCPBuffers, BOOL, "0"), VAR("V1AuthoritativeDirectory",BOOL, V1AuthoritativeDir, "0"), diff --cc src/or/or.h index bc2cdae,b5718a8..7b8ff70 --- a/src/or/or.h +++ b/src/or/or.h @@@ -2553,10 -2534,22 +2570,24 @@@ typedef enum MICRODESC_DIRINFO=1 << 6, } dirinfo_type_t;
+#define ALL_DIRINFO ((dirinfo_type_t)((1<<7)-1)) + #define CRYPT_PATH_MAGIC 0x70127012u
+ struct fast_handshake_state_t; + struct ntor_handshake_state_t; + #define ONION_HANDSHAKE_TYPE_TAP 0x0000 + #define ONION_HANDSHAKE_TYPE_FAST 0x0001 + #define ONION_HANDSHAKE_TYPE_NTOR 0x0002 + typedef struct { + uint16_t tag; + union { + struct fast_handshake_state_t *fast; + crypto_dh_t *tap; + struct ntor_handshake_state_t *ntor; + } u; + } onion_handshake_state_t; + /** Holds accounting information for a single step in the layered encryption * performed by a circuit. Used only at the client edge of a circuit. */ typedef struct crypt_path_t { @@@ -2735,26 -2724,13 +2762,24 @@@ typedef struct circuit_t * more. */ int deliver_window;
- /** For storage while n_chan is pending - * (state CIRCUIT_STATE_CHAN_WAIT). When defined, it is always - * length ONIONSKIN_CHALLENGE_LEN. */ - char *n_chan_onionskin; + /** For storage while n_chan is pending (state CIRCUIT_STATE_CHAN_WAIT). */ + struct create_cell_t *n_chan_create_cell;
- /** When was this circuit created? We keep this timestamp with a higher - * resolution than most so that the circuit-build-time tracking code can - * get millisecond resolution. */ + /** When did circuit construction actually begin (ie send the + * CREATE cell or begin cannibalization). + * + * Note: This timer will get reset if we decide to cannibalize + * a circuit. It may also get reset during certain phases of hidden + * service circuit use. + * + * We keep this timestamp with a higher resolution than most so that the + * circuit-build-time tracking code can get millisecond resolution. + */ + struct timeval timestamp_began; + + /** This timestamp marks when the init_circuit_base constructor ran. */ struct timeval timestamp_created; + /** When the circuit was first used, or 0 if the circuit is clean. * * XXXX023 Note that some code will artifically adjust this value backward @@@ -3875,8 -3802,8 +3901,10 @@@ typedef struct
int IPv6Exit; /**< Do we support exiting to IPv6 addresses? */
+ char *TLSECGroup; /**< One of "P256", "P224", or nil for auto */ + + /** Autobool: should we use the ntor handshake if we can? */ + int UseNTorHandshake; } or_options_t;
/** Persistent state for an onion router, as saved to disk. */ diff --cc src/or/rendservice.c index e70f969,4f3fdf4..fc76f56 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@@ -1382,11 -1382,8 +1382,11 @@@ rend_service_introduce(origin_circuit_ dh = NULL; if (circuit_init_cpath_crypto(cpath,keys+DIGEST_LEN,1)<0) goto err; - memcpy(cpath->handshake_digest, keys, DIGEST_LEN); + memcpy(cpath->rend_circ_nonce, keys, DIGEST_LEN);
+ /* For path bias: This intro circuit was used successfully */ + circuit->path_state = PATH_STATE_USE_SUCCEEDED; + goto done;
log_error: diff --cc src/test/bench.c index da1ae9b,2c40cdf..8b91b07 --- a/src/test/bench.c +++ b/src/test/bench.c @@@ -15,17 -15,15 +15,23 @@@ const char tor_git_revision[] = "" #include "orconfig.h"
#define RELAY_PRIVATE + #define CONFIG_PRIVATE
#include "or.h" + #include "onion_tap.h" #include "relay.h" +#include <openssl/opensslv.h> +#include <openssl/evp.h> - #if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,0,0) +#ifndef OPENSSL_NO_EC +#include <openssl/ec.h> +#include <openssl/ecdh.h> +#include <openssl/obj_mac.h> +#endif ++ + #include "config.h" + #ifdef CURVE25519_ENABLED + #include "crypto_curve25519.h" + #include "onion_ntor.h" #endif
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) @@@ -355,13 -387,12 +480,17 @@@ typedef struct benchmark_t static struct benchmark_t benchmarks[] = { ENT(dmap), ENT(aes), + ENT(onion_TAP), + #ifdef CURVE25519_ENABLED + ENT(onion_ntor), + #endif ENT(cell_aes), ENT(cell_ops), + ENT(dh), +#ifdef HAVE_EC_BENCHMARKS + ENT(ecdh_p256), + ENT(ecdh_p224), +#endif {NULL,NULL,0} };
tor-commits@lists.torproject.org