diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-08-29 15:05:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-08-29 15:05:05 -0400 |
commit | 94605f08fb89ea79409225362d2fa0f8a07435d7 (patch) | |
tree | 8905ef80ef6daec743eb1fd8f63c38e3ab98f3d5 /src/feature/nodelist/nodelist.c | |
parent | 810152b20f6d773172e1f28ab72a1d4b2fda2d82 (diff) | |
parent | 6c0c08bbb506f47bf97bba82e4421592f71455d7 (diff) | |
download | tor-94605f08fb89ea79409225362d2fa0f8a07435d7.tar.gz tor-94605f08fb89ea79409225362d2fa0f8a07435d7.zip |
Merge branch 'ticket27246_035_01_squashed'
Diffstat (limited to 'src/feature/nodelist/nodelist.c')
-rw-r--r-- | src/feature/nodelist/nodelist.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c index d6bc474483..e62e87ea70 100644 --- a/src/feature/nodelist/nodelist.c +++ b/src/feature/nodelist/nodelist.c @@ -1768,6 +1768,37 @@ node_get_curve25519_onion_key(const node_t *node) return NULL; } +/* Return a newly allocacted RSA onion public key taken from the given node. + * + * Return NULL if node is NULL or no RSA onion public key can be found. It is + * the caller responsability to free the returned object. */ +crypto_pk_t * +node_get_rsa_onion_key(const node_t *node) +{ + crypto_pk_t *pk = NULL; + const char *onion_pkey; + size_t onion_pkey_len; + + if (!node) { + goto end; + } + + if (node->ri) { + onion_pkey = node->ri->onion_pkey; + onion_pkey_len = node->ri->onion_pkey_len; + } else if (node->rs && node->md) { + onion_pkey = node->md->onion_pkey; + onion_pkey_len = node->md->onion_pkey_len; + } else { + /* No descriptor or microdescriptor. */ + goto end; + } + pk = router_get_rsa_onion_pkey(onion_pkey, onion_pkey_len); + + end: + return pk; +} + /** Refresh the country code of <b>ri</b>. This function MUST be called on * each router when the GeoIP database is reloaded, and on all new routers. */ void |