diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-01-05 22:53:32 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-01-05 22:53:32 -0500 |
commit | 31d888c834b135d8f36ceec181f3d1ea7af62267 (patch) | |
tree | a1bbab98107d8a154875083e1b3c63be5b103e30 /src/or/routerparse.c | |
parent | dffc8e359bcfeb00813a3afde6aa2328f6a6a476 (diff) | |
download | tor-31d888c834b135d8f36ceec181f3d1ea7af62267.tar.gz tor-31d888c834b135d8f36ceec181f3d1ea7af62267.zip |
Make the = at the end of ntor-onion-key optional.
Makes bug 7869 more easily fixable if we ever choose to do so.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index c873784c0e..dca4176d4b 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1288,18 +1288,14 @@ router_parse_entry_from_string(const char *s, const char *end, tok->key = NULL; /* Prevent free */ if ((tok = find_opt_by_keyword(tokens, K_ONION_KEY_NTOR))) { - uint8_t k[CURVE25519_PUBKEY_LEN+32]; - int r; + curve25519_public_key_t k; tor_assert(tok->n_args >= 1); - r = base64_decode((char*)k, sizeof(k), tok->args[0], strlen(tok->args[0])); - if (r != CURVE25519_PUBKEY_LEN) { - log_warn(LD_DIR, "Bogus onion-key-ntor in routerinfo"); + if (curve25519_public_from_base64(&k, tok->args[0]) < 0) { + log_warn(LD_DIR, "Bogus ntor-onion-key in routerinfo"); goto err; } router->onion_curve25519_pkey = - tor_malloc(sizeof(curve25519_public_key_t)); - memcpy(router->onion_curve25519_pkey->public_key, - k, CURVE25519_PUBKEY_LEN); + tor_memdup(&k, sizeof(curve25519_public_key_t)); } tok = find_by_keyword(tokens, K_SIGNING_KEY); @@ -4264,19 +4260,14 @@ microdescs_parse_from_string(const char *s, const char *eos, tok->key = NULL; if ((tok = find_opt_by_keyword(tokens, K_ONION_KEY_NTOR))) { - uint8_t k[CURVE25519_PUBKEY_LEN+32]; - int r; + curve25519_public_key_t k; tor_assert(tok->n_args >= 1); - r = base64_decode((char*)k, sizeof(k), - tok->args[0], strlen(tok->args[0])); - if (r != CURVE25519_PUBKEY_LEN) { - log_warn(LD_DIR, "Bogus onion-key-ntor in microdesc"); + if (curve25519_public_from_base64(&k, tok->args[0]) < 0) { + log_warn(LD_DIR, "Bogus ntor-onion-key in microdesc"); goto next; } md->onion_curve25519_pkey = - tor_malloc(sizeof(curve25519_public_key_t)); - memcpy(md->onion_curve25519_pkey->public_key, - k, CURVE25519_PUBKEY_LEN); + tor_memdup(&k, sizeof(curve25519_public_key_t)); } { |