23 static token_rule_t networkstatus_detached_signature_token_table[] = {
25 T(
"additional-digest", K_ADDITIONAL_DIGEST,
GE(3),
NO_OBJ ),
29 T(
"additional-signature", K_ADDITIONAL_SIGNATURE,
GE(4),
NEED_OBJ ),
30 T1N(
"directory-signature", K_DIRECTORY_SIGNATURE,
GE(2),
NEED_OBJ ),
44 strmap_set(sigs->
digests, flavor_name, d);
54 const char *flavor_name)
86 networkstatus_detached_signature_token_table, 0)) {
87 log_warn(
LD_DIR,
"Error tokenizing detached networkstatus signatures");
96 const char *hexdigest;
97 size_t expected_length, digest_length;
101 if (tok->
tp == K_CONSENSUS_DIGEST) {
105 hexdigest = tok->
args[0];
106 }
else if (tok->
tp == K_ADDITIONAL_DIGEST) {
109 log_warn(
LD_DIR,
"Unrecognized algorithm name %s", tok->
args[0]);
113 flavor = tok->
args[0];
114 algname = tok->
args[1];
115 hexdigest = tok->
args[2];
121 expected_length = digest_length * 2;
123 if (strlen(hexdigest) != expected_length) {
124 log_warn(
LD_DIR,
"Wrong length on consensus-digest in detached "
125 "networkstatus signatures");
128 digests = detached_get_digests(sigs, flavor);
131 log_warn(
LD_DIR,
"Multiple digests for %s with %s on detached "
132 "signatures document", flavor, algname);
136 hexdigest, strlen(hexdigest)) != (
int) digest_length) {
137 log_warn(
LD_DIR,
"Bad encoding on consensus-digest in detached "
138 "networkstatus signatures");
141 } SMARTLIST_FOREACH_END(_tok);
143 tok = find_by_keyword(tokens, K_VALID_AFTER);
145 log_warn(
LD_DIR,
"Bad valid-after in detached networkstatus signatures");
149 tok = find_by_keyword(tokens, K_FRESH_UNTIL);
151 log_warn(
LD_DIR,
"Bad fresh-until in detached networkstatus signatures");
155 tok = find_by_keyword(tokens, K_VALID_UNTIL);
157 log_warn(
LD_DIR,
"Bad valid-until in detached networkstatus signatures");
162 const char *id_hexdigest;
163 const char *sk_hexdigest;
175 if (tok->
tp == K_DIRECTORY_SIGNATURE) {
179 id_hexdigest = tok->
args[0];
180 sk_hexdigest = tok->
args[1];
181 }
else if (tok->
tp == K_ADDITIONAL_SIGNATURE) {
183 flavor = tok->
args[0];
184 algname = tok->
args[1];
185 id_hexdigest = tok->
args[2];
186 sk_hexdigest = tok->
args[3];
194 log_warn(
LD_DIR,
"Unrecognized algorithm name %s", algname);
203 log_warn(
LD_DIR,
"Bad object type or length on directory-signature");
210 log_warn(
LD_DIR,
"Error decoding declared identity %s in "
211 "network-status vote.",
escaped(id_hexdigest));
217 log_warn(
LD_DIR,
"Error decoding declared signing key digest %s in "
218 "network-status vote.",
escaped(sk_hexdigest));
222 siglist = detached_get_signatures(sigs, flavor);
225 if (dsig->alg == alg &&
232 log_warn(
LD_DIR,
"Two signatures with identical keys and algorithm "
249 } SMARTLIST_FOREACH_END(_tok);
253 ns_detached_signatures_free(sigs);
257 smartlist_free(tokens);
259 DUMP_AREA(area,
"detached signatures");
274 document_signature_free(sig));
275 smartlist_free(sigs);
276 } STRMAP_FOREACH_END;
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
size_t crypto_digest_algorithm_get_length(digest_algorithm_t alg)
int crypto_digest_algorithm_parse_name(const char *name)
int tor_memeq(const void *a, const void *b, size_t sz)
Authority signature structure.
Code to parse and validate detached-signature objects.
ns_detached_signatures_t * networkstatus_parse_detached_signatures(const char *s, const char *eos)
void ns_detached_signatures_free_(ns_detached_signatures_t *s)
const char * escaped(const char *s)
void tor_free_(void *mem)
memarea_t * memarea_new(void)
#define memarea_drop_all(area)
Header file for networkstatus.c.
Detached consensus signatures structure.
Master header file for Tor-specific functionality.
void token_clear(directory_token_t *tok)
int tokenize_string(memarea_t *area, const char *start, const char *end, smartlist_t *out, const token_rule_t *table, int flags)
Header file for parsecommon.c.
#define T1_START(s, t, a, o)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
char d[N_COMMON_DIGEST_ALGORITHMS][DIGEST256_LEN]
char identity_digest[DIGEST_LEN]
char signing_key_digest[DIGEST_LEN]
int parse_iso_time(const char *cp, time_t *t)
Header file for unparseable.c.
int fast_mem_is_zero(const char *mem, size_t len)