diff options
author | Nick Mathewson <nickm@torproject.org> | 2024-06-24 14:40:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2024-06-26 11:42:36 -0400 |
commit | 6c3dd447623e2d203cf54655af6989774cd2506d (patch) | |
tree | fc9150253c7c1602fae7af62232fd59f8bf0aef4 /src | |
parent | 4cdf56a17376a09612d741054efd11a3016d578c (diff) | |
download | tor-6c3dd447623e2d203cf54655af6989774cd2506d.tar.gz tor-6c3dd447623e2d203cf54655af6989774cd2506d.zip |
routerparse: Simplify checking for now-mandatory elements
All of these elements are now mandatory, so we can now simplify
our logic for making sure that they are all present or all not-present.
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/dirparse/routerparse.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/feature/dirparse/routerparse.c b/src/feature/dirparse/routerparse.c index 47f6803fcd..b3653a79e7 100644 --- a/src/feature/dirparse/routerparse.c +++ b/src/feature/dirparse/routerparse.c @@ -627,24 +627,16 @@ router_parse_entry_from_string(const char *s, const char *end, { directory_token_t *ed_sig_tok, *ed_cert_tok, *cc_tap_tok, *cc_ntor_tok, *master_key_tok; - ed_sig_tok = find_opt_by_keyword(tokens, K_ROUTER_SIG_ED25519); - ed_cert_tok = find_opt_by_keyword(tokens, K_IDENTITY_ED25519); - master_key_tok = find_opt_by_keyword(tokens, K_MASTER_KEY_ED25519); + ed_sig_tok = find_by_keyword(tokens, K_ROUTER_SIG_ED25519); + ed_cert_tok = find_by_keyword(tokens, K_IDENTITY_ED25519); + master_key_tok = find_by_keyword(tokens, K_MASTER_KEY_ED25519); cc_tap_tok = find_opt_by_keyword(tokens, K_ONION_KEY_CROSSCERT); - cc_ntor_tok = find_opt_by_keyword(tokens, K_NTOR_ONION_KEY_CROSSCERT); - int n_ed_toks = !!ed_sig_tok + !!ed_cert_tok + - !!cc_tap_tok + !!cc_ntor_tok; - if ((n_ed_toks != 0 && n_ed_toks != 4) || - (n_ed_toks == 4 && !router->onion_curve25519_pkey)) { - log_warn(LD_DIR, "Router descriptor with only partial ed25519/" - "cross-certification support"); - goto err; - } - if (master_key_tok && !ed_sig_tok) { - log_warn(LD_DIR, "Router descriptor has ed25519 master key but no " - "certificate"); + cc_ntor_tok = find_by_keyword(tokens, K_NTOR_ONION_KEY_CROSSCERT); + + IF_BUG_ONCE(! (ed_sig_tok && ed_cert_tok&& cc_ntor_tok &&master_key_tok)) { goto err; } + if (ed_sig_tok) { tor_assert(ed_cert_tok && cc_tap_tok && cc_ntor_tok); const int ed_cert_token_pos = smartlist_pos(tokens, ed_cert_tok); |