13 #define SIGCOMMON_PRIVATE
28 const char *start_str,
29 const char *end_str,
char end_c,
31 const char **start_out,
const char **end_out)
33 const char *start, *end;
34 start = tor_memstr(s, s_len, start_str);
37 "couldn't find start of hashed material \"%s\"",start_str);
40 if (start != s && *(start-1) !=
'\n') {
42 "first occurrence of \"%s\" is not at the start of a line",
46 end = tor_memstr(start+strlen(start_str),
47 s_len - (start-s) - strlen(start_str), end_str);
50 "couldn't find end of hashed material \"%s\"",end_str);
53 end = memchr(end+strlen(end_str), end_c, s_len - (end-s) - strlen(end_str));
75 const char *start_str,
76 const char *end_str,
char end_c,
79 const char *start=NULL, *end=NULL;
92 const char *start,
size_t len,
95 if (alg == DIGEST_SHA1) {
97 log_warn(
LD_BUG,
"couldn't compute digest");
102 log_warn(
LD_BUG,
"couldn't compute digest");
113 const char *start_str,
114 const char *end_str,
char end_c)
116 const char *start=NULL, *end=NULL;
122 log_warn(
LD_BUG,
"couldn't compute digests");
130 signed_digest_equals, (
const uint8_t *d1,
const uint8_t *d2,
size_t len))
148 const char *doctype))
152 const int check_objtype = ! (flags & CST_NO_CHECK_OBJTYPE);
161 log_warn(
LD_DIR,
"Bad object type on %s signature", doctype);
167 signed_digest = tor_malloc(keysize);
171 log_warn(
LD_DIR,
"Error reading %s: invalid signature.", doctype);
177 if (! signed_digest_equals((
const uint8_t *)digest,
178 (
const uint8_t *)signed_digest, digest_len)) {
179 log_warn(
LD_DIR,
"Error reading %s: signature does not match.", doctype);
int crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len)
int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
int crypto_digest(char *digest, const char *m, size_t len)
size_t crypto_pk_keysize(const crypto_pk_t *env)
int crypto_pk_public_checksig(const crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen)
int tor_memeq(const void *a, const void *b, size_t sz)
#define log_fn(severity, domain, args,...)
Master header file for Tor-specific functionality.
Header file for parsecommon.c.
STATIC int router_compute_hash_final(char *digest, const char *start, size_t len, digest_algorithm_t alg)
int check_signature_token(const char *digest, ssize_t digest_len, directory_token_t *tok, crypto_pk_t *pkey, int flags, const char *doctype)
int router_get_hash_impl_helper(const char *s, size_t s_len, const char *start_str, const char *end_str, char end_c, int log_severity, const char **start_out, const char **end_out)
int router_get_hash_impl(const char *s, size_t s_len, char *digest, const char *start_str, const char *end_str, char end_c, digest_algorithm_t alg)
int router_get_hashes_impl(const char *s, size_t s_len, common_digests_t *digests, const char *start_str, const char *end_str, char end_c)
Header file for sigcommon.c.
#define MOCK_IMPL(rv, funcname, arglist)