mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Avoid a needless decode/re-encode step in assigning onion keys
Previously we had decoded the asn.1 to get a public key, and then discarded the asn.1 so that we had to re-encode the key to store it in the onion_pkey field of a microdesc_t or routerinfo_t. Now we can just do a tor_memdup() instead, which should be loads faster.
This commit is contained in:
parent
0556942284
commit
7113a339dc
@ -177,8 +177,8 @@ microdescs_parse_from_string(const char *s, const char *eos,
|
||||
"Relay's onion key had invalid exponent.");
|
||||
goto next;
|
||||
}
|
||||
router_set_rsa_onion_pkey(tok->key, &md->onion_pkey,
|
||||
&md->onion_pkey_len);
|
||||
md->onion_pkey = tor_memdup(tok->object_body, tok->object_size);
|
||||
md->onion_pkey_len = tok->object_size;
|
||||
crypto_pk_free(tok->key);
|
||||
|
||||
if ((tok = find_opt_by_keyword(tokens, K_ONION_KEY_NTOR))) {
|
||||
|
@ -588,8 +588,8 @@ router_parse_entry_from_string(const char *s, const char *end,
|
||||
"Relay's onion key had invalid exponent.");
|
||||
goto err;
|
||||
}
|
||||
router_set_rsa_onion_pkey(tok->key, &router->onion_pkey,
|
||||
&router->onion_pkey_len);
|
||||
router->onion_pkey = tor_memdup(tok->object_body, tok->object_size);
|
||||
router->onion_pkey_len = tok->object_size;
|
||||
crypto_pk_free(tok->key);
|
||||
|
||||
if ((tok = find_opt_by_keyword(tokens, K_ONION_KEY_NTOR))) {
|
||||
|
Loading…
Reference in New Issue
Block a user