[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] hs: Remove v2 code from HS circuitmap



commit 9782cd2c9be8e6581eaee246faa9c4ac4554b2d5
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Tue Feb 16 10:55:56 2021 -0500

    hs: Remove v2 code from HS circuitmap
    
    Related to #40266
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/feature/hs/hs_circuitmap.c | 62 ++----------------------------------------
 src/feature/hs/hs_circuitmap.h | 13 ---------
 src/test/test_circuitlist.c    | 62 ++++++++++++++++++++++++++++--------------
 3 files changed, 44 insertions(+), 93 deletions(-)

diff --git a/src/feature/hs/hs_circuitmap.c b/src/feature/hs/hs_circuitmap.c
index e46b008a5c..ee416e0d24 100644
--- a/src/feature/hs/hs_circuitmap.c
+++ b/src/feature/hs/hs_circuitmap.c
@@ -273,7 +273,7 @@ hs_circuitmap_get_or_circuit(hs_token_type_t type,
 
 /**** Public relay-side getters: */
 
-/** Public function: Return v2 and v3 introduction circuit to this relay.
+/** Public function: Return v3 introduction circuit to this relay.
  * Always return a newly allocated list for which it is the caller's
  * responsibility to free it. */
 smartlist_t *
@@ -286,12 +286,11 @@ hs_circuitmap_get_all_intro_circ_relay_side(void)
     circuit_t *circ = *iter;
 
     /* An origin circuit or purpose is wrong or the hs token is not set to be
-     * a v2 or v3 intro relay side type, we ignore the circuit. Else, we have
+     * a v3 intro relay side type, we ignore the circuit. Else, we have
      * a match so add it to our list. */
     if (CIRCUIT_IS_ORIGIN(circ) ||
         circ->purpose != CIRCUIT_PURPOSE_INTRO_POINT ||
-        (circ->hs_token->type != HS_TOKEN_INTRO_V3_RELAY_SIDE &&
-         circ->hs_token->type != HS_TOKEN_INTRO_V2_RELAY_SIDE)) {
+        circ->hs_token->type != HS_TOKEN_INTRO_V3_RELAY_SIDE) {
       continue;
     }
     smartlist_add(circuit_list, circ);
@@ -312,16 +311,6 @@ hs_circuitmap_get_intro_circ_v3_relay_side(
                                       CIRCUIT_PURPOSE_INTRO_POINT);
 }
 
-/** Public function: Return v2 introduction circuit to this relay with
- * <b>digest</b>. Return NULL if no such circuit is found in the circuitmap. */
-or_circuit_t *
-hs_circuitmap_get_intro_circ_v2_relay_side(const uint8_t *digest)
-{
-  return hs_circuitmap_get_or_circuit(HS_TOKEN_INTRO_V2_RELAY_SIDE,
-                                      REND_TOKEN_LEN, digest,
-                                      CIRCUIT_PURPOSE_INTRO_POINT);
-}
-
 /** Public function: Return rendezvous circuit to this relay with rendezvous
  * <b>cookie</b>. Return NULL if no such circuit is found in the circuitmap. */
 or_circuit_t *
@@ -344,16 +333,6 @@ hs_circuitmap_register_rend_circ_relay_side(or_circuit_t *circ,
                                  HS_TOKEN_REND_RELAY_SIDE,
                                  REND_TOKEN_LEN, cookie);
 }
-/** Public function: Register v2 intro circuit with key <b>digest</b> to the
- * circuitmap. */
-void
-hs_circuitmap_register_intro_circ_v2_relay_side(or_circuit_t *circ,
-                                                const uint8_t *digest)
-{
-  hs_circuitmap_register_circuit(TO_CIRCUIT(circ),
-                                 HS_TOKEN_INTRO_V2_RELAY_SIDE,
-                                 REND_TOKEN_LEN, digest);
-}
 
 /** Public function: Register v3 intro circuit with key <b>auth_key</b> to the
  * circuitmap. */
