mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +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);
|
tor_assert(circ);
|
||||||
|
|
||||||
if (ip->base.is_only_legacy) {
|
if (ip->base.is_only_legacy) {
|
||||||
uint8_t digest[DIGEST_LEN];
|
hs_circuitmap_register_intro_circ_v2_service_side(circ,
|
||||||
if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) {
|
ip->legacy_key_digest);
|
||||||
return;
|
|
||||||
}
|
|
||||||
hs_circuitmap_register_intro_circ_v2_service_side(circ, digest);
|
|
||||||
} else {
|
} else {
|
||||||
hs_circuitmap_register_intro_circ_v3_service_side(circ,
|
hs_circuitmap_register_intro_circ_v3_service_side(circ,
|
||||||
&ip->auth_key_kp.pubkey);
|
&ip->auth_key_kp.pubkey);
|
||||||
@ -675,22 +672,14 @@ setup_introduce1_data(const hs_desc_intro_point_t *ip,
|
|||||||
origin_circuit_t *
|
origin_circuit_t *
|
||||||
hs_circ_service_get_intro_circ(const hs_service_intro_point_t *ip)
|
hs_circ_service_get_intro_circ(const hs_service_intro_point_t *ip)
|
||||||
{
|
{
|
||||||
origin_circuit_t *circ = NULL;
|
|
||||||
|
|
||||||
tor_assert(ip);
|
tor_assert(ip);
|
||||||
|
|
||||||
if (ip->base.is_only_legacy) {
|
if (ip->base.is_only_legacy) {
|
||||||
uint8_t digest[DIGEST_LEN];
|
return hs_circuitmap_get_intro_circ_v2_service_side(ip->legacy_key_digest);
|
||||||
if (BUG(crypto_pk_get_digest(ip->legacy_key, (char *) digest) < 0)) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
circ = hs_circuitmap_get_intro_circ_v2_service_side(digest);
|
|
||||||
} else {
|
} else {
|
||||||
circ = hs_circuitmap_get_intro_circ_v3_service_side(
|
return hs_circuitmap_get_intro_circ_v3_service_side(
|
||||||
&ip->auth_key_kp.pubkey);
|
&ip->auth_key_kp.pubkey);
|
||||||
}
|
}
|
||||||
end:
|
|
||||||
return circ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when we fail building a rendezvous circuit at some point other than
|
/* 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) {
|
if (crypto_pk_generate_key(ip->legacy_key) < 0) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if (crypto_pk_get_digest(ip->legacy_key,
|
||||||
|
(char *) ip->legacy_key_digest) < 0) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ei == NULL) {
|
if (ei == NULL) {
|
||||||
|
@ -51,6 +51,9 @@ typedef struct hs_service_intro_point_t {
|
|||||||
* the base object legacy flag is set. */
|
* the base object legacy flag is set. */
|
||||||
crypto_pk_t *legacy_key;
|
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. */
|
/* Amount of INTRODUCE2 cell accepted from this intro point. */
|
||||||
uint64_t introduce2_count;
|
uint64_t introduce2_count;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user