summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-19 16:28:10 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-19 16:28:10 +0000
commit106e01db3de223ad2ff26254915792b40420362a (patch)
treed8fb4dbb03fbc958175d954603dede89e71d11ff /src/or
parentfb295ba4dde82922ce50475b165b3732e3a2042f (diff)
downloadtor-106e01db3de223ad2ff26254915792b40420362a.tar.gz
tor-106e01db3de223ad2ff26254915792b40420362a.zip
r15956@catbus: nickm | 2007-10-19 11:18:14 -0400
Encode address in certificates. Also, make it possible to create certs reusing an old key. svn:r12046
Diffstat (limited to 'src/or')
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/routerparse.c18
2 files changed, 17 insertions, 3 deletions
diff --git a/src/or/or.h b/src/or/or.h
index afee5ce8d9..971732c61a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1475,6 +1475,8 @@ typedef struct authority_cert_t {
crypto_pk_env_t *signing_key;
char signing_key_digest[DIGEST_LEN];
time_t expires;
+ uint32_t addr;
+ uint16_t dir_port;
} authority_cert_t;
/** Bitfield enum type listing types of directory authority/directory
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 2b5c298826..73200dcfe4 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -63,6 +63,7 @@ typedef enum {
K_DIR_KEY_PUBLISHED,
K_DIR_KEY_EXPIRES,
K_DIR_KEY_CERTIFICATION,
+ K_DIR_ADDRESS,
K_VOTE_STATUS,
K_VALID_AFTER,
@@ -280,8 +281,6 @@ static token_rule_t dir_token_table[] = {
END_OF_TABLE
};
-/** List of tokens allowable in the footer of v1/v2 directory/networkstatus
- * footers. */
#define CERTIFICATE_MEMBERS \
T1("dir-key-certificate-version", K_DIR_KEY_CERTIFICATE_VERSION, \
GE(1), NO_OBJ ), \
@@ -290,7 +289,8 @@ static token_rule_t dir_token_table[] = {
T1("dir-key-expires", K_DIR_KEY_EXPIRES, CONCAT_ARGS, NO_OBJ), \
T1("dir-signing-key", K_DIR_SIGNING_KEY, NO_ARGS, NEED_KEY ),\
T1("dir-key-certification", K_DIR_KEY_CERTIFICATION, \
- NO_ARGS, NEED_OBJ),
+ NO_ARGS, NEED_OBJ), \
+ T01("dir-address", K_DIR_ADDRESS, GE(1), NO_OBJ),
static token_rule_t dir_key_certificate_table[] = {
CERTIFICATE_MEMBERS
@@ -346,6 +346,8 @@ static token_rule_t networkstatus_consensus_token_table[] = {
END_OF_TABLE
};
+/** List of tokens allowable in the footer of v1/v2 directory/networkstatus
+ * footers. */
static token_rule_t networkstatus_vote_footer_token_table[] = {
T( "directory-signature", K_DIRECTORY_SIGNATURE, GE(2), NEED_OBJ ),
END_OF_TABLE
@@ -1438,6 +1440,16 @@ authority_cert_parse_from_string(const char *s, const char **end_of_string)
goto err;
}
+ tok = find_first_by_keyword(tokens, K_DIR_ADDRESS);
+ if (tok) {
+ tor_assert(tok->n_args);
+ if (parse_addr_port(LOG_WARN, tok->args[0], NULL, &cert->addr,
+ &cert->dir_port)<0) {
+ log_warn(LD_DIR, "Couldn't parse dir-address in certificate");
+ goto err;
+ }
+ }
+
tok = find_first_by_keyword(tokens, K_DIR_KEY_PUBLISHED);
tor_assert(tok);
if (parse_iso_time(tok->args[0], &cert->cache_info.published_on) < 0) {