summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-05-03 09:33:42 -0400
committerDavid Goulet <dgoulet@torproject.org>2018-05-03 09:33:42 -0400
commit2e8eb1d5e32cc5849fc0676b5fa92b1606f2cae5 (patch)
tree081c14a5916c5c736d2973957aba2f2ceca382fa
parenteb00eff09defc607f4dc4b6fec7b3c80dc8b439f (diff)
parent0c346bdd689e84f92202476d96748ad9fe9d519f (diff)
downloadtor-2e8eb1d5e32cc5849fc0676b5fa92b1606f2cae5.tar.gz
tor-2e8eb1d5e32cc5849fc0676b5fa92b1606f2cae5.zip
Merge remote-tracking branch 'asn/bug23107'
-rw-r--r--changes/bug231076
-rw-r--r--src/or/hs_circuit.c19
-rw-r--r--src/or/hs_service.c4
-rw-r--r--src/or/hs_service.h3
4 files changed, 17 insertions, 15 deletions
diff --git a/changes/bug23107 b/changes/bug23107
new file mode 100644
index 0000000000..55885e10fd
--- /dev/null
+++ b/changes/bug23107
@@ -0,0 +1,6 @@
+ o Code simplification and refactoring:
+ - Put a SHA1 public key digest in hs_service_intro_point_t, and use it in
+ register_intro_circ() and service_intro_point_new(). This prevents the
+ digest from being re-calculated each time. Closes ticket 23107. Patch by
+ Neel Chauhan.
+
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
index 3a674f6223..4174470636 100644
--- a/src/or/hs_circuit.c
+++ b/src/or/hs_circuit.c
@@ -193,11 +193,8 @@ register_intro_circ(const hs_service_intro_point_t *ip,
tor_assert(circ);
if (ip->base.is_only_legacy) {
- uint8_t digest[DIGEST_LEN];
- if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) {
- return;
- }
- hs_circuitmap_register_intro_circ_v2_service_side(circ, digest);
+ hs_circuitmap_register_intro_circ_v2_service_side(circ,
+ ip->legacy_key_digest);
} else {
hs_circuitmap_register_intro_circ_v3_service_side(circ,
&ip->auth_key_kp.pubkey);
@@ -675,22 +672,14 @@ setup_introduce1_data(const hs_desc_intro_point_t *ip,
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);
+ return hs_circuitmap_get_intro_circ_v2_service_side(ip->legacy_key_digest);
} else {
- circ = hs_circuitmap_get_intro_circ_v3_service_side(
+ return 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
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index e40e9203e7..cf2760760a 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -441,6 +441,10 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy)
if (crypto_pk_generate_key(ip->legacy_key) < 0) {
goto err;
}
+ if (crypto_pk_get_digest(ip->legacy_key,
+ (char *) ip->legacy_key_digest) < 0) {
+ goto err;
+ }
}
if (ei == NULL) {
diff --git a/src/or/hs_service.h b/src/or/hs_service.h
index 2e27d8a899..ea7ee9ecf2 100644
--- a/src/or/hs_service.h
+++ b/src/or/hs_service.h
@@ -51,6 +51,9 @@ typedef struct hs_service_intro_point_t {
* the base object legacy flag is set. */
crypto_pk_t *legacy_key;
+ /* Legacy key SHA1 public key digest. */
+ uint8_t legacy_key_digest[DIGEST_LEN];
+
/* Amount of INTRODUCE2 cell accepted from this intro point. */
uint64_t introduce2_count;