Tor 0.4.9.0-alpha-dev
onion_crypto.c
Go to the documentation of this file.
1/* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file onion_crypto.c
9 * \brief Functions to handle different kinds of circuit extension crypto.
10 *
11 * In this module, we provide a set of abstractions to create a uniform
12 * interface over the three circuit extension handshakes that Tor has used
13 * over the years (TAP, CREATE_FAST, and ntor). These handshakes are
14 * implemented in onion_tap.c, onion_fast.c, and onion_ntor.c respectively.
15 *
16 * All[*] of these handshakes follow a similar pattern: a client, knowing
17 * some key from the relay it wants to extend through, generates the
18 * first part of a handshake. A relay receives that handshake, and sends
19 * a reply. Once the client handles the reply, it knows that it is
20 * talking to the right relay, and it shares some freshly negotiated key
21 * material with that relay.
22 *
23 * We sometimes call the client's part of the handshake an "onionskin".
24 * We do this because historically, Onion Routing used a multi-layer
25 * structure called an "onion" to construct circuits. Each layer of the
26 * onion contained key material chosen by the client, the identity of
27 * the next relay in the circuit, and a smaller onion, encrypted with
28 * the key of the next relay. When we changed Tor to use a telescoping
29 * circuit extension design, it corresponded to sending each layer of the
30 * onion separately -- as a series of onionskins.
31 **/
32
33#include "core/or/or.h"
34#include "core/or/extendinfo.h"
45
47
50
51#include "trunnel/congestion_control.h"
52#include "trunnel/extension.h"
53
54static const uint8_t NTOR3_CIRC_VERIFICATION[] = "circuit extend";
55static const size_t NTOR3_CIRC_VERIFICATION_LEN = 14;
56
57#define NTOR3_VERIFICATION_ARGS \
58 NTOR3_CIRC_VERIFICATION, NTOR3_CIRC_VERIFICATION_LEN
59
60/** Return a new server_onion_keys_t object with all of the keys
61 * and other info we might need to do onion handshakes. (We make a copy of
62 * our keys for each cpuworker to avoid race conditions with the main thread,
63 * and to avoid locking) */
66{
67 if (!get_master_identity_key())
68 return NULL;
69
70 server_onion_keys_t *keys = tor_malloc_zero(sizeof(server_onion_keys_t));
71 memcpy(keys->my_identity, router_get_my_id_digest(), DIGEST_LEN);
72 ed25519_pubkey_copy(&keys->my_ed_identity, get_master_identity_key());
73 dup_onion_keys(&keys->onion_key, &keys->last_onion_key);
74 keys->curve25519_key_map = construct_ntor_key_map();
75 keys->junk_keypair = tor_malloc_zero(sizeof(curve25519_keypair_t));
76 curve25519_keypair_generate(keys->junk_keypair, 0);
77 return keys;
78}
79/** Release all storage held in <b>keys</b>. */
80void
82{
83 if (! keys)
84 return;
85
86 crypto_pk_free(keys->onion_key);
87 crypto_pk_free(keys->last_onion_key);
88 ntor_key_map_free(keys->curve25519_key_map);
89 tor_free(keys->junk_keypair);
90 memwipe(keys, 0, sizeof(server_onion_keys_t));
91 tor_free(keys);
92}
93
94/** Release whatever storage is held in <b>state</b>, depending on its
95 * type, and clear its pointer. */
96void
98{
99 switch (state->tag) {
100 case ONION_HANDSHAKE_TYPE_TAP:
101 crypto_dh_free(state->u.tap);
102 state->u.tap = NULL;
103 break;
104 case ONION_HANDSHAKE_TYPE_FAST:
105 fast_handshake_state_free(state->u.fast);
106 state->u.fast = NULL;
107 break;
108 case ONION_HANDSHAKE_TYPE_NTOR:
109 ntor_handshake_state_free(state->u.ntor);
110 state->u.ntor = NULL;
111 break;
112 case ONION_HANDSHAKE_TYPE_NTOR_V3:
113 ntor3_handshake_state_free(state->u.ntor3);
114 break;
115 default:
116 /* LCOV_EXCL_START
117 * This state should not even exist. */
118 log_warn(LD_BUG, "called with unknown handshake state type %d",
119 (int)state->tag);
121 /* LCOV_EXCL_STOP */
122 }
123}
124
125/** Perform the first step of a circuit-creation handshake of type <b>type</b>
126 * (one of ONION_HANDSHAKE_TYPE_*): generate the initial "onion skin" in
127 * <b>onion_skin_out</b> with length of up to <b>onion_skin_out_maxlen</b>,
128 * and store any state information in <b>state_out</b>.
129 * Return -1 on failure, and the length of the onionskin on acceptance.
130 */
131int
133 const extend_info_t *node,
134 onion_handshake_state_t *state_out,
135 uint8_t *onion_skin_out,
136 size_t onion_skin_out_maxlen)
137{
138 int r = -1;
139
140 switch (type) {
141 case ONION_HANDSHAKE_TYPE_TAP:
142 if (onion_skin_out_maxlen < TAP_ONIONSKIN_CHALLENGE_LEN)
143 return -1;
144 if (!node->onion_key)
145 return -1;
146
148 &state_out->u.tap,
149 (char*)onion_skin_out) < 0)
150 return -1;
151
152 r = TAP_ONIONSKIN_CHALLENGE_LEN;
153 break;
154 case ONION_HANDSHAKE_TYPE_FAST:
155 if (fast_onionskin_create(&state_out->u.fast, onion_skin_out) < 0)
156 return -1;
157
158 r = CREATE_FAST_LEN;
159 break;
160 case ONION_HANDSHAKE_TYPE_NTOR:
161 if (onion_skin_out_maxlen < NTOR_ONIONSKIN_LEN)
162 return -1;
163 if (!extend_info_supports_ntor(node))
164 return -1;
165 if (onion_skin_ntor_create((const uint8_t*)node->identity_digest,
167 &state_out->u.ntor,
168 onion_skin_out) < 0)
169 return -1;
170
172 break;
173 case ONION_HANDSHAKE_TYPE_NTOR_V3:
175 return -1;
177 return -1;
178 size_t msg_len = 0;
179 uint8_t *msg = NULL;
180 if (client_circ_negotiation_message(node, &msg, &msg_len) < 0)
181 return -1;
182 uint8_t *onion_skin = NULL;
183 size_t onion_skin_len = 0;
184 int status = onion_skin_ntor3_create(
185 &node->ed_identity,
187 NTOR3_VERIFICATION_ARGS,
188 msg, msg_len, /* client message */
189 &state_out->u.ntor3,
190 &onion_skin, &onion_skin_len);
191 tor_free(msg);
192 if (status < 0) {
193 return -1;
194 }
195 if (onion_skin_len > onion_skin_out_maxlen) {
196 tor_free(onion_skin);
197 return -1;
198 }
199 memcpy(onion_skin_out, onion_skin, onion_skin_len);
200 tor_free(onion_skin);
201 r = (int) onion_skin_len;
202 break;
203
204 default:
205 /* LCOV_EXCL_START
206 * We should never try to create an impossible handshake type. */
207 log_warn(LD_BUG, "called with unknown handshake state type %d", type);
209 r = -1;
210 /* LCOV_EXCL_STOP */
211 }
212
213 if (r > 0)
214 state_out->tag = (uint16_t) type;
215
216 return r;
217}
218
219/**
220 * Takes a param request message from the client, compares it to our
221 * consensus parameters, and creates a reply message and output
222 * parameters.
223 *
224 * This function runs in a worker thread, so it can only inspect
225 * arguments and local variables.
226 *
227 * Returns 0 if successful.
228 * Returns -1 on parsing, parameter failure, or reply creation failure.
229 */
230static int
231negotiate_v3_ntor_server_circ_params(const uint8_t *param_request_msg,
232 size_t param_request_len,
233 const circuit_params_t *our_ns_params,
234 circuit_params_t *params_out,
235 uint8_t **resp_msg_out,
236 size_t *resp_msg_len_out)
237{
238 int ret;
239
240 /* Parse request. */
241 ret = congestion_control_parse_ext_request(param_request_msg,
242 param_request_len);
243 if (ret < 0) {
244 goto err;
245 }
246 params_out->cc_enabled = ret && our_ns_params->cc_enabled;
247
248 /* Build the response. */
249 ret = congestion_control_build_ext_response(our_ns_params, params_out,
250 resp_msg_out, resp_msg_len_out);
251 if (ret < 0) {
252 goto err;
253 }
254 params_out->sendme_inc_cells = our_ns_params->sendme_inc_cells;
255
256 /* Success. */
257 ret = 0;
258
259 err:
260 return ret;
261}
262
263/* This is the maximum value for keys_out_len passed to
264 * onion_skin_server_handshake, plus 16. We can make it bigger if needed:
265 * It just defines how many bytes to stack-allocate. */
266#define MAX_KEYS_TMP_LEN 128
267
268/** Perform the second (server-side) step of a circuit-creation handshake of
269 * type <b>type</b>, responding to the client request in <b>onion_skin</b>
270 * using the keys in <b>keys</b>. On success, write our response into
271 * <b>reply_out</b>, generate <b>keys_out_len</b> bytes worth of key material
272 * in <b>keys_out_len</b>, a hidden service nonce to <b>rend_nonce_out</b>,
273 * and return the length of the reply. On failure, return -1.
274 */
275int
277 const uint8_t *onion_skin, size_t onionskin_len,
278 const server_onion_keys_t *keys,
279 const circuit_params_t *our_ns_params,
280 uint8_t *reply_out,
281 size_t reply_out_maxlen,
282 uint8_t *keys_out, size_t keys_out_len,
283 uint8_t *rend_nonce_out,
284 circuit_params_t *params_out)
285{
286 int r = -1;
287 memset(params_out, 0, sizeof(*params_out));
288
289 switch (type) {
290 case ONION_HANDSHAKE_TYPE_TAP:
291 if (reply_out_maxlen < TAP_ONIONSKIN_REPLY_LEN)
292 return -1;
293 if (onionskin_len != TAP_ONIONSKIN_CHALLENGE_LEN)
294 return -1;
295 if (onion_skin_TAP_server_handshake((const char*)onion_skin,
296 keys->onion_key, keys->last_onion_key,
297 (char*)reply_out,
298 (char*)keys_out, keys_out_len)<0)
299 return -1;
300 r = TAP_ONIONSKIN_REPLY_LEN;
301 memcpy(rend_nonce_out, reply_out+DH1024_KEY_LEN, DIGEST_LEN);
302 break;
303 case ONION_HANDSHAKE_TYPE_FAST:
304 if (reply_out_maxlen < CREATED_FAST_LEN)
305 return -1;
306 if (onionskin_len != CREATE_FAST_LEN)
307 return -1;
308 if (fast_server_handshake(onion_skin, reply_out, keys_out, keys_out_len)<0)
309 return -1;
310 r = CREATED_FAST_LEN;
311 memcpy(rend_nonce_out, reply_out+DIGEST_LEN, DIGEST_LEN);
312 break;
313 case ONION_HANDSHAKE_TYPE_NTOR:
314 if (reply_out_maxlen < NTOR_REPLY_LEN)
315 return -1;
316 if (onionskin_len < NTOR_ONIONSKIN_LEN)
317 return -1;
318 {
319 size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
320 tor_assert(keys_tmp_len <= MAX_KEYS_TMP_LEN);
321 uint8_t keys_tmp[MAX_KEYS_TMP_LEN];
322
324 onion_skin, keys->curve25519_key_map,
325 keys->junk_keypair,
326 keys->my_identity,
327 reply_out, keys_tmp, keys_tmp_len)<0) {
328 /* no need to memwipe here, since the output will never be used */
329 return -1;
330 }
331
332 memcpy(keys_out, keys_tmp, keys_out_len);
333 memcpy(rend_nonce_out, keys_tmp+keys_out_len, DIGEST_LEN);
334 memwipe(keys_tmp, 0, sizeof(keys_tmp));
335 r = NTOR_REPLY_LEN;
336 }
337 break;
338 case ONION_HANDSHAKE_TYPE_NTOR_V3: {
339 size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
340 tor_assert(keys_tmp_len <= MAX_KEYS_TMP_LEN);
341 uint8_t keys_tmp[MAX_KEYS_TMP_LEN];
342 uint8_t *client_msg = NULL;
343 size_t client_msg_len = 0;
344 uint8_t *reply_msg = NULL;
345 size_t reply_msg_len = 0;
346
347 ntor3_server_handshake_state_t *state = NULL;
348
350 keys->curve25519_key_map,
351 keys->junk_keypair,
352 &keys->my_ed_identity,
353 onion_skin, onionskin_len,
354 NTOR3_VERIFICATION_ARGS,
355 &client_msg, &client_msg_len,
356 &state) < 0) {
357 return -1;
358 }
359
361 client_msg_len,
362 our_ns_params,
363 params_out,
364 &reply_msg,
365 &reply_msg_len) < 0) {
366 ntor3_server_handshake_state_free(state);
367 tor_free(client_msg);
368 return -1;
369 }
370 tor_free(client_msg);
371
372 uint8_t *server_handshake = NULL;
373 size_t server_handshake_len = 0;
375 state,
376 NTOR3_VERIFICATION_ARGS,
377 reply_msg, reply_msg_len,
378 &server_handshake, &server_handshake_len,
379 keys_tmp, keys_tmp_len) < 0) {
380 tor_free(reply_msg);
381 ntor3_server_handshake_state_free(state);
382 return -1;
383 }
384 tor_free(reply_msg);
385
386 if (server_handshake_len > reply_out_maxlen) {
387 tor_free(server_handshake);
388 ntor3_server_handshake_state_free(state);
389 return -1;
390 }
391
392 memcpy(keys_out, keys_tmp, keys_out_len);
393 memcpy(rend_nonce_out, keys_tmp+keys_out_len, DIGEST_LEN);
394 memcpy(reply_out, server_handshake, server_handshake_len);
395 memwipe(keys_tmp, 0, keys_tmp_len);
396 memwipe(server_handshake, 0, server_handshake_len);
397 tor_free(server_handshake);
398 ntor3_server_handshake_state_free(state);
399
400 r = (int) server_handshake_len;
401 }
402 break;
403 default:
404 /* LCOV_EXCL_START
405 * We should have rejected this far before this point */
406 log_warn(LD_BUG, "called with unknown handshake state type %d", type);
408 return -1;
409 /* LCOV_EXCL_STOP */
410 }
411
412 return r;
413}
414
415/**
416 * Takes a param response message from the exit, compares it to our
417 * consensus parameters for sanity, and creates output parameters
418 * if sane.
419 *
420 * Returns -1 on parsing or insane params, 0 if success.
421 */
422static int
423negotiate_v3_ntor_client_circ_params(const uint8_t *param_response_msg,
424 size_t param_response_len,
425 circuit_params_t *params_out)
426{
427 int ret = congestion_control_parse_ext_response(param_response_msg,
428 param_response_len,
429 params_out);
430 if (ret < 0) {
431 return -1;
432 }
433
434 /* If congestion control came back enabled, but we didn't ask for it
435 * because the consensus said no, close the circuit.
436 *
437 * This is a fatal error condition for the circuit, because it either
438 * means that congestion control was disabled by the consensus
439 * during the handshake, or the exit decided to send us an unsolicited
440 * congestion control response.
441 *
442 * In either case, we cannot proceed on this circuit, and must try a
443 * new one.
444 */
445 if (ret && !congestion_control_enabled()) {
446 return -1;
447 }
448 params_out->cc_enabled = ret;
449
450 return 0;
451}
452
453/** Perform the final (client-side) step of a circuit-creation handshake of
454 * type <b>type</b>, using our state in <b>handshake_state</b> and the
455 * server's response in <b>reply</b>. On success, generate <b>keys_out_len</b>
456 * bytes worth of key material in <b>keys_out_len</b>, set
457 * <b>rend_authenticator_out</b> to the "KH" field that can be used to
458 * establish introduction points at this hop, and return 0. On failure,
459 * return -1, and set *msg_out to an error message if this is worth
460 * complaining to the user about. */
461int
463 const onion_handshake_state_t *handshake_state,
464 const uint8_t *reply, size_t reply_len,
465 uint8_t *keys_out, size_t keys_out_len,
466 uint8_t *rend_authenticator_out,
467 circuit_params_t *params_out,
468 const char **msg_out)
469{
470 if (handshake_state->tag != type)
471 return -1;
472
473 memset(params_out, 0, sizeof(*params_out));
474
475 switch (type) {
476 case ONION_HANDSHAKE_TYPE_TAP:
477 if (reply_len != TAP_ONIONSKIN_REPLY_LEN) {
478 if (msg_out)
479 *msg_out = "TAP reply was not of the correct length.";
480 return -1;
481 }
482 if (onion_skin_TAP_client_handshake(handshake_state->u.tap,
483 (const char*)reply,
484 (char *)keys_out, keys_out_len,
485 msg_out) < 0)
486 return -1;
487
488 memcpy(rend_authenticator_out, reply+DH1024_KEY_LEN, DIGEST_LEN);
489
490 return 0;
491 case ONION_HANDSHAKE_TYPE_FAST:
492 if (reply_len != CREATED_FAST_LEN) {
493 if (msg_out)
494 *msg_out = "TAP reply was not of the correct length.";
495 return -1;
496 }
497 if (fast_client_handshake(handshake_state->u.fast, reply,
498 keys_out, keys_out_len, msg_out) < 0)
499 return -1;
500
501 memcpy(rend_authenticator_out, reply+DIGEST_LEN, DIGEST_LEN);
502 return 0;
503 case ONION_HANDSHAKE_TYPE_NTOR:
504 if (reply_len < NTOR_REPLY_LEN) {
505 if (msg_out)
506 *msg_out = "ntor reply was not of the correct length.";
507 return -1;
508 }
509 {
510 size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
511 uint8_t *keys_tmp = tor_malloc(keys_tmp_len);
512 if (onion_skin_ntor_client_handshake(handshake_state->u.ntor,
513 reply,
514 keys_tmp, keys_tmp_len, msg_out) < 0) {
515 tor_free(keys_tmp);
516 return -1;
517 }
518 memcpy(keys_out, keys_tmp, keys_out_len);
519 memcpy(rend_authenticator_out, keys_tmp + keys_out_len, DIGEST_LEN);
520 memwipe(keys_tmp, 0, keys_tmp_len);
521 tor_free(keys_tmp);
522 }
523 return 0;
524 case ONION_HANDSHAKE_TYPE_NTOR_V3: {
525 size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
526 uint8_t *keys_tmp = tor_malloc(keys_tmp_len);
527 uint8_t *server_msg = NULL;
528 size_t server_msg_len = 0;
530 handshake_state->u.ntor3,
531 reply, reply_len,
532 NTOR3_VERIFICATION_ARGS,
533 keys_tmp, keys_tmp_len,
534 &server_msg, &server_msg_len);
535 if (r < 0) {
536 tor_free(keys_tmp);
537 tor_free(server_msg);
538 return -1;
539 }
540
542 server_msg_len,
543 params_out) < 0) {
544 tor_free(keys_tmp);
545 tor_free(server_msg);
546 return -1;
547 }
548 tor_free(server_msg);
549
550 memcpy(keys_out, keys_tmp, keys_out_len);
551 memcpy(rend_authenticator_out, keys_tmp + keys_out_len, DIGEST_LEN);
552 memwipe(keys_tmp, 0, keys_tmp_len);
553 tor_free(keys_tmp);
554
555 return 0;
556 }
557 default:
558 log_warn(LD_BUG, "called with unknown handshake state type %d", type);
560 return -1;
561 }
562}
int client_circ_negotiation_message(const extend_info_t *ei, uint8_t **msg_out, size_t *msg_len_out)
Header file for circuitbuild.c.
int congestion_control_build_ext_response(const circuit_params_t *our_params, const circuit_params_t *circ_params, uint8_t **msg_out, size_t *msg_len_out)
int congestion_control_parse_ext_request(const uint8_t *msg, const size_t msg_len)
int congestion_control_parse_ext_response(const uint8_t *msg, const size_t msg_len, circuit_params_t *params_out)
bool congestion_control_enabled(void)
Public APIs for congestion control.
Path structures for origin circuits.
int curve25519_keypair_generate(curve25519_keypair_t *keypair_out, int extra_strong)
Headers for crypto_dh.c.
void ed25519_pubkey_copy(ed25519_public_key_t *dest, const ed25519_public_key_t *src)
int ed25519_public_key_is_zero(const ed25519_public_key_t *pubkey)
void memwipe(void *mem, uint8_t byte, size_t sz)
Definition: crypto_util.c:55
Common functions for cryptographic routines.
#define DH1024_KEY_LEN
Definition: dh_sizes.h:20
#define DIGEST_LEN
Definition: digest_sizes.h:20
Extend-info structure.
int extend_info_supports_ntor_v3(const extend_info_t *ei)
Definition: extendinfo.c:228
Header for core/or/extendinfo.c.
#define LD_BUG
Definition: log.h:86
#define tor_free(p)
Definition: malloc.h:56
int onion_skin_client_handshake(int type, const onion_handshake_state_t *handshake_state, const uint8_t *reply, size_t reply_len, uint8_t *keys_out, size_t keys_out_len, uint8_t *rend_authenticator_out, circuit_params_t *params_out, const char **msg_out)
Definition: onion_crypto.c:462
static int negotiate_v3_ntor_client_circ_params(const uint8_t *param_response_msg, size_t param_response_len, circuit_params_t *params_out)
Definition: onion_crypto.c:423
int onion_skin_create(int type, const extend_info_t *node, onion_handshake_state_t *state_out, uint8_t *onion_skin_out, size_t onion_skin_out_maxlen)
Definition: onion_crypto.c:132
int onion_skin_server_handshake(int type, const uint8_t *onion_skin, size_t onionskin_len, const server_onion_keys_t *keys, const circuit_params_t *our_ns_params, uint8_t *reply_out, size_t reply_out_maxlen, uint8_t *keys_out, size_t keys_out_len, uint8_t *rend_nonce_out, circuit_params_t *params_out)
Definition: onion_crypto.c:276
void server_onion_keys_free_(server_onion_keys_t *keys)
Definition: onion_crypto.c:81
void onion_handshake_state_release(onion_handshake_state_t *state)
Definition: onion_crypto.c:97
static int negotiate_v3_ntor_server_circ_params(const uint8_t *param_request_msg, size_t param_request_len, const circuit_params_t *our_ns_params, circuit_params_t *params_out, uint8_t **resp_msg_out, size_t *resp_msg_len_out)
Definition: onion_crypto.c:231
server_onion_keys_t * server_onion_keys_new(void)
Definition: onion_crypto.c:65
Header file for onion_crypto.c.
int fast_client_handshake(const fast_handshake_state_t *handshake_state, const uint8_t *handshake_reply_out, uint8_t *key_out, size_t key_out_len, const char **msg_out)
Definition: onion_fast.c:109
int fast_server_handshake(const uint8_t *key_in, uint8_t *handshake_reply_out, uint8_t *key_out, size_t key_out_len)
Definition: onion_fast.c:67
int fast_onionskin_create(fast_handshake_state_t **handshake_state_out, uint8_t *handshake_out)
Definition: onion_fast.c:49
Header file for onion_fast.c.
int onion_skin_ntor_client_handshake(const ntor_handshake_state_t *handshake_state, const uint8_t *handshake_reply, uint8_t *key_out, size_t key_out_len, const char **msg_out)
Definition: onion_ntor.c:254
int onion_skin_ntor_server_handshake(const uint8_t *onion_skin, const di_digest256_map_t *private_keys, const curve25519_keypair_t *junk_keys, const uint8_t *my_node_id, uint8_t *handshake_reply_out, uint8_t *key_out, size_t key_out_len)
Definition: onion_ntor.c:149
int onion_skin_ntor_create(const uint8_t *router_id, const curve25519_public_key_t *router_key, ntor_handshake_state_t **handshake_state_out, uint8_t *onion_skin_out)
Definition: onion_ntor.c:93
Header for onion_ntor.c.
#define NTOR_REPLY_LEN
Definition: onion_ntor.h:25
#define NTOR_ONIONSKIN_LEN
Definition: onion_ntor.h:23
int onion_ntor3_client_handshake(const ntor3_handshake_state_t *handshake_state, const uint8_t *handshake_reply, size_t reply_len, const uint8_t *verification, size_t verification_len, uint8_t *keys_out, size_t keys_out_len, uint8_t **message_out, size_t *message_len_out)
int onion_skin_ntor3_server_handshake_part1(const di_digest256_map_t *private_keys, const curve25519_keypair_t *junk_key, const ed25519_public_key_t *my_id, const uint8_t *client_handshake, size_t client_handshake_len, const uint8_t *verification, size_t verification_len, uint8_t **client_message_out, size_t *client_message_len_out, ntor3_server_handshake_state_t **state_out)
int onion_skin_ntor3_create(const ed25519_public_key_t *relay_id, const curve25519_public_key_t *relay_key, const uint8_t *verification, const size_t verification_len, const uint8_t *message, const size_t message_len, ntor3_handshake_state_t **handshake_state_out, uint8_t **onion_skin_out, size_t *onion_skin_len_out)
int onion_skin_ntor3_server_handshake_part2(const ntor3_server_handshake_state_t *state, const uint8_t *verification, size_t verification_len, const uint8_t *server_message, size_t server_message_len, uint8_t **handshake_out, size_t *handshake_len_out, uint8_t *keys_out, size_t keys_out_len)
Header for core/crypto/onion_ntor_v3.c.
struct ntor3_server_handshake_state_t ntor3_server_handshake_state_t
Definition: onion_ntor_v3.h:31
int onion_skin_TAP_client_handshake(crypto_dh_t *handshake_state, const char *handshake_reply, char *key_out, size_t key_out_len, const char **msg_out)
Definition: onion_tap.c:207
int onion_skin_TAP_create(crypto_pk_t *dest_router_key, crypto_dh_t **handshake_state_out, char *onion_skin_out)
Definition: onion_tap.c:53
int onion_skin_TAP_server_handshake(const char *onion_skin, crypto_pk_t *private_key, crypto_pk_t *prev_private_key, char *handshake_reply_out, char *key_out, size_t key_out_len)
Definition: onion_tap.c:105
Header file for onion_tap.c.
Master header file for Tor-specific functionality.
const uint8_t * router_get_my_id_digest(void)
Definition: router.c:1752
void dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last)
Definition: router.c:228
di_digest256_map_t * construct_ntor_key_map(void)
Definition: router.c:300
Header file for router.c.
Header for routerkeys.c.
uint8_t sendme_inc_cells
Definition: onion_crypto.h:36
ed25519_public_key_t ed_identity
char identity_digest[DIGEST_LEN]
crypto_pk_t * onion_key
curve25519_public_key_t curve25519_onion_key
#define tor_assert(expr)
Definition: util_bug.h:103
#define tor_fragile_assert()
Definition: util_bug.h:278