]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs_pow: add per-circuit effort information to control port
authorMicah Elizabeth Scott <beth@torproject.org>
Wed, 26 Apr 2023 22:29:04 +0000 (15:29 -0700)
committerMicah Elizabeth Scott <beth@torproject.org>
Wed, 10 May 2023 14:41:37 +0000 (07:41 -0700)
This lets controller apps see the outgoing PoW effort on client
circuits, and the validated effort received on an incoming service
circuit.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
src/core/or/origin_circuit_st.h
src/feature/control/control_fmt.c
src/feature/hs/hs_circuit.c
src/feature/hs/hs_pow.c

index 3b3fcc9b4245f608f79eaff103655c04caf023f1..22fc3316b9a68d989a75100610c307fbc06cb2b8 100644 (file)
@@ -212,6 +212,10 @@ struct origin_circuit_t {
    * (in host byte order) for response comparison. */
   uint32_t pathbias_probe_nonce;
 
+  /** This is nonzero iff hs_with_pow_circ is set and there was a valid proof
+   * of work solution associated with this circuit. */
+  uint32_t hs_pow_effort;
+
   /** Set iff this is a hidden-service circuit for a HS with PoW defenses
    * enabled, so that we know to be more lenient with timing out the
    * circuit-build to allow the service time to work through the queue of
index cc8686818a488f5c361348f522ac9cd7fe993943..b6efd18163de45a0b15f1d16cfea4ad591438d75 100644 (file)
@@ -153,6 +153,13 @@ circuit_describe_status_for_controller(origin_circuit_t *circ)
     tor_free(socks_password_escaped);
   }
 
+  /* Attach the proof-of-work solution effort, if it's nonzero. Clients set
+   * this to the effort they've chosen, services set this to a value that
+   * was provided by the client and then verified by the service. */
+  if (circ->hs_pow_effort > 0) {
+    smartlist_add_asprintf(descparts, "HS_POW=v1,%u", circ->hs_pow_effort);
+  }
+
   rv = smartlist_join_strings(descparts, " ", 0, NULL);
 
   SMARTLIST_FOREACH(descparts, char *, cp, tor_free(cp));
index ccd6711041e5ecde485c28b2160085f20cad04e8..9311a261691e6672db240b7cfac23d7e4fae7ec2 100644 (file)
@@ -429,6 +429,13 @@ launch_rendezvous_point_circuit,(const hs_service_t *service,
     tor_assert(circ->hs_ident);
   }
 
+  /* Remember PoW state if this introduction included a valid proof of work
+   * client puzzle extension. */
+  if (rdv_data->pow_effort > 0) {
+    circ->hs_pow_effort = rdv_data->pow_effort;
+    circ->hs_with_pow_circ = 1;
+  }
+
   /* Setup congestion control if asked by the client from the INTRO cell. */
   if (rdv_data->cc_enabled) {
     hs_circ_setup_congestion_control(circ, congestion_control_sendme_inc(),
index 4f662b58d9e669e779ae948a27ae4d020f0ccd4d..1a23c69836884a9f2b4c578663a2d5b4144c4798 100644 (file)
@@ -446,6 +446,9 @@ pow_worker_replyfn(void *work_)
      * timing out while waiting for the service-side circuit to be built. */
     rend_circ->hs_with_pow_circ = 1;
 
+    /* Remember the PoW effort we chose, for client-side rend circuits. */
+    rend_circ->hs_pow_effort = job->pow_inputs.effort;
+
     // and then send that intro cell
     if (send_introduce1(intro_circ, rend_circ,
                         desc, job->pow_solution_out, ip) < 0) {