diff options
author | David Goulet <dgoulet@torproject.org> | 2017-07-19 11:42:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:34 -0400 |
commit | 2cae4f41006cd1885c33870232a040f98ffd6597 (patch) | |
tree | 5c8bcd47e7a90bc69e441325722074c200cca09b /src/or/hs_circuit.c | |
parent | 6c3d525c361adac1ad769f87a343fe3e9d2b050b (diff) | |
download | tor-2cae4f41006cd1885c33870232a040f98ffd6597.tar.gz tor-2cae4f41006cd1885c33870232a040f98ffd6597.zip |
prop224: Move get_intro_circuit() to hs_circuit.c
Make this function public so we can use it both in hs_circuit.c and
hs_service.c to avoid code duplication.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_circuit.c')
-rw-r--r-- | src/or/hs_circuit.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c index ce85229470..adca189ad8 100644 --- a/src/or/hs_circuit.c +++ b/src/or/hs_circuit.c @@ -215,17 +215,7 @@ count_opened_desc_intro_point_circuits(const hs_service_t *service, DIGEST256MAP_FOREACH(desc->intro_points.map, key, const hs_service_intro_point_t *, ip) { circuit_t *circ; - origin_circuit_t *ocirc; - if (ip->base.is_only_legacy) { - uint8_t digest[DIGEST_LEN]; - if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) { - continue; - } - ocirc = hs_circuitmap_get_intro_circ_v2_service_side(digest); - } else { - ocirc = - hs_circuitmap_get_intro_circ_v3_service_side(&ip->auth_key_kp.pubkey); - } + origin_circuit_t *ocirc = hs_circ_service_get_intro_circ(ip); if (ocirc == NULL) { continue; } @@ -665,6 +655,29 @@ retry_service_rendezvous_point(const origin_circuit_t *circ) /* Public API */ /* ========== */ +/* Return an introduction point circuit matching the given intro point object. + * NULL is returned is no such circuit can be found. */ +origin_circuit_t * +hs_circ_service_get_intro_circ(const hs_service_intro_point_t *ip) +{ + origin_circuit_t *circ = NULL; + + tor_assert(ip); + + if (ip->base.is_only_legacy) { + uint8_t digest[DIGEST_LEN]; + if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) { + goto end; + } + circ = hs_circuitmap_get_intro_circ_v2_service_side(digest); + } else { + circ = hs_circuitmap_get_intro_circ_v3_service_side( + &ip->auth_key_kp.pubkey); + } + end: + return circ; +} + /* Called when we fail building a rendezvous circuit at some point other than * the last hop: launches a new circuit to the same rendezvous point. This * supports legacy service. */ |