aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-14 14:28:11 -0400
committerNick Mathewson <nickm@torproject.org>2016-11-10 09:43:27 -0500
commit8406677a5e6db74bd593a7d43868054b54b147df (patch)
tree19c22f6be0d4140627906814e28eff1cd775020c
parent431565e0531eb6cfdaabd2bba8912655898f079b (diff)
downloadtor-8406677a5e6db74bd593a7d43868054b54b147df.tar.gz
tor-8406677a5e6db74bd593a7d43868054b54b147df.zip
Accessor functions to get a node's ID keys.
-rw-r--r--src/or/nodelist.c33
-rw-r--r--src/or/nodelist.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 2802d5b9e0..9486224379 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -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)
diff --git a/src/or/nodelist.h b/src/or/nodelist.h
index 71a91e107f..2cdcdcee42 100644
--- a/src/or/nodelist.h
+++ b/src/or/nodelist.h
@@ -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);