Merge remote-tracking branch 'asn/bug23107'

This commit is contained in:
David Goulet 2018-05-03 09:33:42 -04:00
commit 2e8eb1d5e3
4 changed files with 17 additions and 15 deletions

6
changes/bug23107 Normal file
View File

@ -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.

View File

@ -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

View File

@ -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) {

View File

@ -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;