@@ -393,30 +372,6 @@ hs_circuitmap_get_intro_circ_v3_service_side(const
   return circ;
 }
 
-/** Public function: Return v2 introduction circuit originating from this
- * hidden service with <b>digest</b>. Return NULL if no such circuit is found
- * in the circuitmap. */
-origin_circuit_t *
-hs_circuitmap_get_intro_circ_v2_service_side(const uint8_t *digest)
-{
-  origin_circuit_t *circ = NULL;
-
-  /* Check first for established intro circuits */
-  circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_INTRO_V2_SERVICE_SIDE,
-                                          REND_TOKEN_LEN, digest,
-                                          CIRCUIT_PURPOSE_S_INTRO);
-  if (circ) {
-    return circ;
-  }
-
-  /* ...if nothing found, check for pending intro circs */
-  circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_INTRO_V2_SERVICE_SIDE,
-                                          REND_TOKEN_LEN, digest,
-                                          CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
-
-  return circ;
-}
-
 /** Public function: Return rendezvous circuit originating from this hidden
  * service with rendezvous <b>cookie</b>. Return NULL if no such circuit is
  * found in the circuitmap. */
@@ -515,17 +470,6 @@ hs_circuitmap_get_established_rend_circ_client_side(const uint8_t *cookie)
 
 /**** Public servide-side setters: */
 
-/** Public function: Register v2 intro circuit with key <b>digest</b> to the
- * circuitmap. */
-void
-hs_circuitmap_register_intro_circ_v2_service_side(origin_circuit_t *circ,
-                                                  const uint8_t *digest)
-{
-  hs_circuitmap_register_circuit(TO_CIRCUIT(circ),
-                                 HS_TOKEN_INTRO_V2_SERVICE_SIDE,
-                                 REND_TOKEN_LEN, digest);
-}
-
 /** Public function: Register v3 intro circuit with key <b>auth_key</b> to the
  * circuitmap. */
 void
diff --git a/src/feature/hs/hs_circuitmap.h b/src/feature/hs/hs_circuitmap.h
index df3e7a6e7e..cd6eaf95d5 100644
--- a/src/feature/hs/hs_circuitmap.h
+++ b/src/feature/hs/hs_circuitmap.h
@@ -24,14 +24,10 @@ struct or_circuit_t *
 hs_circuitmap_get_intro_circ_v3_relay_side(const
                                    struct ed25519_public_key_t *auth_key);
 struct or_circuit_t *
-hs_circuitmap_get_intro_circ_v2_relay_side(const uint8_t *digest);
-struct or_circuit_t *
 hs_circuitmap_get_rend_circ_relay_side(const uint8_t *cookie);
 
 void hs_circuitmap_register_rend_circ_relay_side(struct or_circuit_t *circ,
                                                  const uint8_t *cookie);
-void hs_circuitmap_register_intro_circ_v2_relay_side(struct or_circuit_t *circ,
-                                                     const uint8_t *digest);
 void hs_circuitmap_register_intro_circ_v3_relay_side(struct or_circuit_t *circ,
                                  const struct ed25519_public_key_t *auth_key);
 
@@ -43,17 +39,12 @@ struct origin_circuit_t *
 hs_circuitmap_get_intro_circ_v3_service_side(const
                                      struct ed25519_public_key_t *auth_key);
 struct origin_circuit_t *
-hs_circuitmap_get_intro_circ_v2_service_side(const uint8_t *digest);
-struct origin_circuit_t *
 hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie);
 struct origin_circuit_t *
 hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie);
 struct origin_circuit_t *
 hs_circuitmap_get_established_rend_circ_client_side(const uint8_t *cookie);
 
-void hs_circuitmap_register_intro_circ_v2_service_side(
-                                        struct origin_circuit_t *circ,
-                                        const uint8_t *digest);
 void hs_circuitmap_register_intro_circ_v3_service_side(
                                  struct origin_circuit_t *circ,
                                  const struct ed25519_public_key_t *auth_key);
