Accessor functions to get a node's ID keys.

This commit is contained in:
Nick Mathewson 2016-09-14 14:28:11 -04:00
parent 431565e053
commit 8406677a5e
2 changed files with 35 additions and 0 deletions

View File

@ -53,6 +53,7 @@
#include "router.h"
#include "routerlist.h"
#include "routerset.h"
#include "torcert.h"
#include <string.h>
@ -646,6 +647,38 @@ node_get_by_nickname,(const char *nickname, int warn_if_unnamed))
}
}
/** Return the Ed25519 identity key for the provided node, or NULL if it
* doesn't have one. */
const ed25519_public_key_t *
node_get_ed25519_id(const node_t *node)
{
if (node->ri) {
if (node->ri->cache_info.signing_key_cert) {
const ed25519_public_key_t *pk =
&node->ri->cache_info.signing_key_cert->signing_key;
if (BUG(ed25519_public_key_is_zero(pk)))
goto try_the_md;
return pk;
}
}
try_the_md:
if (node->md) {
if (node->md->ed25519_identity_pkey) {
return node->md->ed25519_identity_pkey;
}
}
return NULL;
}
/** Return the RSA ID key's SHA1 digest for the provided node. */
const uint8_t *
node_get_rsa_id_digest(const node_t *node)
{
tor_assert(node);
return (const uint8_t*)node->identity;
}
/** Return the nickname of <b>node</b>, or NULL if we can't find one. */
const char *
node_get_nickname(const node_t *node)

View File

@ -55,6 +55,8 @@ void node_get_address_string(const node_t *node, char *cp, size_t len);
long node_get_declared_uptime(const node_t *node);
time_t node_get_published_on(const node_t *node);
const smartlist_t *node_get_declared_family(const node_t *node);
const ed25519_public_key_t *node_get_ed25519_id(const node_t *node);
const uint8_t *node_get_rsa_id_digest(const node_t *node);
int node_has_ipv6_addr(const node_t *node);
int node_has_ipv6_orport(const node_t *node);