diff options
author | David Goulet <dgoulet@torproject.org> | 2017-11-10 14:34:41 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-05 19:39:46 -0500 |
commit | b71a9b60cc0c29899637acc0610cb87c56869c1e (patch) | |
tree | ce1d22cf93c266f64585a7780b5dedf670e613fe /src/or/hs_control.c | |
parent | 3b436d495fc6ad59ff5d9406d7ef17494286c299 (diff) | |
download | tor-b71a9b60cc0c29899637acc0610cb87c56869c1e.tar.gz tor-b71a9b60cc0c29899637acc0610cb87c56869c1e.zip |
hs-v3: Implement HS_DESC CREATED event
This makes the REPLICA= field optional for the control port event. A v2
service will always pass it and v3 is ignored.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_control.c')
-rw-r--r-- | src/or/hs_control.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/hs_control.c b/src/or/hs_control.c index add62d5832..ea010605bb 100644 --- a/src/or/hs_control.c +++ b/src/or/hs_control.c @@ -102,3 +102,26 @@ hs_control_desc_event_received(const hs_ident_dir_conn_t *ident, hsdir_id_digest); } +/* Send on the control port the "HS_DESC CREATED [...]" event. + * + * Using the onion address of the descriptor's service and the blinded public + * key of the descriptor as a descriptor ID. None can be NULL. */ +void +hs_control_desc_event_created(const char *onion_address, + const ed25519_public_key_t *blinded_pk) +{ + char base64_blinded_pk[ED25519_BASE64_LEN + 1]; + + tor_assert(onion_address); + tor_assert(blinded_pk); + + /* Build base64 encoded blinded key. */ + IF_BUG_ONCE(ed25519_public_to_base64(base64_blinded_pk, blinded_pk) < 0) { + return; + } + + /* Version 3 doesn't use the replica number in its descriptor ID computation + * so we pass negative value so the control port subsystem can ignore it. */ + control_event_hs_descriptor_created(onion_address, base64_blinded_pk, -1); +} + |