@@ -75,15 +66,11 @@ void hs_circuitmap_free_all(void);
 typedef enum {
   /** A rendezvous cookie on a relay (128bit)*/
   HS_TOKEN_REND_RELAY_SIDE,
-  /** A v2 introduction point pubkey on a relay (160bit) */
-  HS_TOKEN_INTRO_V2_RELAY_SIDE,
   /** A v3 introduction point pubkey on a relay (256bit) */
   HS_TOKEN_INTRO_V3_RELAY_SIDE,
 
   /** A rendezvous cookie on a hidden service (128bit)*/
   HS_TOKEN_REND_SERVICE_SIDE,
-  /** A v2 introduction point pubkey on a hidden service (160bit) */
-  HS_TOKEN_INTRO_V2_SERVICE_SIDE,
   /** A v3 introduction point pubkey on a hidden service (256bit) */
   HS_TOKEN_INTRO_V3_SERVICE_SIDE,
 
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 63c4418f29..2e518e392a 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -203,6 +203,10 @@ test_rend_token_maps(void *arg)
   c4 = or_circuit_new(0, NULL);
   c5 = origin_circuit_new();
 
+  ed25519_public_key_t intro_pk1 = { {1} }; /* Junk, not important. */
+  ed25519_public_key_t intro_pk2 = { {2} }; /* Junk, not important. */
+  ed25519_public_key_t intro_pk3 = { {3} }; /* Junk, not important. */
+
   /* Make sure we really filled up the tok* variables */
   tt_int_op(tok1[REND_TOKEN_LEN-1], OP_EQ, 'y');
   tt_int_op(tok2[REND_TOKEN_LEN-1], OP_EQ, ' ');
@@ -210,31 +214,37 @@ test_rend_token_maps(void *arg)
 
   /* No maps; nothing there. */
   tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok1));
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok1));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk1));
 
   hs_circuitmap_register_rend_circ_relay_side(c1, tok1);
-  hs_circuitmap_register_intro_circ_v2_relay_side(c2, tok2);
+  hs_circuitmap_register_intro_circ_v3_relay_side(c2, &intro_pk2);
 
   tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok3));
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk3));
   tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok2));
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok1));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
 
   /* Without purpose set, we don't get the circuits */
   tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok1));
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok2));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
 
   c1->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
   c2->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
 
   /* Okay, make sure they show up now. */
   tt_ptr_op(c1, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok1));
-  tt_ptr_op(c2, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok2));
+  tt_ptr_op(c2, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
 
   /* Two items at the same place with the same token. */
   c3->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
   hs_circuitmap_register_rend_circ_relay_side(c3, tok2);
-  tt_ptr_op(c2, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok2));
+  tt_ptr_op(c2, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
   tt_ptr_op(c3, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok2));
 
   /* Marking a circuit makes it not get returned any more */
@@ -246,31 +256,36 @@ test_rend_token_maps(void *arg)
   /* Freeing a circuit makes it not get returned any more. */
   circuit_free_(TO_CIRCUIT(c2));
   c2 = NULL;
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok2));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
 
   /* c3 -- are you still there? */
   tt_ptr_op(c3, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok2));
   /* Change its cookie.  This never happens in Tor per se, but hey. */
   c3->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
-  hs_circuitmap_register_intro_circ_v2_relay_side(c3, tok3);
+  hs_circuitmap_register_intro_circ_v3_relay_side(c3, &intro_pk3);
 
   tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok2));
-  tt_ptr_op(c3, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3));
+  tt_ptr_op(c3, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk3));
 
   /* Now replace c3 with c4. */
   c4->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
-  hs_circuitmap_register_intro_circ_v2_relay_side(c4, tok3);
+  hs_circuitmap_register_intro_circ_v3_relay_side(c4, &intro_pk3);
 
