mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
In node_get_ed25519_id, detect and warn on inconsistent IDs.
This shouldn't actually be possible, but it's worth checking for.
This commit is contained in:
parent
fed3a08d8c
commit
92b1dfd50e
@ -879,23 +879,35 @@ node_get_by_nickname,(const char *nickname, int warn_if_unnamed))
|
|||||||
const ed25519_public_key_t *
|
const ed25519_public_key_t *
|
||||||
node_get_ed25519_id(const node_t *node)
|
node_get_ed25519_id(const node_t *node)
|
||||||
{
|
{
|
||||||
|
const ed25519_public_key_t *ri_pk = NULL;
|
||||||
|
const ed25519_public_key_t *md_pk = NULL;
|
||||||
if (node->ri) {
|
if (node->ri) {
|
||||||
if (node->ri->cache_info.signing_key_cert) {
|
if (node->ri->cache_info.signing_key_cert) {
|
||||||
const ed25519_public_key_t *pk =
|
ri_pk = &node->ri->cache_info.signing_key_cert->signing_key;
|
||||||
&node->ri->cache_info.signing_key_cert->signing_key;
|
if (BUG(ed25519_public_key_is_zero(ri_pk)))
|
||||||
if (BUG(ed25519_public_key_is_zero(pk)))
|
ri_pk = NULL;
|
||||||
goto try_the_md;
|
|
||||||
return pk;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try_the_md:
|
|
||||||
if (node->md) {
|
if (node->md) {
|
||||||
if (node->md->ed25519_identity_pkey) {
|
if (node->md->ed25519_identity_pkey) {
|
||||||
return node->md->ed25519_identity_pkey;
|
md_pk = node->md->ed25519_identity_pkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ri_pk && md_pk) {
|
||||||
|
if (ed25519_pubkey_eq(ri_pk, md_pk)) {
|
||||||
|
return ri_pk;
|
||||||
|
} else {
|
||||||
|
log_warn(LD_GENERAL, "Inconsistent ed25519 identities in the nodelist");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
} else if (ri_pk) {
|
||||||
|
return ri_pk;
|
||||||
|
} else {
|
||||||
|
return md_pk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Return true iff this node's Ed25519 identity matches <b>id</b>.
|
/** Return true iff this node's Ed25519 identity matches <b>id</b>.
|
||||||
* (An absent Ed25519 identity matches NULL or zero.) */
|
* (An absent Ed25519 identity matches NULL or zero.) */
|
||||||
|
Loading…
Reference in New Issue
Block a user