From 07f0a2b964eedd1ced201f2d1d82ec0089fac371 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 24 Jun 2024 14:04:04 -0400 Subject: Make onion-key body optional in microdescs Also, stop storing onion keys in microdesc_t. (In prop350, for microdescs, we are making the body optional; the "onion-key" entry is still mandatory, so that we can tell where microdescs begin.) --- src/feature/dirparse/microdesc_parse.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/feature/dirparse/microdesc_parse.c') diff --git a/src/feature/dirparse/microdesc_parse.c b/src/feature/dirparse/microdesc_parse.c index beb38bda30..eef52f14f3 100644 --- a/src/feature/dirparse/microdesc_parse.c +++ b/src/feature/dirparse/microdesc_parse.c @@ -30,7 +30,7 @@ /** List of tokens recognized in microdescriptors */ // clang-format off static token_rule_t microdesc_token_table[] = { - T1_START("onion-key", K_ONION_KEY, NO_ARGS, NEED_KEY_1024), + T1_START("onion-key", K_ONION_KEY, NO_ARGS, OPT_KEY_1024), T1("ntor-onion-key", K_ONION_KEY_NTOR, GE(1), NO_OBJ ), T0N("id", K_ID, GE(2), NO_OBJ ), T0N("a", K_A, GE(1), NO_OBJ ), @@ -200,14 +200,11 @@ microdesc_parse_fields(microdesc_t *md, } tok = find_by_keyword(tokens, K_ONION_KEY); - if (!crypto_pk_public_exponent_ok(tok->key)) { + if (tok && tok->key && !crypto_pk_public_exponent_ok(tok->key)) { log_warn(LD_DIR, "Relay's onion key had invalid exponent."); goto err; } - md->onion_pkey = tor_memdup(tok->object_body, tok->object_size); - md->onion_pkey_len = tok->object_size; - crypto_pk_free(tok->key); if ((tok = find_opt_by_keyword(tokens, K_ONION_KEY_NTOR))) { curve25519_public_key_t k; -- cgit v1.2.3-54-g00ecf