summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-10-08 11:33:59 -0400
committerNick Mathewson <nickm@torproject.org>2015-05-28 10:41:49 -0400
commit24b720a984cc6c05ebc51d0c699a36119c518ee4 (patch)
tree26c12564c8e378fd059de9eabf96dd18d050fe01 /src/or/routerparse.c
parent006b7ce5ff2a90a517e2842fcdd716ed60a90f14 (diff)
downloadtor-24b720a984cc6c05ebc51d0c699a36119c518ee4.tar.gz
tor-24b720a984cc6c05ebc51d0c699a36119c518ee4.zip
Include ed25519 keys in microdescriptors.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 98104f4c08..e1bc295ef9 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -72,6 +72,7 @@ typedef enum {
K_CLIENT_VERSIONS,
K_SERVER_VERSIONS,
K_OR_ADDRESS,
+ K_ID,
K_P,
K_P6,
K_R,
@@ -503,6 +504,7 @@ static token_rule_t networkstatus_detached_signature_token_table[] = {
static token_rule_t microdesc_token_table[] = {
T1_START("onion-key", K_ONION_KEY, NO_ARGS, NEED_KEY_1024),
T01("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 ),
T01("family", K_FAMILY, ARGS, NO_OBJ ),
T01("p", K_P, CONCAT_ARGS, NO_OBJ ),
@@ -4372,6 +4374,26 @@ microdescs_parse_from_string(const char *s, const char *eos,
tor_memdup(&k, sizeof(curve25519_public_key_t));
}
+ smartlist_t *id_lines = find_all_by_keyword(tokens, K_ID);
+ if (id_lines) {
+ SMARTLIST_FOREACH_BEGIN(id_lines, directory_token_t *, t) {
+ tor_assert(t->n_args >= 2);
+ if (!strcmp(t->args[0], "ed25519")) {
+ if (md->ed25519_identity_pkey) {
+ log_warn(LD_DIR, "Extra ed25519 key in microdesc");
+ goto next;
+ }
+ ed25519_public_key_t k;
+ if (ed25519_public_from_base64(&k, t->args[1])<0) {
+ log_warn(LD_DIR, "Bogus ed25519 key in microdesc");
+ goto next;
+ }
+ md->ed25519_identity_pkey = tor_memdup(&k, sizeof(k));
+ }
+ } SMARTLIST_FOREACH_END(t);
+ smartlist_free(id_lines);
+ }
+
{
smartlist_t *a_lines = find_all_by_keyword(tokens, K_A);
if (a_lines) {