tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit ee15c16742aecb4795ce12847068b7907be9e8a2
parent 2f1b3d647ff1489f4cb0f25d96701eaf35e076da
Author: David Goulet <dgoulet@torproject.org>
Date:   Sun, 23 Jul 2017 13:01:00 -0400

prop224: Parse RENDEZVOUS2 cell

Signed-off-by: David Goulet <dgoulet@torproject.org>

Diffstat:
Msrc/or/hs_cell.c | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c @@ -899,3 +899,35 @@ hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len) return ret; } +/* Handle a RENDEZVOUS2 cell encoded in payload of length payload_len. On + * success, handshake_info contains the data in the HANDSHAKE_INFO field, and + * 0 is returned. On error, a negative value is returned. */ +int +hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len, + uint8_t *handshake_info, size_t handshake_info_len) +{ + int ret = -1; + trn_cell_rendezvous2_t *cell = NULL; + + tor_assert(payload); + tor_assert(handshake_info); + + if (trn_cell_rendezvous2_parse(&cell, payload, payload_len) < 0) { + log_info(LD_REND, "Invalid RENDEZVOUS2 cell. Unable to parse it."); + goto end; + } + + /* Static size, we should never have an issue with this else we messed up + * our code flow. */ + tor_assert(trn_cell_rendezvous2_getlen_handshake_info(cell) == + handshake_info_len); + memcpy(handshake_info, + trn_cell_rendezvous2_getconstarray_handshake_info(cell), + handshake_info_len); + ret = 0; + + end: + trn_cell_rendezvous2_free(cell); + return ret; +} +