mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Make a bunch of signature/digest-checking functions mockable
This commit is contained in:
+6
-6
@@ -1207,12 +1207,12 @@ make_tap_onion_key_crosscert(const crypto_pk_t *onion_key,
|
||||
|
||||
/** Check whether an RSA-TAP cross-certification is correct. Return 0 if it
|
||||
* is, -1 if it isn't. */
|
||||
int
|
||||
check_tap_onion_key_crosscert(const uint8_t *crosscert,
|
||||
int crosscert_len,
|
||||
const crypto_pk_t *onion_pkey,
|
||||
const ed25519_public_key_t *master_id_pkey,
|
||||
const uint8_t *rsa_id_digest)
|
||||
MOCK_IMPL(int,
|
||||
check_tap_onion_key_crosscert,(const uint8_t *crosscert,
|
||||
int crosscert_len,
|
||||
const crypto_pk_t *onion_pkey,
|
||||
const ed25519_public_key_t *master_id_pkey,
|
||||
const uint8_t *rsa_id_digest))
|
||||
{
|
||||
uint8_t *cc = tor_malloc(crypto_pk_keysize(onion_pkey));
|
||||
int cc_len =
|
||||
|
||||
+2
-2
@@ -57,11 +57,11 @@ uint8_t *make_tap_onion_key_crosscert(const crypto_pk_t *onion_key,
|
||||
const crypto_pk_t *rsa_id_key,
|
||||
int *len_out);
|
||||
|
||||
int check_tap_onion_key_crosscert(const uint8_t *crosscert,
|
||||
MOCK_DECL(int, check_tap_onion_key_crosscert,(const uint8_t *crosscert,
|
||||
int crosscert_len,
|
||||
const crypto_pk_t *onion_pkey,
|
||||
const ed25519_public_key_t *master_id_pkey,
|
||||
const uint8_t *rsa_id_digest);
|
||||
const uint8_t *rsa_id_digest));
|
||||
|
||||
int load_ed_keys(const or_options_t *options, time_t now);
|
||||
int should_make_new_ed_keys(const or_options_t *options, const time_t now);
|
||||
|
||||
+15
-4
@@ -863,8 +863,8 @@ dump_desc_populate_fifo_from_directory(const char *dirname)
|
||||
* type *<b>type</b> to file $DATADIR/unparseable-desc. Do not write more
|
||||
* than one descriptor to disk per minute. If there is already such a
|
||||
* file in the data directory, overwrite it. */
|
||||
STATIC void
|
||||
dump_desc(const char *desc, const char *type)
|
||||
MOCK_IMPL(STATIC void,
|
||||
dump_desc,(const char *desc, const char *type))
|
||||
{
|
||||
tor_assert(desc);
|
||||
tor_assert(type);
|
||||
@@ -4508,13 +4508,24 @@ router_get_hash_impl(const char *s, size_t s_len, char *digest,
|
||||
&start,&end)<0)
|
||||
return -1;
|
||||
|
||||
return router_compute_hash_final(digest, start, end-start, alg);
|
||||
}
|
||||
|
||||
/** Compute the digest of the <b>len</b>-byte directory object at
|
||||
* <b>start</b>, using <b>alg</b>. Store the result in <b>digest</b>, which
|
||||
* must be long enough to hold it. */
|
||||
MOCK_IMPL(STATIC int,
|
||||
router_compute_hash_final,(char *digest,
|
||||
const char *start, size_t len,
|
||||
digest_algorithm_t alg))
|
||||
{
|
||||
if (alg == DIGEST_SHA1) {
|
||||
if (crypto_digest(digest, start, end-start) < 0) {
|
||||
if (crypto_digest(digest, start, len) < 0) {
|
||||
log_warn(LD_BUG,"couldn't compute digest");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (crypto_digest256(digest, start, end-start, alg) < 0) {
|
||||
if (crypto_digest256(digest, start, len, alg) < 0) {
|
||||
log_warn(LD_BUG,"couldn't compute digest");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
|
||||
MOCK_DECL(STATIC dumped_desc_t *, dump_desc_populate_one_file,
|
||||
(const char *dirname, const char *f));
|
||||
STATIC void dump_desc_populate_fifo_from_directory(const char *dirname);
|
||||
STATIC void dump_desc(const char *desc, const char *type);
|
||||
STATIC void dump_desc_fifo_cleanup(void);
|
||||
struct memarea_t;
|
||||
STATIC routerstatus_t *routerstatus_parse_entry_from_string(
|
||||
@@ -120,6 +119,10 @@ STATIC routerstatus_t *routerstatus_parse_entry_from_string(
|
||||
vote_routerstatus_t *vote_rs,
|
||||
int consensus_method,
|
||||
consensus_flavor_t flav);
|
||||
MOCK_DECL(STATIC void,dump_desc,(const char *desc, const char *type));
|
||||
MOCK_DECL(STATIC int, router_compute_hash_final,(char *digest,
|
||||
const char *start, size_t len,
|
||||
digest_algorithm_t alg));
|
||||
#endif
|
||||
|
||||
#define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
|
||||
|
||||
Reference in New Issue
Block a user