diff options
author | David Goulet <dgoulet@torproject.org> | 2017-03-09 12:54:51 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:33 -0400 |
commit | dfa6301aed8f1c7164b1e8513ab64119944d976c (patch) | |
tree | a1ce43963a6c773e08eaa15e2dcb0d8e0f200ab4 /src/or/hs_cell.c | |
parent | acc7c4ee9578e37a66dff6a09c86bee5777f782d (diff) | |
download | tor-dfa6301aed8f1c7164b1e8513ab64119944d976c.tar.gz tor-dfa6301aed8f1c7164b1e8513ab64119944d976c.zip |
prop224: Handle service RENDEZVOUS1 cell
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cell.c')
-rw-r--r-- | src/or/hs_cell.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c index 18d15fe0a6..68c201b890 100644 --- a/src/or/hs_cell.c +++ b/src/or/hs_cell.c @@ -18,6 +18,7 @@ #include "hs/cell_common.h" #include "hs/cell_establish_intro.h" #include "hs/cell_introduce1.h" +#include "hs/cell_rendezvous.h" /* Compute the MAC of an INTRODUCE cell in mac_out. The encoded_cell param is * the cell content up to the ENCRYPTED section of length encoded_cell_len. @@ -500,3 +501,37 @@ hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, return ret; } +/* Build a RENDEZVOUS1 cell with the given rendezvous cookie and handshake + * info. The encoded cell is put in cell_out and the length of the data is + * returned. This can't fail. */ +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) +{ + ssize_t cell_len; + trn_cell_rendezvous1_t *cell; + + tor_assert(rendezvous_cookie); + tor_assert(rendezvous_handshake_info); + tor_assert(cell_out); + + cell = trn_cell_rendezvous1_new(); + /* Set the RENDEZVOUS_COOKIE. */ + memcpy(trn_cell_rendezvous1_getarray_rendezvous_cookie(cell), + rendezvous_cookie, rendezvous_cookie_len); + /* Set the HANDSHAKE_INFO. */ + trn_cell_rendezvous1_setlen_handshake_info(cell, + rendezvous_handshake_info_len); + memcpy(trn_cell_rendezvous1_getarray_handshake_info(cell), + rendezvous_handshake_info, rendezvous_handshake_info_len); + /* Encoding. */ + cell_len = trn_cell_rendezvous1_encode(cell_out, RELAY_PAYLOAD_SIZE, cell); + tor_assert(cell_len > 0); + + trn_cell_rendezvous1_free(cell); + return cell_len; +} + |