summaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-11 12:37:58 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-08 16:48:00 -0500
commit424ae9e18bc902e6c96a0e49b609f40868174af8 (patch)
tree1462efb5d9ae3f68406a29b23eb89e6b48102f3d /src/or/nodelist.c
parent3b1e04fe4505ccbd7d93061dccb5673523519c64 (diff)
downloadtor-424ae9e18bc902e6c96a0e49b609f40868174af8.tar.gz
tor-424ae9e18bc902e6c96a0e49b609f40868174af8.zip
helper to test a node for matching an ed25519 ID.
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 1f993e4595..d8d2dbbfd4 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -671,6 +671,18 @@ node_get_ed25519_id(const node_t *node)
return NULL;
}
+/** Return true iff this node's Ed25519 identity matches <b>id</b>.
+ * (An absent Ed25519 identity matches NULL or zero.) */
+int
+node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id)
+{
+ const ed25519_public_key_t *node_id = node_get_ed25519_id(node);
+ if (node_id == NULL || ed25519_public_key_is_zero(node_id)) {
+ return id == NULL || ed25519_public_key_is_zero(id);
+ } else {
+ return id && ed25519_pubkey_eq(node_id, id);
+ }
+}
/** Return true iff <b>node</b> supports authenticating itself
* by ed25519 ID during the link handshake in a way that we can understand