diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-09-18 11:11:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-09-18 11:12:43 -0400 |
commit | 1e9488f2fd829d48eb5ef6c2170e0f7163061136 (patch) | |
tree | ad28be0754779394dcb33e047406ae2325b665cd /src/feature | |
parent | 02840169d860384257042bdf6d7601c2bf48b47b (diff) | |
download | tor-1e9488f2fd829d48eb5ef6c2170e0f7163061136.tar.gz tor-1e9488f2fd829d48eb5ef6c2170e0f7163061136.zip |
Extract expressions in construct_ntor_key_map()
No behavioral change here: this is just refactoring.
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/relay/router.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index dad2c6a50f..88a30cef08 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -278,19 +278,16 @@ construct_ntor_key_map(void) { di_digest256_map_t *m = NULL; - if (!tor_mem_is_zero((const char*) - curve25519_onion_key.pubkey.public_key, - CURVE25519_PUBKEY_LEN)) { - dimap_add_entry(&m, - curve25519_onion_key.pubkey.public_key, + const uint8_t *cur_pk = curve25519_onion_key.pubkey.public_key; + const uint8_t *last_pk = last_curve25519_onion_key.pubkey.public_key; + + if (!tor_mem_is_zero((const char *)cur_pk, CURVE25519_PUBKEY_LEN)) { + dimap_add_entry(&m, cur_pk, tor_memdup(&curve25519_onion_key, sizeof(curve25519_keypair_t))); } - if (!tor_mem_is_zero((const char*) - last_curve25519_onion_key.pubkey.public_key, - CURVE25519_PUBKEY_LEN)) { - dimap_add_entry(&m, - last_curve25519_onion_key.pubkey.public_key, + if (!tor_mem_is_zero((const char*)last_pk, CURVE25519_PUBKEY_LEN)) { + dimap_add_entry(&m, last_pk, tor_memdup(&last_curve25519_onion_key, sizeof(curve25519_keypair_t))); } |