-  tt_ptr_op(c4, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3));
+  tt_ptr_op(c4, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk3));
 
   tt_ptr_op(TO_CIRCUIT(c3)->hs_token, OP_EQ, NULL);
   tt_ptr_op(TO_CIRCUIT(c4)->hs_token, OP_NE, NULL);
-  tt_mem_op(TO_CIRCUIT(c4)->hs_token->token, OP_EQ, tok3, REND_TOKEN_LEN);
+  tt_mem_op(TO_CIRCUIT(c4)->hs_token->token, OP_EQ, &intro_pk3,
+            REND_TOKEN_LEN);
 
   /* Now clear c4's cookie. */
   hs_circuitmap_remove_circuit(TO_CIRCUIT(c4));
   tt_ptr_op(TO_CIRCUIT(c4)->hs_token, OP_EQ, NULL);
-  tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3));
+  tt_ptr_op(NULL, OP_EQ,
+            hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk3));
 
   /* Now let's do a check for the client-side rend circuitmap */
   c5->base_.purpose = CIRCUIT_PURPOSE_C_ESTABLISH_REND;
@@ -401,6 +416,9 @@ test_hs_circuitmap_isolation(void *arg)
 
   hs_circuitmap_init();
 
+  ed25519_public_key_t intro_pk1 = { {1} }; /* Junk, not important. */
+  ed25519_public_key_t intro_pk2 = { {2} }; /* Junk, not important. */
+
   {
     const uint8_t tok1[REND_TOKEN_LEN] = "bet i got some of th";
 
@@ -416,7 +434,8 @@ test_hs_circuitmap_isolation(void *arg)
 
     /* check that service-side getters don't work */
     tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_service_side(tok1));
-    tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_service_side(tok1));
+    tt_ptr_op(NULL, OP_EQ,
+              hs_circuitmap_get_intro_circ_v3_service_side(&intro_pk1));
 
     /* Check that the right getter works. */
     tt_ptr_op(circ1, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok1));
@@ -436,17 +455,18 @@ test_hs_circuitmap_isolation(void *arg)
     circ4->base_.purpose = CIRCUIT_PURPOSE_S_ESTABLISH_INTRO;
 
     /* Register circ2 with tok2 as service-side intro v2 circ */
-    hs_circuitmap_register_intro_circ_v2_service_side(circ2, tok2);
+    hs_circuitmap_register_intro_circ_v3_service_side(circ2, &intro_pk2);
     /* Register circ3 with tok2 again but for different purpose */
-    hs_circuitmap_register_intro_circ_v2_relay_side(circ3, tok2);
+    hs_circuitmap_register_intro_circ_v3_relay_side(circ3, &intro_pk2);
 
     /* Check that the getters work */
     tt_ptr_op(circ2, OP_EQ,
-              hs_circuitmap_get_intro_circ_v2_service_side(tok2));
-    tt_ptr_op(circ3, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok2));
+              hs_circuitmap_get_intro_circ_v3_service_side(&intro_pk2));
+    tt_ptr_op(circ3, OP_EQ,
+              hs_circuitmap_get_intro_circ_v3_relay_side(&intro_pk2));
 
     /* Register circ4 with tok2: it should override circ2 */
-    hs_circuitmap_register_intro_circ_v2_service_side(circ4, tok2);
+    hs_circuitmap_register_intro_circ_v3_service_side(circ4, &intro_pk2);
 
     /* check that relay-side getters don't work */
     tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_rend_circ_relay_side(tok2));
@@ -454,7 +474,7 @@ test_hs_circuitmap_isolation(void *arg)
     /* Check that the getter returns circ4; the last circuit registered with
      * that token. */
     tt_ptr_op(circ4, OP_EQ,
-              hs_circuitmap_get_intro_circ_v2_service_side(tok2));
+              hs_circuitmap_get_intro_circ_v3_service_side(&intro_pk2));
   }
 
  done:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits