23#include "trunnel/congestion_control.h"
24#include "trunnel/ed25519_cert.h"
25#include "trunnel/extension.h"
26#include "trunnel/hs/cell_establish_intro.h"
27#include "trunnel/hs/cell_introduce1.h"
28#include "trunnel/hs/cell_rendezvous.h"
39 const uint8_t *encrypted,
size_t encrypted_len,
40 const uint8_t *mac_key,
size_t mac_key_len,
41 uint8_t *mac_out,
size_t mac_out_len)
55 mac_msg_len = encoded_cell_len + (encrypted_len -
DIGEST256_LEN);
59 memcpy(mac_msg, encoded_cell, encoded_cell_len);
60 offset += encoded_cell_len;
63 memcpy(mac_msg + offset, encrypted, (encrypted_len -
DIGEST256_LEN));
69 mac_msg, mac_msg_len);
70 memwipe(mac_msg, 0,
sizeof(mac_msg));
82 size_t n_subcredentials,
84 const uint8_t *encrypted_section,
103 subcredentials, keys) < 0) {
118 size_t encrypted_section_len)
120 uint8_t *decrypted = NULL;
121 crypto_cipher_t *cipher = NULL;
133 decrypted = tor_malloc_zero(encrypted_section_len);
135 (
const char *) encrypted_section,
136 encrypted_section_len) < 0) {
143 crypto_cipher_free(cipher);
151static trn_cell_introduce_encrypted_t *
156 trn_cell_introduce_encrypted_t *enc_cell = NULL;
162 if (trn_cell_introduce_encrypted_parse(&enc_cell, decrypted_data,
163 decrypted_len) < 0) {
164 log_info(
LD_REND,
"Unable to parse the decrypted ENCRYPTED section of "
165 "the INTRODUCE2 cell on circuit %u for service %s",
171 if (trn_cell_introduce_encrypted_get_onion_key_type(enc_cell) !=
172 TRUNNEL_HS_INTRO_ONION_KEY_TYPE_NTOR) {
173 log_info(
LD_REND,
"INTRODUCE2 onion key type is invalid. Got %u but "
174 "expected %u on circuit %u for service %s",
175 trn_cell_introduce_encrypted_get_onion_key_type(enc_cell),
176 TRUNNEL_HS_INTRO_ONION_KEY_TYPE_NTOR,
182 if (trn_cell_introduce_encrypted_getlen_onion_key(enc_cell) !=
184 log_info(
LD_REND,
"INTRODUCE2 onion key length is invalid. Got %u but "
185 "expected %d on circuit %u for service %s",
186 (
unsigned)trn_cell_introduce_encrypted_getlen_onion_key(enc_cell),
195 trn_cell_introduce_encrypted_free(enc_cell);
208 trn_cell_introduce1_t **cell_ptr_out)
210 trn_cell_introduce1_t *cell = NULL;
218 if (trn_cell_introduce1_parse(&cell, payload, payload_len) < 0) {
219 log_info(
LD_PROTOCOL,
"Unable to parse INTRODUCE2 cell on circuit %u "
227 *cell_ptr_out = cell;
237 const uint8_t *onion_pk)
242 trn_cell_introduce_encrypted_set_onion_key_type(cell,
243 TRUNNEL_HS_INTRO_ONION_KEY_TYPE_NTOR);
246 memcpy(trn_cell_introduce_encrypted_getarray_onion_key(cell), onion_pk,
247 trn_cell_introduce_encrypted_getlen_onion_key(cell));
259 tor_assert(smartlist_len(lspecs) <= UINT8_MAX);
261 uint8_t lspecs_num = (uint8_t) smartlist_len(lspecs);
262 trn_cell_introduce_encrypted_set_nspec(cell, lspecs_num);
267 trn_cell_introduce_encrypted_add_nspecs(cell, ls));
274 trn_cell_introduce_encrypted_t *enc_cell)
279 ssize_t full_len = trn_cell_introduce1_encoded_len(cell) +
280 trn_cell_introduce_encrypted_encoded_len(enc_cell);
284 trn_cell_introduce_encrypted_setlen_pad(enc_cell, padding);
285 memset(trn_cell_introduce_encrypted_getarray_pad(enc_cell), 0,
286 trn_cell_introduce_encrypted_getlen_pad(enc_cell));
299 const trn_cell_introduce_encrypted_t *enc_cell,
303 ssize_t encrypted_len;
304 ssize_t encoded_cell_len, encoded_enc_cell_len;
307 uint8_t *encrypted = NULL;
309 crypto_cipher_t *cipher = NULL;
318 encoded_cell_len = trn_cell_introduce1_encode(encoded_cell,
319 sizeof(encoded_cell), cell);
323 encoded_enc_cell_len =
324 trn_cell_introduce_encrypted_encode(encoded_enc_cell,
325 sizeof(encoded_enc_cell), enc_cell);
330 if (hs_ntor_client_get_introduce1_keys(data->
auth_pk, data->
enc_pk,
340 sizeof(keys.enc_key) * 8);
345 encrypted_len =
sizeof(data->
client_kp->pubkey) + encoded_enc_cell_len +
348 encrypted = tor_malloc_zero(encrypted_len);
351 memcpy(encrypted, data->
client_kp->pubkey.public_key,
352 sizeof(data->
client_kp->pubkey.public_key));
353 offset +=
sizeof(data->
client_kp->pubkey.public_key);
356 (
const char *) encoded_enc_cell, encoded_enc_cell_len);
357 crypto_cipher_free(cipher);
358 offset += encoded_enc_cell_len;
362 encrypted, encrypted_len,
363 keys.mac_key,
sizeof(keys.mac_key),
365 memcpy(encrypted + offset, mac,
sizeof(mac));
366 offset +=
sizeof(mac);
370 trn_cell_introduce1_setlen_encrypted(cell, encrypted_len);
371 memcpy(trn_cell_introduce1_getarray_encrypted(cell),
372 encrypted, encrypted_len);
375 memwipe(&keys, 0,
sizeof(keys));
377 memwipe(encrypted, 0, encrypted_len);
378 memwipe(encoded_enc_cell, 0,
sizeof(encoded_enc_cell));
387 trn_extension_t *extensions)
390 size_t pow_ext_encoded_len;
391 uint8_t *field_array;
392 trn_extension_field_t *field = NULL;
393 trn_cell_extension_pow_t *pow_ext = NULL;
399 field = trn_extension_field_new();
400 trn_extension_field_set_field_type(field, TRUNNEL_EXT_TYPE_POW);
403 pow_ext = trn_cell_extension_pow_new();
408 trn_cell_extension_pow_set_pow_version(pow_ext, TRUNNEL_POW_VERSION_EQUIX);
410 memcpy(trn_cell_extension_pow_getarray_pow_nonce(pow_ext),
411 &pow_solution->nonce, TRUNNEL_POW_NONCE_LEN);
413 trn_cell_extension_pow_set_pow_effort(pow_ext, pow_solution->effort);
415 memcpy(trn_cell_extension_pow_getarray_pow_seed(pow_ext),
416 pow_solution->seed_head, TRUNNEL_POW_SEED_HEAD_LEN);
417 memcpy(trn_cell_extension_pow_getarray_pow_solution(pow_ext),
418 pow_solution->equix_solution, TRUNNEL_POW_SOLUTION_LEN);
421 ret = trn_cell_extension_pow_encoded_len(pow_ext);
425 pow_ext_encoded_len = ret;
428 trn_extension_field_set_field_len(field, pow_ext_encoded_len);
429 trn_extension_field_setlen_field(field, pow_ext_encoded_len);
431 field_array = trn_extension_field_getarray_field(field);
432 ret = trn_cell_extension_pow_encode(field_array,
433 trn_extension_field_getlen_field(field), pow_ext);
437 tor_assert(ret == (ssize_t)pow_ext_encoded_len);
440 trn_extension_add_fields(extensions, field);
444 trn_extension_set_num(extensions, trn_extension_get_num(extensions) + 1);
447 trn_cell_extension_pow_free(pow_ext);
452 trn_extension_field_free(field);
453 trn_cell_extension_pow_free(pow_ext);
462 trn_extension_field_t *field = NULL;
465 field = trn_extension_field_new();
466 trn_extension_field_set_field_type(field,
467 TRUNNEL_EXT_TYPE_CC_REQUEST);
470 trn_extension_field_set_field_len(field, 0);
473 trn_extension_add_fields(extensions, field);
474 trn_extension_set_num(extensions, trn_extension_get_num(extensions) + 1);
483 trn_cell_introduce_encrypted_t *enc_cell;
484 trn_extension_t *ext;
489 enc_cell = trn_cell_introduce_encrypted_new();
493 ext = trn_extension_new();
503 trn_cell_introduce_encrypted_set_extensions(enc_cell, ext);
506 memcpy(trn_cell_introduce_encrypted_getarray_rend_cookie(enc_cell),
523 trn_cell_introduce_encrypted_free(enc_cell);
535 trn_cell_introduce1_set_auth_key_type(cell,
536 TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);
539 memcpy(trn_cell_introduce1_getarray_auth_key(cell),
540 data->
auth_pk->pubkey, trn_cell_introduce1_getlen_auth_key(cell));
547 uint8_t param_type, uint64_t param_value)
549 trn_cell_extension_dos_param_t *dos_param =
550 trn_cell_extension_dos_param_new();
553 tor_assert(param_type == TRUNNEL_DOS_PARAM_TYPE_INTRO2_RATE_PER_SEC ||
554 param_type == TRUNNEL_DOS_PARAM_TYPE_INTRO2_BURST_PER_SEC);
556 trn_cell_extension_dos_param_set_type(dos_param, param_type);
557 trn_cell_extension_dos_param_set_value(dos_param, param_value);
558 trn_cell_extension_dos_add_params(dos_ext, dos_param);
568 trn_extension_t *extensions)
571 size_t dos_ext_encoded_len;
572 uint8_t *field_array;
573 trn_extension_field_t *field = NULL;
574 trn_cell_extension_dos_t *dos_ext = NULL;
580 field = trn_extension_field_new();
581 trn_extension_field_set_field_type(field,
582 TRUNNEL_CELL_EXTENSION_TYPE_DOS);
585 dos_ext = trn_cell_extension_dos_new();
586 trn_cell_extension_dos_set_n_params(dos_ext, 2);
590 TRUNNEL_DOS_PARAM_TYPE_INTRO2_RATE_PER_SEC,
591 service_config->intro_dos_rate_per_sec);
594 TRUNNEL_DOS_PARAM_TYPE_INTRO2_BURST_PER_SEC,
595 service_config->intro_dos_burst_per_sec);
598 ret = trn_cell_extension_dos_encoded_len(dos_ext);
602 dos_ext_encoded_len = ret;
604 trn_extension_field_set_field_len(field, dos_ext_encoded_len);
605 trn_extension_field_setlen_field(field, dos_ext_encoded_len);
607 field_array = trn_extension_field_getarray_field(field);
608 ret = trn_cell_extension_dos_encode(field_array,
609 trn_extension_field_getlen_field(field), dos_ext);
613 tor_assert(ret == (ssize_t) dos_ext_encoded_len);
616 trn_extension_add_fields(extensions, field);
620 trn_extension_set_num(extensions, trn_extension_get_num(extensions) + 1);
623 trn_cell_extension_dos_free(dos_ext);
628 trn_extension_field_free(field);
629 trn_cell_extension_dos_free(dos_ext);
644 trn_extension_t *extensions;
649 extensions = trn_extension_new();
650 trn_extension_set_num(extensions, 0);
678 ssize_t cell_len = -1;
680 trn_cell_establish_intro_t *cell = NULL;
681 trn_extension_t *extensions;
691 cell = trn_cell_establish_intro_new();
692 trn_cell_establish_intro_set_extensions(cell, extensions);
695 trn_cell_establish_intro_set_sig_len(cell, sig_len);
696 trn_cell_establish_intro_setlen_sig(cell, sig_len);
699 trn_cell_establish_intro_set_auth_key_type(cell,
700 TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);
706 trn_cell_establish_intro_set_auth_key_len(cell, auth_key_len);
707 trn_cell_establish_intro_setlen_auth_key(cell, auth_key_len);
710 uint8_t *auth_key_ptr = trn_cell_establish_intro_getarray_auth_key(cell);
711 memcpy(auth_key_ptr, ip->
auth_key_kp.pubkey.pubkey, auth_key_len);
716 ssize_t tmp_cell_enc_len = 0;
717 ssize_t tmp_cell_mac_offset =
718 sig_len +
sizeof(cell->sig_len) +
719 trn_cell_establish_intro_getlen_handshake_mac(cell);
721 uint8_t mac[TRUNNEL_SHA3_256_LEN], *handshake_ptr;
725 tmp_cell_enc_len = trn_cell_establish_intro_encode(tmp_cell_enc,
726 sizeof(tmp_cell_enc),
728 if (BUG(tmp_cell_enc_len < 0)) {
732 tor_assert(tmp_cell_enc_len > tmp_cell_mac_offset);
737 tmp_cell_enc, tmp_cell_enc_len - tmp_cell_mac_offset);
738 handshake_ptr = trn_cell_establish_intro_getarray_handshake_mac(cell);
739 memcpy(handshake_ptr, mac,
sizeof(mac));
742 memwipe(tmp_cell_enc, 0,
sizeof(tmp_cell_enc));
747 ssize_t tmp_cell_enc_len = 0;
748 ssize_t tmp_cell_sig_offset = (sig_len +
sizeof(cell->sig_len));
754 tmp_cell_enc_len = trn_cell_establish_intro_encode(tmp_cell_enc,
755 sizeof(tmp_cell_enc),
757 if (BUG(tmp_cell_enc_len < 0)) {
762 tmp_cell_enc_len - tmp_cell_sig_offset,
764 log_warn(
LD_BUG,
"Unable to make signature for ESTABLISH_INTRO cell.");
768 sig_ptr = trn_cell_establish_intro_getarray_sig(cell);
769 memcpy(sig_ptr, sig.sig, sig_len);
771 memwipe(tmp_cell_enc, 0,
sizeof(tmp_cell_enc));
775 cell_len = trn_cell_establish_intro_encode(cell_out,
780 trn_cell_establish_intro_free(cell);
791 trn_cell_intro_established_t *cell = NULL;
797 ret = trn_cell_intro_established_parse(&cell, payload, payload_len);
801 trn_cell_intro_established_free(cell);
812 const trn_extension_field_t *field,
816 trn_cell_extension_pow_t *pow = NULL;
823 log_info(
LD_REND,
"Unsolicited PoW solution in INTRODUCE2 request.");
827 if (trn_cell_extension_pow_parse(&pow,
828 trn_extension_field_getconstarray_field(field),
829 trn_extension_field_getlen_field(field)) < 0) {
835 if (trn_cell_extension_pow_get_pow_version(pow) !=
836 TRUNNEL_POW_VERSION_EQUIX) {
837 log_debug(
LD_REND,
"Unsupported PoW version. Malformed INTRODUCE2");
842 sol.effort = trn_cell_extension_pow_get_pow_effort(pow);
844 memcpy(sol.seed_head, trn_cell_extension_pow_getconstarray_pow_seed(pow),
847 memcpy(sol.nonce, trn_cell_extension_pow_getconstarray_pow_nonce(pow),
850 memcpy(sol.equix_solution,
851 trn_cell_extension_pow_getconstarray_pow_solution(pow),
855 log_info(
LD_REND,
"PoW INTRODUCE2 request failed to verify.");
859 log_info(
LD_REND,
"PoW INTRODUCE2 request successfully verified.");
866 trn_cell_extension_pow_free(pow);
878 const uint8_t *encrypted_section,
879 size_t encrypted_section_len)
890 if (intro_keys == NULL) {
891 log_info(
LD_REND,
"Invalid INTRODUCE2 encrypted data. Unable to "
892 "compute key material");
903 intro_keys_result = tor_malloc_zero(
sizeof(*intro_keys_result));
908 size_t mac_offset = encrypted_section_len -
sizeof(mac);
913 encrypted_section, encrypted_section_len,
914 intro_keys[i].mac_key,
915 sizeof(intro_keys[i].mac_key),
920 bool equal =
tor_memeq(mac, encrypted_section + mac_offset,
sizeof(mac));
922 sizeof(*intro_keys_result));
931 log_info(
LD_REND,
"Invalid MAC validation for INTRODUCE2 cell");
935 return intro_keys_result;
946 const trn_extension_field_t *field)
949 trn_extension_field_cc_t *cc_field = NULL;
954 switch (trn_extension_field_get_field_type(field)) {
955 case TRUNNEL_EXT_TYPE_CC_REQUEST:
961 case TRUNNEL_EXT_TYPE_POW:
965 log_fn(LOG_PROTOCOL_WARN,
LD_REND,
"Invalid PoW cell extension.");
973 trn_extension_field_cc_free(cc_field);
989 uint8_t *decrypted = NULL;
990 size_t encrypted_section_len;
991 const uint8_t *encrypted_section;
992 trn_cell_introduce1_t *cell = NULL;
993 trn_cell_introduce_encrypted_t *enc_cell = NULL;
1006 log_info(
LD_REND,
"Received a decodable INTRODUCE2 cell on circuit %u "
1007 "for service %s. Decoding encrypted section...",
1011 encrypted_section = trn_cell_introduce1_getconstarray_encrypted(cell);
1012 encrypted_section_len = trn_cell_introduce1_getlen_encrypted(cell);
1017 log_info(
LD_REND,
"Invalid INTRODUCE2 encrypted section length "
1018 "for service %s. Dropping cell.",
1032 encrypted_section_len, &elapsed)) {
1033 log_warn(
LD_REND,
"Possible replay detected! An INTRODUCE2 cell with the "
1034 "same ENCRYPTED section was seen %ld seconds ago. "
1035 "Dropping cell.", (
long int) elapsed);
1048 encrypted_section_len);
1050 log_warn(
LD_REND,
"Could not get valid INTRO2 keys on circuit %u "
1051 "for service %s",
TO_CIRCUIT(circ)->n_circ_id,
1058 const uint8_t *encrypted_data =
1063 size_t encrypted_data_len =
1064 encrypted_section_len -
1069 encrypted_data, encrypted_data_len);
1070 if (decrypted == NULL) {
1071 log_info(
LD_REND,
"Unable to decrypt the ENCRYPTED section of an "
1072 "INTRODUCE2 cell on circuit %u for service %s",
1082 memwipe(decrypted, 0, encrypted_data_len);
1083 if (enc_cell == NULL) {
1093 trn_cell_introduce_encrypted_getconstarray_onion_key(enc_cell),
1097 "Invalid rendezvous onion key in INTRODUCE2 cell on "
1098 "circuit %u for service %s. Dropping cell.",
1104 trn_cell_introduce_encrypted_getconstarray_rend_cookie(enc_cell),
1108 for (
size_t idx = 0;
1109 idx < trn_cell_introduce_encrypted_get_nspec(enc_cell); idx++) {
1110 link_specifier_t *lspec =
1111 trn_cell_introduce_encrypted_get_nspecs(enc_cell, idx);
1116 if (BUG(!lspec_dup)) {
1123 const trn_extension_t *extensions =
1124 trn_cell_introduce_encrypted_get_extensions(enc_cell);
1125 if (extensions != NULL) {
1126 for (
size_t idx = 0; idx < trn_extension_get_num(extensions); idx++) {
1127 const trn_extension_field_t *field =
1128 trn_extension_getconst_fields(extensions, idx);
1129 if (BUG(field == NULL)) {
1149 encrypted_section_len);
1154 "Valid INTRODUCE2 cell. Willing to launch rendezvous circuit.");
1162 trn_cell_introduce_encrypted_free(enc_cell);
1163 trn_cell_introduce1_free(cell);
1172 size_t rendezvous_cookie_len,
1173 const uint8_t *rendezvous_handshake_info,
1174 size_t rendezvous_handshake_info_len,
1178 trn_cell_rendezvous1_t *cell;
1184 cell = trn_cell_rendezvous1_new();
1186 memcpy(trn_cell_rendezvous1_getarray_rendezvous_cookie(cell),
1187 rendezvous_cookie, rendezvous_cookie_len);
1189 trn_cell_rendezvous1_setlen_handshake_info(cell,
1190 rendezvous_handshake_info_len);
1191 memcpy(trn_cell_rendezvous1_getarray_handshake_info(cell),
1192 rendezvous_handshake_info, rendezvous_handshake_info_len);
1194 cell_len = trn_cell_rendezvous1_encode(cell_out,
1198 trn_cell_rendezvous1_free(cell);
1211 trn_cell_introduce1_t *cell;
1212 trn_extension_t *ext;
1217 cell = trn_cell_introduce1_new();
1221 ext = trn_extension_new();
1223 trn_extension_set_num(ext, 0);
1224 trn_cell_introduce1_set_extensions(cell, ext);
1235 cell_len = trn_cell_introduce1_encode(cell_out,
1238 trn_cell_introduce1_free(cell);
1266 trn_cell_introduce_ack_t *cell = NULL;
1270 if (trn_cell_introduce_ack_parse(&cell, payload, payload_len) < 0) {
1271 log_info(
LD_REND,
"Invalid INTRODUCE_ACK cell. Unable to parse it.");
1275 ret = trn_cell_introduce_ack_get_status(cell);
1278 trn_cell_introduce_ack_free(cell);
1287 uint8_t *handshake_info,
size_t handshake_info_len)
1290 trn_cell_rendezvous2_t *cell = NULL;
1295 if (trn_cell_rendezvous2_parse(&cell, payload, payload_len) < 0) {
1296 log_info(
LD_REND,
"Invalid RENDEZVOUS2 cell. Unable to parse it.");
1302 tor_assert(trn_cell_rendezvous2_getlen_handshake_info(cell) ==
1303 handshake_info_len);
1304 memcpy(handshake_info,
1305 trn_cell_rendezvous2_getconstarray_handshake_info(cell),
1306 handshake_info_len);
1310 trn_cell_rendezvous2_free(cell);
Header file for config.c.
bool congestion_control_enabled(void)
Public APIs for congestion control.
crypto_cipher_t * crypto_cipher_new_with_bits(const char *key, int bits)
int crypto_cipher_decrypt(crypto_cipher_t *env, char *to, const char *from, size_t fromlen)
int crypto_cipher_encrypt(crypto_cipher_t *env, char *to, const char *from, size_t fromlen)
int curve25519_public_key_is_ok(const curve25519_public_key_t *key)
Header for crypto_curve25519.c.
void crypto_mac_sha3_256(uint8_t *mac_out, size_t len_out, const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len)
int ed25519_sign_prefixed(ed25519_signature_t *signature_out, const uint8_t *msg, size_t msg_len, const char *prefix_str, const ed25519_keypair_t *keypair)
void memwipe(void *mem, uint8_t byte, size_t sz)
Common functions for cryptographic routines.
void memcpy_if_true_timei(bool s, void *dest, const void *src, size_t n)
int tor_memeq(const void *a, const void *b, size_t sz)
int safe_mem_is_zero(const void *mem, size_t sz)
static int handle_introduce2_encrypted_cell_pow_extension(const hs_service_t *service, const hs_service_intro_point_t *ip, const trn_extension_field_t *field, hs_cell_introduce2_data_t *data)
static void build_introduce_cc_extension(trn_extension_t *extensions)
ssize_t hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, uint8_t *cell_out)
STATIC trn_extension_t * build_establish_intro_extensions(const hs_service_config_t *service_config, const hs_service_intro_point_t *ip)
ssize_t hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, const origin_circuit_t *circ, const hs_service_t *service, const hs_service_intro_point_t *ip)
static void build_establish_intro_dos_param(trn_cell_extension_dos_t *dos_ext, uint8_t param_type, uint64_t param_value)
static int build_establish_intro_dos_extension(const hs_service_config_t *service_config, trn_extension_t *extensions)
static void compute_introduce_mac(const uint8_t *encoded_cell, size_t encoded_cell_len, const uint8_t *encrypted, size_t encrypted_len, const uint8_t *mac_key, size_t mac_key_len, uint8_t *mac_out, size_t mac_out_len)
static hs_ntor_intro_cell_keys_t * get_introduce2_key_material(const ed25519_public_key_t *auth_key, const curve25519_keypair_t *enc_key, size_t n_subcredentials, const hs_subcredential_t *subcredentials, const uint8_t *encrypted_section, curve25519_public_key_t *client_pk)
static uint8_t * decrypt_introduce2(const uint8_t *enc_key, const uint8_t *encrypted_section, size_t encrypted_section_len)
static void introduce1_set_encrypted_link_spec(trn_cell_introduce_encrypted_t *cell, const smartlist_t *lspecs)
static int parse_introduce2_cell(const hs_service_t *service, const origin_circuit_t *circ, const uint8_t *payload, size_t payload_len, trn_cell_introduce1_t **cell_ptr_out)
ssize_t hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
static int parse_introduce_cell_extension(const hs_service_t *service, const hs_service_intro_point_t *ip, hs_cell_introduce2_data_t *data, const trn_extension_field_t *field)
ssize_t hs_cell_build_establish_intro(const char *circ_nonce, const hs_service_config_t *service_config, const hs_service_intro_point_t *ip, uint8_t *cell_out)
int hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len)
static trn_cell_introduce_encrypted_t * parse_introduce2_encrypted(const uint8_t *decrypted_data, size_t decrypted_len, const origin_circuit_t *circ, const hs_service_t *service)
static hs_ntor_intro_cell_keys_t * get_introduce2_keys_and_verify_mac(hs_cell_introduce2_data_t *data, const uint8_t *encrypted_section, size_t encrypted_section_len)
void hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
ssize_t hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie, size_t rendezvous_cookie_len, const uint8_t *rendezvous_handshake_info, size_t rendezvous_handshake_info_len, uint8_t *cell_out)
static int introduce1_set_encrypted(trn_cell_introduce1_t *cell, const hs_cell_introduce1_data_t *data)
ssize_t hs_cell_build_introduce1(const hs_cell_introduce1_data_t *data, uint8_t *cell_out)
int hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len, uint8_t *handshake_info, size_t handshake_info_len)
static void introduce1_set_auth_key(trn_cell_introduce1_t *cell, const hs_cell_introduce1_data_t *data)
static int build_introduce_pow_extension(const hs_pow_solution_t *pow_solution, trn_extension_t *extensions)
static void introduce1_set_encrypted_padding(const trn_cell_introduce1_t *cell, trn_cell_introduce_encrypted_t *enc_cell)
static int introduce1_encrypt_and_encode(trn_cell_introduce1_t *cell, const trn_cell_introduce_encrypted_t *enc_cell, const hs_cell_introduce1_data_t *data)
static void introduce1_set_encrypted_onion_key(trn_cell_introduce_encrypted_t *cell, const uint8_t *onion_pk)
Header file containing cell data for the whole HS subsystem.
#define HS_CELL_INTRODUCE1_MIN_SIZE
link_specifier_t * link_specifier_dup(const link_specifier_t *src)
#define ESTABLISH_INTRO_SIG_PREFIX
#define HS_REND_COOKIE_LEN
int hs_ntor_service_get_introduce1_keys_multi(const struct ed25519_public_key_t *intro_auth_pubkey, const struct curve25519_keypair_t *intro_enc_keypair, const struct curve25519_public_key_t *client_ephemeral_enc_pubkey, size_t n_subcredentials, const hs_subcredential_t *subcredentials, hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out)
Header file for the specific code for onion balance.
int hs_pow_verify(const ed25519_public_key_t *service_blinded_id, const hs_pow_service_state_t *pow_state, const hs_pow_solution_t *pow_solution)
#define HS_POW_EQX_SOL_LEN
#define HS_POW_SEED_HEAD_LEN
#define log_fn(severity, domain, args,...)
Master header file for Tor-specific functionality.
#define RELAY_PAYLOAD_SIZE_MAX
Origin circuit structure.
size_t replay_cache_count(const replaycache_t *r)
int replaycache_test_and_elapsed(const replaycache_t *r, const void *data, size_t len, time_t *elapsed)
int replaycache_add_and_test(replaycache_t *r, const void *data, size_t len)
Header file for replaycache.c.
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
curve25519_public_key_t onion_pk
uint8_t rendezvous_cookie[REND_COOKIE_LEN]
curve25519_public_key_t client_pk
smartlist_t * link_specifiers
const ed25519_public_key_t * auth_pk
const struct hs_subcredential_t * subcredential
const hs_pow_solution_t * pow_solution
const curve25519_keypair_t * client_kp
const curve25519_public_key_t * enc_pk
const uint8_t * rendezvous_cookie
const curve25519_public_key_t * onion_pk
smartlist_t * link_specifiers
protover_summary_flags_t pv
const ed25519_public_key_t * auth_pk
const curve25519_keypair_t * enc_kp
replaycache_t * replay_cache
const struct hs_subcredential_t * subcredentials
hs_cell_intro_rdv_data_t rdv_data
unsigned int has_dos_defense_enabled
unsigned int support_intro2_dos_defense
ed25519_keypair_t auth_key_kp
ed25519_public_key_t blinded_id
hs_pow_service_state_t * pow_state
char onion_address[HS_SERVICE_ADDR_LEN_BASE32+1]
unsigned int supports_congestion_control
unsigned int protocols_known
#define ED25519_PUBKEY_LEN
#define CURVE25519_PUBKEY_LEN