hs_cell.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_cell.c
  5. * \brief Hidden service API for cell creation and handling.
  6. **/
  7. #include "or.h"
  8. #include "config.h"
  9. #include "rendservice.h"
  10. #include "hs_cell.h"
  11. #include "hs_ntor.h"
  12. /* Trunnel. */
  13. #include "ed25519_cert.h"
  14. #include "hs/cell_common.h"
  15. #include "hs/cell_establish_intro.h"
  16. #include "hs/cell_introduce1.h"
  17. #include "hs/cell_rendezvous.h"
  18. /* Compute the MAC of an INTRODUCE cell in mac_out. The encoded_cell param is
  19. * the cell content up to the ENCRYPTED section of length encoded_cell_len.
  20. * The encrypted param is the start of the ENCRYPTED section of length
  21. * encrypted_len. The mac_key is the key needed for the computation of the MAC
  22. * derived from the ntor handshake of length mac_key_len.
  23. *
  24. * The length mac_out_len must be at least DIGEST256_LEN. */
  25. static void
  26. compute_introduce_mac(const uint8_t *encoded_cell, size_t encoded_cell_len,
  27. const uint8_t *encrypted, size_t encrypted_len,
  28. const uint8_t *mac_key, size_t mac_key_len,
  29. uint8_t *mac_out, size_t mac_out_len)
  30. {
  31. size_t offset = 0;
  32. size_t mac_msg_len;
  33. uint8_t mac_msg[RELAY_PAYLOAD_SIZE] = {0};
  34. tor_assert(encoded_cell);
  35. tor_assert(encrypted);
  36. tor_assert(mac_key);
  37. tor_assert(mac_out);
  38. tor_assert(mac_out_len >= DIGEST256_LEN);
  39. /* Compute the size of the message which is basically the entire cell until
  40. * the MAC field of course. */
  41. mac_msg_len = encoded_cell_len + (encrypted_len - DIGEST256_LEN);
  42. tor_assert(mac_msg_len <= sizeof(mac_msg));
  43. /* First, put the encoded cell in the msg. */
  44. memcpy(mac_msg, encoded_cell, encoded_cell_len);
  45. offset += encoded_cell_len;
  46. /* Second, put the CLIENT_PK + ENCRYPTED_DATA but ommit the MAC field (which
  47. * is junk at this point). */
  48. memcpy(mac_msg + offset, encrypted, (encrypted_len - DIGEST256_LEN));
  49. offset += (encrypted_len - DIGEST256_LEN);
  50. tor_assert(offset == mac_msg_len);
  51. crypto_mac_sha3_256(mac_out, mac_out_len,
  52. mac_key, mac_key_len,
  53. mac_msg, mac_msg_len);
  54. memwipe(mac_msg, 0, sizeof(mac_msg));
  55. }
  56. /* From a set of keys, subcredential and the ENCRYPTED section of an
  57. * INTRODUCE2 cell, return a newly allocated intro cell keys structure.
  58. * Finally, the client public key is copied in client_pk. On error, return
  59. * NULL. */
  60. static hs_ntor_intro_cell_keys_t *
  61. get_introduce2_key_material(const ed25519_public_key_t *auth_key,
  62. const curve25519_keypair_t *enc_key,
  63. const uint8_t *subcredential,
  64. const uint8_t *encrypted_section,
  65. curve25519_public_key_t *client_pk)
  66. {
  67. hs_ntor_intro_cell_keys_t *keys;
  68. tor_assert(auth_key);
  69. tor_assert(enc_key);
  70. tor_assert(subcredential);
  71. tor_assert(encrypted_section);
  72. tor_assert(client_pk);
  73. keys = tor_malloc_zero(sizeof(*keys));
  74. /* First bytes of the ENCRYPTED section are the client public key. */
  75. memcpy(client_pk->public_key, encrypted_section, CURVE25519_PUBKEY_LEN);
  76. if (hs_ntor_service_get_introduce1_keys(auth_key, enc_key, client_pk,
  77. subcredential, keys) < 0) {
  78. /* Don't rely on the caller to wipe this on error. */
  79. memwipe(client_pk, 0, sizeof(curve25519_public_key_t));
  80. tor_free(keys);
  81. keys = NULL;
  82. }
  83. return keys;
  84. }
  85. /* Using the given encryption key, decrypt the encrypted_section of length
  86. * encrypted_section_len of an INTRODUCE2 cell and return a newly allocated
  87. * buffer containing the decrypted data. On decryption failure, NULL is
  88. * returned. */
  89. static uint8_t *
  90. decrypt_introduce2(const uint8_t *enc_key, const uint8_t *encrypted_section,
  91. size_t encrypted_section_len)
  92. {
  93. uint8_t *decrypted = NULL;
  94. crypto_cipher_t *cipher = NULL;
  95. tor_assert(enc_key);
  96. tor_assert(encrypted_section);
  97. /* Decrypt ENCRYPTED section. */
  98. cipher = crypto_cipher_new_with_bits((char *) enc_key,
  99. CURVE25519_PUBKEY_LEN * 8);
  100. tor_assert(cipher);
  101. /* This is symmetric encryption so can't be bigger than the encrypted
  102. * section length. */
  103. decrypted = tor_malloc_zero(encrypted_section_len);
  104. if (crypto_cipher_decrypt(cipher, (char *) decrypted,
  105. (const char *) encrypted_section,
  106. encrypted_section_len) < 0) {
  107. tor_free(decrypted);
  108. decrypted = NULL;
  109. goto done;
  110. }
  111. done:
  112. crypto_cipher_free(cipher);
  113. return decrypted;
  114. }
  115. /* Given a pointer to the decrypted data of the ENCRYPTED section of an
  116. * INTRODUCE2 cell of length decrypted_len, parse and validate the cell
  117. * content. Return a newly allocated cell structure or NULL on error. The
  118. * circuit and service object are only used for logging purposes. */
  119. static trn_cell_introduce_encrypted_t *
  120. parse_introduce2_encrypted(const uint8_t *decrypted_data,
  121. size_t decrypted_len, const origin_circuit_t *circ,
  122. const hs_service_t *service)
  123. {
  124. trn_cell_introduce_encrypted_t *enc_cell = NULL;
  125. tor_assert(decrypted_data);
  126. tor_assert(circ);
  127. tor_assert(service);
  128. if (trn_cell_introduce_encrypted_parse(&enc_cell, decrypted_data,
  129. decrypted_len) < 0) {
  130. log_info(LD_REND, "Unable to parse the decrypted ENCRYPTED section of "
  131. "the INTRODUCE2 cell on circuit %u for service %s",
  132. TO_CIRCUIT(circ)->n_circ_id,
  133. safe_str_client(service->onion_address));
  134. goto err;
  135. }
  136. if (trn_cell_introduce_encrypted_get_onion_key_type(enc_cell) !=
  137. HS_CELL_ONION_KEY_TYPE_NTOR) {
  138. log_info(LD_REND, "INTRODUCE2 onion key type is invalid. Got %u but "
  139. "expected %u on circuit %u for service %s",
  140. trn_cell_introduce_encrypted_get_onion_key_type(enc_cell),
  141. HS_CELL_ONION_KEY_TYPE_NTOR, TO_CIRCUIT(circ)->n_circ_id,
  142. safe_str_client(service->onion_address));
  143. goto err;
  144. }
  145. if (trn_cell_introduce_encrypted_getlen_onion_key(enc_cell) !=
  146. CURVE25519_PUBKEY_LEN) {
  147. log_info(LD_REND, "INTRODUCE2 onion key length is invalid. Got %ld but "
  148. "expected %d on circuit %u for service %s",
  149. trn_cell_introduce_encrypted_getlen_onion_key(enc_cell),
  150. CURVE25519_PUBKEY_LEN, TO_CIRCUIT(circ)->n_circ_id,
  151. safe_str_client(service->onion_address));
  152. goto err;
  153. }
  154. /* XXX: Validate NSPEC field as well. */
  155. return enc_cell;
  156. err:
  157. trn_cell_introduce_encrypted_free(enc_cell);
  158. return NULL;
  159. }
  160. /* Build a legacy ESTABLISH_INTRO cell with the given circuit nonce and RSA
  161. * encryption key. The encoded cell is put in cell_out that MUST at least be
  162. * of the size of RELAY_PAYLOAD_SIZE. Return the encoded cell length on
  163. * success else a negative value and cell_out is untouched. */
  164. static ssize_t
  165. build_legacy_establish_intro(const char *circ_nonce, crypto_pk_t *enc_key,
  166. uint8_t *cell_out)
  167. {
  168. ssize_t cell_len;
  169. char buf[RELAY_PAYLOAD_SIZE] = {0};
  170. tor_assert(circ_nonce);
  171. tor_assert(enc_key);
  172. tor_assert(cell_out);
  173. cell_len = rend_service_encode_establish_intro_cell(buf, sizeof(buf),
  174. enc_key, circ_nonce);
  175. tor_assert(cell_len <= RELAY_PAYLOAD_SIZE);
  176. if (cell_len >= 0) {
  177. memcpy(cell_out, buf, cell_len);
  178. }
  179. return cell_len;
  180. }
  181. /* ========== */
  182. /* Public API */
  183. /* ========== */
  184. /* Build an ESTABLISH_INTRO cell with the given circuit nonce and intro point
  185. * object. The encoded cell is put in cell_out that MUST at least be of the
  186. * size of RELAY_PAYLOAD_SIZE. Return the encoded cell length on success else
  187. * a negative value and cell_out is untouched. This function also supports
  188. * legacy cell creation. */
  189. ssize_t
  190. hs_cell_build_establish_intro(const char *circ_nonce,
  191. const hs_service_intro_point_t *ip,
  192. uint8_t *cell_out)
  193. {
  194. ssize_t cell_len = -1;
  195. uint16_t sig_len = ED25519_SIG_LEN;
  196. trn_cell_extension_t *ext;
  197. trn_cell_establish_intro_t *cell = NULL;
  198. tor_assert(circ_nonce);
  199. tor_assert(ip);
  200. /* Quickly handle the legacy IP. */
  201. if (ip->base.is_only_legacy) {
  202. tor_assert(ip->legacy_key);
  203. cell_len = build_legacy_establish_intro(circ_nonce, ip->legacy_key,
  204. cell_out);
  205. tor_assert(cell_len <= RELAY_PAYLOAD_SIZE);
  206. /* Success or not we are done here. */
  207. goto done;
  208. }
  209. /* Set extension data. None used here. */
  210. ext = trn_cell_extension_new();
  211. trn_cell_extension_set_num(ext, 0);
  212. cell = trn_cell_establish_intro_new();
  213. trn_cell_establish_intro_set_extensions(cell, ext);
  214. /* Set signature size. Array is then allocated in the cell. We need to do
  215. * this early so we can use trunnel API to get the signature length. */
  216. trn_cell_establish_intro_set_sig_len(cell, sig_len);
  217. trn_cell_establish_intro_setlen_sig(cell, sig_len);
  218. /* Set AUTH_KEY_TYPE: 2 means ed25519 */
  219. trn_cell_establish_intro_set_auth_key_type(cell,
  220. HS_INTRO_AUTH_KEY_TYPE_ED25519);
  221. /* Set AUTH_KEY and AUTH_KEY_LEN field. Must also set byte-length of
  222. * AUTH_KEY to match */
  223. {
  224. uint16_t auth_key_len = ED25519_PUBKEY_LEN;
  225. trn_cell_establish_intro_set_auth_key_len(cell, auth_key_len);
  226. trn_cell_establish_intro_setlen_auth_key(cell, auth_key_len);
  227. /* We do this call _after_ setting the length because it's reallocated at
  228. * that point only. */
  229. uint8_t *auth_key_ptr = trn_cell_establish_intro_getarray_auth_key(cell);
  230. memcpy(auth_key_ptr, ip->auth_key_kp.pubkey.pubkey, auth_key_len);
  231. }
  232. /* Calculate HANDSHAKE_AUTH field (MAC). */
  233. {
  234. ssize_t tmp_cell_enc_len = 0;
  235. ssize_t tmp_cell_mac_offset =
  236. sig_len + sizeof(cell->sig_len) +
  237. trn_cell_establish_intro_getlen_handshake_mac(cell);
  238. uint8_t tmp_cell_enc[RELAY_PAYLOAD_SIZE] = {0};
  239. uint8_t mac[TRUNNEL_SHA3_256_LEN], *handshake_ptr;
  240. /* We first encode the current fields we have in the cell so we can
  241. * compute the MAC using the raw bytes. */
  242. tmp_cell_enc_len = trn_cell_establish_intro_encode(tmp_cell_enc,
  243. sizeof(tmp_cell_enc),
  244. cell);
  245. if (BUG(tmp_cell_enc_len < 0)) {
  246. goto done;
  247. }
  248. /* Sanity check. */
  249. tor_assert(tmp_cell_enc_len > tmp_cell_mac_offset);
  250. /* Circuit nonce is always DIGEST_LEN according to tor-spec.txt. */
  251. crypto_mac_sha3_256(mac, sizeof(mac),
  252. (uint8_t *) circ_nonce, DIGEST_LEN,
  253. tmp_cell_enc, tmp_cell_enc_len - tmp_cell_mac_offset);
  254. handshake_ptr = trn_cell_establish_intro_getarray_handshake_mac(cell);
  255. memcpy(handshake_ptr, mac, sizeof(mac));
  256. }
  257. /* Calculate the cell signature SIG. */
  258. {
  259. ssize_t tmp_cell_enc_len = 0;
  260. ssize_t tmp_cell_sig_offset = (sig_len + sizeof(cell->sig_len));
  261. uint8_t tmp_cell_enc[RELAY_PAYLOAD_SIZE] = {0}, *sig_ptr;
  262. ed25519_signature_t sig;
  263. /* We first encode the current fields we have in the cell so we can
  264. * compute the signature from the raw bytes of the cell. */
  265. tmp_cell_enc_len = trn_cell_establish_intro_encode(tmp_cell_enc,
  266. sizeof(tmp_cell_enc),
  267. cell);
  268. if (BUG(tmp_cell_enc_len < 0)) {
  269. goto done;
  270. }
  271. if (ed25519_sign_prefixed(&sig, tmp_cell_enc,
  272. tmp_cell_enc_len - tmp_cell_sig_offset,
  273. ESTABLISH_INTRO_SIG_PREFIX, &ip->auth_key_kp)) {
  274. log_warn(LD_BUG, "Unable to make signature for ESTABLISH_INTRO cell.");
  275. goto done;
  276. }
  277. /* Copy the signature into the cell. */
  278. sig_ptr = trn_cell_establish_intro_getarray_sig(cell);
  279. memcpy(sig_ptr, sig.sig, sig_len);
  280. }
  281. /* Encode the cell. Can't be bigger than a standard cell. */
  282. cell_len = trn_cell_establish_intro_encode(cell_out, RELAY_PAYLOAD_SIZE,
  283. cell);
  284. done:
  285. trn_cell_establish_intro_free(cell);
  286. return cell_len;
  287. }
  288. /* Parse the INTRO_ESTABLISHED cell in the payload of size payload_len. If we
  289. * are successful at parsing it, return the length of the parsed cell else a
  290. * negative value on error. */
  291. ssize_t
  292. hs_cell_parse_intro_established(const uint8_t *payload, size_t payload_len)
  293. {
  294. ssize_t ret;
  295. trn_cell_intro_established_t *cell = NULL;
  296. tor_assert(payload);
  297. /* Try to parse the payload into a cell making sure we do actually have a
  298. * valid cell. */
  299. ret = trn_cell_intro_established_parse(&cell, payload, payload_len);
  300. if (ret >= 0) {
  301. /* On success, we do not keep the cell, we just notify the caller that it
  302. * was successfully parsed. */
  303. trn_cell_intro_established_free(cell);
  304. }
  305. return ret;
  306. }
  307. /* Parsse the INTRODUCE2 cell using data which contains everything we need to
  308. * do so and contains the destination buffers of information we extract and
  309. * compute from the cell. Return 0 on success else a negative value. The
  310. * service and circ are only used for logging purposes. */
  311. ssize_t
  312. hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
  313. const origin_circuit_t *circ,
  314. const hs_service_t *service)
  315. {
  316. int ret = -1;
  317. uint8_t *decrypted = NULL;
  318. size_t encrypted_section_len;
  319. const uint8_t *encrypted_section;
  320. trn_cell_introduce1_t *cell = NULL;
  321. trn_cell_introduce_encrypted_t *enc_cell = NULL;
  322. hs_ntor_intro_cell_keys_t *intro_keys = NULL;
  323. tor_assert(data);
  324. tor_assert(circ);
  325. tor_assert(service);
  326. /* Parse the cell so we can start cell validation. */
  327. if (trn_cell_introduce1_parse(&cell, data->payload,
  328. data->payload_len) < 0) {
  329. log_info(LD_PROTOCOL, "Unable to parse INTRODUCE2 cell on circuit %u "
  330. "for service %s",
  331. TO_CIRCUIT(circ)->n_circ_id,
  332. safe_str_client(service->onion_address));
  333. goto done;
  334. }
  335. /* XXX: Add/Test replaycache. */
  336. log_info(LD_REND, "Received a decodable INTRODUCE2 cell on circuit %u "
  337. "for service %s. Decoding encrypted section...",
  338. TO_CIRCUIT(circ)->n_circ_id,
  339. safe_str_client(service->onion_address));
  340. encrypted_section = trn_cell_introduce1_getconstarray_encrypted(cell);
  341. encrypted_section_len = trn_cell_introduce1_getlen_encrypted(cell);
  342. /* Encrypted section must at least contain the CLIENT_PK and MAC which is
  343. * defined in section 3.3.2 of the specification. */
  344. if (encrypted_section_len < (CURVE25519_PUBKEY_LEN + DIGEST256_LEN)) {
  345. log_info(LD_REND, "Invalid INTRODUCE2 encrypted section length "
  346. "for service %s. Dropping cell.",
  347. safe_str_client(service->onion_address));
  348. goto done;
  349. }
  350. /* Build the key material out of the key material found in the cell. */
  351. intro_keys = get_introduce2_key_material(data->auth_pk, data->enc_kp,
  352. data->subcredential,
  353. encrypted_section,
  354. &data->client_pk);
  355. if (intro_keys == NULL) {
  356. log_info(LD_REND, "Invalid INTRODUCE2 encrypted data. Unable to "
  357. "compute key material on circuit %u for service %s",
  358. TO_CIRCUIT(circ)->n_circ_id,
  359. safe_str_client(service->onion_address));
  360. goto done;
  361. }
  362. /* Validate MAC from the cell and our computed key material. The MAC field
  363. * in the cell is at the end of the encrypted section. */
  364. {
  365. uint8_t mac[DIGEST256_LEN];
  366. /* The MAC field is at the very end of the ENCRYPTED section. */
  367. size_t mac_offset = encrypted_section_len - sizeof(mac);
  368. /* Compute the MAC. Use the entire encoded payload with a length up to the
  369. * ENCRYPTED section. */
  370. compute_introduce_mac(data->payload,
  371. data->payload_len - encrypted_section_len,
  372. encrypted_section, encrypted_section_len,
  373. intro_keys->mac_key, sizeof(intro_keys->mac_key),
  374. mac, sizeof(mac));
  375. if (tor_memcmp(mac, encrypted_section + mac_offset, sizeof(mac))) {
  376. log_info(LD_REND, "Invalid MAC validation for INTRODUCE2 cell on "
  377. "circuit %u for service %s",
  378. TO_CIRCUIT(circ)->n_circ_id,
  379. safe_str_client(service->onion_address));
  380. goto done;
  381. }
  382. }
  383. {
  384. /* The ENCRYPTED_DATA section starts just after the CLIENT_PK. */
  385. const uint8_t *encrypted_data =
  386. encrypted_section + sizeof(data->client_pk);
  387. /* It's symmetric encryption so it's correct to use the ENCRYPTED length
  388. * for decryption. Computes the length of ENCRYPTED_DATA meaning removing
  389. * the CLIENT_PK and MAC length. */
  390. size_t encrypted_data_len =
  391. encrypted_section_len - (sizeof(data->client_pk) + DIGEST256_LEN);
  392. /* This decrypts the ENCRYPTED_DATA section of the cell. */
  393. decrypted = decrypt_introduce2(intro_keys->enc_key,
  394. encrypted_data, encrypted_data_len);
  395. if (decrypted == NULL) {
  396. log_info(LD_REND, "Unable to decrypt the ENCRYPTED section of an "
  397. "INTRODUCE2 cell on circuit %u for service %s",
  398. TO_CIRCUIT(circ)->n_circ_id,
  399. safe_str_client(service->onion_address));
  400. goto done;
  401. }
  402. /* Parse this blob into an encrypted cell structure so we can then extract
  403. * the data we need out of it. */
  404. enc_cell = parse_introduce2_encrypted(decrypted, encrypted_data_len,
  405. circ, service);
  406. memwipe(decrypted, 0, encrypted_data_len);
  407. if (enc_cell == NULL) {
  408. goto done;
  409. }
  410. }
  411. /* XXX: Implement client authorization checks. */
  412. /* Extract onion key and rendezvous cookie from the cell used for the
  413. * rendezvous point circuit e2e encryption. */
  414. memcpy(data->onion_pk.public_key,
  415. trn_cell_introduce_encrypted_getconstarray_onion_key(enc_cell),
  416. CURVE25519_PUBKEY_LEN);
  417. memcpy(data->rendezvous_cookie,
  418. trn_cell_introduce_encrypted_getconstarray_rend_cookie(enc_cell),
  419. sizeof(data->rendezvous_cookie));
  420. /* Extract rendezvous link specifiers. */
  421. for (size_t idx = 0;
  422. idx < trn_cell_introduce_encrypted_get_nspec(enc_cell); idx++) {
  423. link_specifier_t *lspec =
  424. trn_cell_introduce_encrypted_get_nspecs(enc_cell, idx);
  425. smartlist_add(data->link_specifiers, hs_link_specifier_dup(lspec));
  426. }
  427. /* Success. */
  428. ret = 0;
  429. log_info(LD_REND, "Valid INTRODUCE2 cell. Launching rendezvous circuit.");
  430. done:
  431. if (intro_keys) {
  432. memwipe(intro_keys, 0, sizeof(hs_ntor_intro_cell_keys_t));
  433. tor_free(intro_keys);
  434. }
  435. tor_free(decrypted);
  436. trn_cell_introduce1_free(cell);
  437. trn_cell_introduce_encrypted_free(enc_cell);
  438. return ret;
  439. }
  440. /* Build a RENDEZVOUS1 cell with the given rendezvous cookie and handshake
  441. * info. The encoded cell is put in cell_out and the length of the data is
  442. * returned. This can't fail. */
  443. ssize_t
  444. hs_cell_build_rendezvous1(const uint8_t *rendezvous_cookie,
  445. size_t rendezvous_cookie_len,
  446. const uint8_t *rendezvous_handshake_info,
  447. size_t rendezvous_handshake_info_len,
  448. uint8_t *cell_out)
  449. {
  450. ssize_t cell_len;
  451. trn_cell_rendezvous1_t *cell;
  452. tor_assert(rendezvous_cookie);
  453. tor_assert(rendezvous_handshake_info);
  454. tor_assert(cell_out);
  455. cell = trn_cell_rendezvous1_new();
  456. /* Set the RENDEZVOUS_COOKIE. */
  457. memcpy(trn_cell_rendezvous1_getarray_rendezvous_cookie(cell),
  458. rendezvous_cookie, rendezvous_cookie_len);
  459. /* Set the HANDSHAKE_INFO. */
  460. trn_cell_rendezvous1_setlen_handshake_info(cell,
  461. rendezvous_handshake_info_len);
  462. memcpy(trn_cell_rendezvous1_getarray_handshake_info(cell),
  463. rendezvous_handshake_info, rendezvous_handshake_info_len);
  464. /* Encoding. */
  465. cell_len = trn_cell_rendezvous1_encode(cell_out, RELAY_PAYLOAD_SIZE, cell);
  466. tor_assert(cell_len > 0);
  467. trn_cell_rendezvous1_free(cell);
  468. return cell_len;
  469. }