summaryrefslogtreecommitdiff
path: root/src/feature/hs/hs_client.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-06-28 11:42:35 -0400
committerMicah Elizabeth Scott <beth@torproject.org>2023-05-10 07:37:11 -0700
commit8b41e09a775e882096364210317813c830160a5b (patch)
tree9ffc826432bac77288a360d18e1d5b1f0409342a /src/feature/hs/hs_client.c
parent26957b47ac8aff33e8c6a6de2a227c0182749206 (diff)
downloadtor-8b41e09a775e882096364210317813c830160a5b.tar.gz
tor-8b41e09a775e882096364210317813c830160a5b.zip
hs: Client now solve PoW if present
At this commit, the tor main loop solves it. We might consider moving this to the CPU pool at some point. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/hs/hs_client.c')
-rw-r--r--src/feature/hs/hs_client.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c
index 7cee3480d5..e241e6218d 100644
--- a/src/feature/hs/hs_client.c
+++ b/src/feature/hs/hs_client.c
@@ -613,6 +613,7 @@ send_introduce1(origin_circuit_t *intro_circ,
char onion_address[HS_SERVICE_ADDR_LEN_BASE32 + 1];
const ed25519_public_key_t *service_identity_pk = NULL;
const hs_desc_intro_point_t *ip;
+ hs_pow_solution_t *pow_solution = NULL;
tor_assert(rend_circ);
if (intro_circ_is_ok(intro_circ) < 0) {
@@ -668,9 +669,24 @@ send_introduce1(origin_circuit_t *intro_circ,
goto perm_err;
}
+ /* If the descriptor contains PoW parameters then the service is
+ * expecting a PoW solution in the INTRODUCE cell, which we solve here. */
+ if (desc->encrypted_data.pow_params) {
+ log_debug(LD_REND, "PoW params present in descriptor.");
+ pow_solution = tor_malloc_zero(sizeof(hs_pow_solution_t));
+ if (hs_pow_solve(desc->encrypted_data.pow_params, pow_solution)) {
+ log_warn(LD_REND, "Haven't solved the PoW yet.");
+ goto tran_err;
+ }
+ /* Set flag to reflect that the HS we are attempting to rendezvous has PoW
+ * defenses enabled, and as such we will need to be more lenient with
+ * timing out while waiting for the circuit to be built. */
+ rend_circ->hs_with_pow_circ = 1;
+ }
+
/* Send the INTRODUCE1 cell. */
if (hs_circ_send_introduce1(intro_circ, rend_circ, ip,
- &desc->subcredential) < 0) {
+ &desc->subcredential, pow_solution) < 0) {
if (TO_CIRCUIT(intro_circ)->marked_for_close) {
/* If the introduction circuit was closed, we were unable to send the
* cell for some reasons. In any case, the intro circuit has to be
@@ -724,6 +740,7 @@ send_introduce1(origin_circuit_t *intro_circ,
end:
memwipe(onion_address, 0, sizeof(onion_address));
+ tor_free(pow_solution);
return status;
}