Tor 0.4.9.0-alpha-dev
Macros | Functions
sigcommon.c File Reference

Shared hashing, signing, and signature-checking code for directory objects. More...

#include "core/or/or.h"
#include "feature/dirparse/parsecommon.h"
#include "feature/dirparse/sigcommon.h"

Go to the source code of this file.

Functions

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)
 
STATIC int router_compute_hash_final (char *digest, const char *start, size_t len, 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)
 
STATIC int signed_digest_equals (const uint8_t *d1, const uint8_t *d2, size_t len)
 
int check_signature_token (const char *digest, ssize_t digest_len, directory_token_t *tok, crypto_pk_t *pkey, int flags, const char *doctype)
 

Detailed Description

Shared hashing, signing, and signature-checking code for directory objects.

Definition in file sigcommon.c.

Macro Definition Documentation

◆ SIGCOMMON_PRIVATE

#define SIGCOMMON_PRIVATE

Definition at line 13 of file sigcommon.c.

Function Documentation

◆ check_signature_token()

int check_signature_token ( const char *  digest,
ssize_t  digest_len,
directory_token_t tok,
crypto_pk_t pkey,
int  flags,
const char *  doctype 
)

Check whether the object body of the token in tok has a good signature for digest using key pkey. If CST_NO_CHECK_OBJTYPE is set, do not check the object type of the signature object. Use doctype as the type of the document when generating log messages. Return 0 on success, negative on failure.

Definition at line 148 of file sigcommon.c.

◆ router_compute_hash_final()

STATIC int router_compute_hash_final ( char *  digest,
const char *  start,
size_t  len,
digest_algorithm_t  alg 
)

Compute the digest of the len-byte directory object at start, using alg. Store the result in digest, which must be long enough to hold it.

Definition at line 93 of file sigcommon.c.

Referenced by router_get_hash_impl().

◆ router_get_hash_impl()

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 
)

Compute the digest of the substring of s taken from the first occurrence of start_str through the first instance of c after the first subsequent occurrence of end_str; store the 20-byte or 32-byte result in digest; return 0 on success.

If no such substring exists, return -1.

Definition at line 74 of file sigcommon.c.

Referenced by router_get_extrainfo_hash(), and router_get_router_hash().

◆ router_get_hash_impl_helper()

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 
)

Helper function for router_get_hash_impl: given s, s_len, start_str, end_str, and end_c with the same semantics as in that function, set *start_out (inclusive) and *end_out (exclusive) to the boundaries of the string to be hashed.

Return 0 on success and -1 on failure.

Definition at line 27 of file sigcommon.c.

Referenced by router_get_hash_impl(), router_get_hashes_impl(), and router_get_networkstatus_v3_signed_boundaries().

◆ router_get_hashes_impl()

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 
)

As router_get_hash_impl, but compute all hashes.

Definition at line 112 of file sigcommon.c.

Referenced by router_get_networkstatus_v3_hashes().

◆ signed_digest_equals()

STATIC int signed_digest_equals ( const uint8_t *  d1,
const uint8_t *  d2,
size_t  len 
)

Definition at line 130 of file sigcommon.c.