diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-08-29 15:02:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-08-29 15:02:11 -0400 |
commit | bbaa7d09a045130560a2f5da579671c5e02c9cd7 (patch) | |
tree | 232540453f40eb00b2dc0492b236967f383627e8 /src/or/nodelist.c | |
parent | f46ce6e3d8bea3cf00388c87c29cdcafd4bab350 (diff) | |
parent | 19816f2f782568722964d35ee132af441a809db3 (diff) | |
download | tor-bbaa7d09a045130560a2f5da579671c5e02c9cd7.tar.gz tor-bbaa7d09a045130560a2f5da579671c5e02c9cd7.zip |
Merge remote-tracking branch 'teor/reject-tap-v6'
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r-- | src/or/nodelist.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 7b64cafd79..070e2e9e0d 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -1173,14 +1173,38 @@ node_get_pref_ipv6_dirport(const node_t *node, tor_addr_port_t *ap_out) } } +/** Return true iff <b>md</b> has a curve25519 onion key. + * Use node_has_curve25519_onion_key() instead of calling this directly. */ +static int +microdesc_has_curve25519_onion_key(const microdesc_t *md) +{ + if (!md) { + return 0; + } + + if (!md->onion_curve25519_pkey) { + return 0; + } + + if (tor_mem_is_zero((const char*)md->onion_curve25519_pkey->public_key, + CURVE25519_PUBKEY_LEN)) { + return 0; + } + + return 1; +} + /** Return true iff <b>node</b> has a curve25519 onion key. */ int node_has_curve25519_onion_key(const node_t *node) { + if (!node) + return 0; + if (node->ri) - return node->ri->onion_curve25519_pkey != NULL; + return routerinfo_has_curve25519_onion_key(node->ri); else if (node->md) - return node->md->onion_curve25519_pkey != NULL; + return microdesc_has_curve25519_onion_key(node->md); else return 0; } |