diff options
author | teor <teor@torproject.org> | 2019-02-18 15:24:26 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-02-19 21:44:40 +1000 |
commit | 53b49d1a35d2e7abf1cc7aff15553c23dde0f352 (patch) | |
tree | 5acce2618e716206ab80275b2d7221307b2cf75f /src/feature/relay | |
parent | 7c9450fb073c8b5fb38dab826de7f0356c4828e2 (diff) | |
download | tor-53b49d1a35d2e7abf1cc7aff15553c23dde0f352.tar.gz tor-53b49d1a35d2e7abf1cc7aff15553c23dde0f352.zip |
test_dir: Unit tests for RSA-only router and extrainfo descriptor creation
Tests 29017 and 29018.
Diffstat (limited to 'src/feature/relay')
-rw-r--r-- | src/feature/relay/router.c | 18 | ||||
-rw-r--r-- | src/feature/relay/router.h | 12 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 7e2161ef31..18c8375299 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -196,8 +196,8 @@ set_onion_key(crypto_pk_t *k) /** Return the current onion key. Requires that the onion key has been * loaded or generated. */ -crypto_pk_t * -get_onion_key(void) +MOCK_IMPL(crypto_pk_t *, +get_onion_key,(void)) { tor_assert(onionkey); return onionkey; @@ -376,8 +376,8 @@ assert_identity_keys_ok(void) /** Returns the current server identity key; requires that the key has * been set, and that we are running as a Tor server. */ -crypto_pk_t * -get_server_identity_key(void) +MOCK_IMPL(crypto_pk_t *, +get_server_identity_key,(void)) { tor_assert(server_identitykey); tor_assert(server_mode(get_options())); @@ -1951,8 +1951,8 @@ get_my_declared_family(const or_options_t *options) * * Returns a negative value and sets ri_out to NULL on temporary error. */ -static int -router_build_fresh_unsigned_routerinfo(routerinfo_t **ri_out) +MOCK_IMPL(STATIC int, +router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) { routerinfo_t *ri = NULL; uint32_t addr; @@ -2171,7 +2171,7 @@ router_dump_and_sign_extrainfo_descriptor_body(extrainfo_t *ei) * If ri is NULL, logs a BUG() warning and returns NULL. * Caller is responsible for freeing the generated extrainfo. */ -static extrainfo_t * +STATIC extrainfo_t * router_build_fresh_signed_extrainfo(const routerinfo_t *ri) { int result = -1; @@ -2203,7 +2203,7 @@ router_build_fresh_signed_extrainfo(const routerinfo_t *ri) * * If ei is NULL, logs a BUG() warning and zeroes the relevant fields. */ -static void +STATIC void router_update_routerinfo_from_extrainfo(routerinfo_t *ri, const extrainfo_t *ei) { @@ -2231,7 +2231,7 @@ router_update_routerinfo_from_extrainfo(routerinfo_t *ri, * If ri is NULL, logs a BUG() warning and returns a negative value. * On error, ri->cache_info is not modified. */ -static int +STATIC int router_dump_and_sign_routerinfo_descriptor_body(routerinfo_t *ri) { if (BUG(!ri)) diff --git a/src/feature/relay/router.h b/src/feature/relay/router.h index 497d8d243e..d4ad52c9d9 100644 --- a/src/feature/relay/router.h +++ b/src/feature/relay/router.h @@ -25,10 +25,10 @@ struct ed25519_keypair_t; #define TOR_ROUTERINFO_ERROR_DESC_REBUILDING (-6) #define TOR_ROUTERINFO_ERROR_INTERNAL_BUG (-7) -crypto_pk_t *get_onion_key(void); +MOCK_DECL(crypto_pk_t *,get_onion_key,(void)); time_t get_onion_key_set_at(void); void set_server_identity_key(crypto_pk_t *k); -crypto_pk_t *get_server_identity_key(void); +MOCK_DECL(crypto_pk_t *,get_server_identity_key,(void)); int server_identity_key_is_set(void); void set_client_identity_key(crypto_pk_t *k); crypto_pk_t *get_tlsclient_identity_key(void); @@ -124,6 +124,14 @@ STATIC smartlist_t *get_my_declared_family(const or_options_t *options); extern time_t desc_clean_since; extern const char *desc_dirty_reason; void set_server_identity_key_digest_testing(const uint8_t *digest); + +MOCK_DECL(STATIC int, + router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)); +STATIC extrainfo_t *router_build_fresh_signed_extrainfo( + const routerinfo_t *ri); +STATIC void router_update_routerinfo_from_extrainfo(routerinfo_t *ri, + const extrainfo_t *ei); +STATIC int router_dump_and_sign_routerinfo_descriptor_body(routerinfo_t *ri); #endif #endif |