Ticket #23107: b23107-002.patch

File b23107-002.patch, 3.4 KB (added by neel, 13 months ago)

Patch (Revision 2)

  • new file changes/bug23107

    From 0eb84c6566c92e980bfa1a39507812080653dde1 Mon Sep 17 00:00:00 2001
    From: Neel Chauhan <neel@neelc.org>
    Date: Fri, 27 Apr 2018 17:45:16 -0400
    Subject: [PATCH] Put a SHA1 public key digest in hs_service_intro_point_t and
     use it in register_intro_circ() and service_intro_point_new()
    
    ---
     changes/bug23107    |  6 ++++++
     src/or/hs_circuit.c | 19 ++++---------------
     src/or/hs_service.c |  4 ++++
     src/or/hs_service.h |  3 +++
     4 files changed, 17 insertions(+), 15 deletions(-)
     create mode 100644 changes/bug23107
    
    diff --git a/changes/bug23107 b/changes/bug23107
    new file mode 100644
    index 000000000..70d1856bb
    - +  
     1  o Code simplification and refactoring:
     2    - Put a SHA1 public key digest in hs_service_intro_point_t, and use it in
     3      register_intro_circ() and service_intro_point_new(). This prevents the
     4      digest from being re-calculated each time. Fixes bug 23107. Patch by
     5      Neel Chauhan.
     6
  • src/or/hs_circuit.c

    diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
    index 3a674f622..417447063 100644
    a b register_intro_circ(const hs_service_intro_point_t *ip, 
    193193  tor_assert(circ);
    194194
    195195  if (ip->base.is_only_legacy) {
    196     uint8_t digest[DIGEST_LEN];
    197     if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) {
    198       return;
    199     }
    200     hs_circuitmap_register_intro_circ_v2_service_side(circ, digest);
     196    hs_circuitmap_register_intro_circ_v2_service_side(circ,
     197                                                      ip->legacy_key_digest);
    201198  } else {
    202199    hs_circuitmap_register_intro_circ_v3_service_side(circ,
    203200                                         &ip->auth_key_kp.pubkey);
    setup_introduce1_data(const hs_desc_intro_point_t *ip, 
    675672origin_circuit_t *
    676673hs_circ_service_get_intro_circ(const hs_service_intro_point_t *ip)
    677674{
    678   origin_circuit_t *circ = NULL;
    679 
    680675  tor_assert(ip);
    681676
    682677  if (ip->base.is_only_legacy) {
    683     uint8_t digest[DIGEST_LEN];
    684     if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) {
    685       goto end;
    686     }
    687     circ = hs_circuitmap_get_intro_circ_v2_service_side(digest);
     678    return hs_circuitmap_get_intro_circ_v2_service_side(ip->legacy_key_digest);
    688679  } else {
    689     circ = hs_circuitmap_get_intro_circ_v3_service_side(
     680    return hs_circuitmap_get_intro_circ_v3_service_side(
    690681                                        &ip->auth_key_kp.pubkey);
    691682  }
    692  end:
    693   return circ;
    694683}
    695684
    696685/* Called when we fail building a rendezvous circuit at some point other than
  • src/or/hs_service.c

    diff --git a/src/or/hs_service.c b/src/or/hs_service.c
    index 7af14373d..0c3e162c1 100644
    a b service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy) 
    441441    if (crypto_pk_generate_key(ip->legacy_key) < 0) {
    442442      goto err;
    443443    }
     444    if (crypto_pk_get_digest(ip->legacy_key,
     445                             (char *) ip->legacy_key_digest) < 0) {
     446      goto err;
     447    }
    444448  }
    445449
    446450  if (ei == NULL) {
  • src/or/hs_service.h

    diff --git a/src/or/hs_service.h b/src/or/hs_service.h
    index 2e27d8a89..ea7ee9ecf 100644
    a b typedef struct hs_service_intro_point_t { 
    5151   * the base object legacy flag is set. */
    5252  crypto_pk_t *legacy_key;
    5353
     54  /* Legacy key SHA1 public key digest. */
     55   uint8_t legacy_key_digest[DIGEST_LEN];
     56
    5457  /* Amount of INTRODUCE2 cell accepted from this intro point. */
    5558  uint64_t introduce2_count;
    5659