aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_router.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-08-23 14:05:42 -0400
committerNick Mathewson <nickm@torproject.org>2018-08-29 15:01:38 -0400
commit2f6bc74914d60b62b8e61904aae16c84c2b1181d (patch)
tree0bd9202dfefab689c9a3b7657ba197ae5a35ccdf /src/test/test_router.c
parentac44e70ffc047941d196596dd651019c054b7faf (diff)
downloadtor-2f6bc74914d60b62b8e61904aae16c84c2b1181d.tar.gz
tor-2f6bc74914d60b62b8e61904aae16c84c2b1181d.zip
router: Keep RSA onion public key in ASN.1 format
The OpenSSL "RSA" object is currently 408 bytes compares to the ASN.1 encoding which is 140 for a 1024 RSA key. We save 268 bytes per descriptor (routerinfo_t) *and* microdescriptor (microdesc_t). Scaling this to 6000 relays, and considering client usually only have microdescriptors, we save 1.608 MB of RAM which is considerable for mobile client. This commit makes it that we keep the RSA onion public key (used for TAP handshake) in ASN.1 format instead of an OpenSSL RSA object. Changes is done in both routerinfo_t and microdesc_t. Closes #27246 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_router.c')
-rw-r--r--src/test/test_router.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/test/test_router.c b/src/test/test_router.c
index c6a2452c8c..613ec04021 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -49,7 +49,8 @@ NS(router_get_my_routerinfo)(void)
mock_routerinfo->platform = tor_strdup("unittest");
mock_routerinfo->cache_info.published_on = now;
mock_routerinfo->identity_pkey = crypto_pk_dup_key(ident_key);
- mock_routerinfo->onion_pkey = crypto_pk_dup_key(tap_key);
+ router_set_rsa_onion_pkey(tap_key, &mock_routerinfo->onion_pkey,
+ &mock_routerinfo->onion_pkey_len);
mock_routerinfo->bandwidthrate = 9001;
mock_routerinfo->bandwidthburst = 9002;
}
@@ -89,11 +90,14 @@ test_router_dump_router_to_string_no_bridge_distribution_method(void *arg)
/* Generate our server descriptor and ensure that the substring
* "bridge-distribution-request any" occurs somewhere within it. */
+ crypto_pk_t *onion_pkey = router_get_rsa_onion_pkey(router->onion_pkey,
+ router->onion_pkey_len);
desc = router_dump_router_to_string(router,
router->identity_pkey,
- router->onion_pkey,
+ onion_pkey,
&ntor_keypair,
&signing_keypair);
+ crypto_pk_free(onion_pkey);
tt_ptr_op(desc, !=, NULL);
found = strstr(desc, needle);
tt_ptr_op(found, !=, NULL);