mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Optimize legacy intro point digest calculation.
This commit is contained in:
parent
60fad8d41f
commit
af70d3c459
6
changes/bug23107
Normal file
6
changes/bug23107
Normal 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. Fixes bug 23107. Patch by
|
||||
Neel Chauhan.
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user