diff options
author | George Kadianakis <desnacked@riseup.net> | 2013-06-04 20:00:28 +0300 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-08-15 12:03:37 -0400 |
commit | 33c3e60a376291faed073dcfb6c9b8a0098572a0 (patch) | |
tree | 85c817c417797c276b1a5849493773c5a5285408 /src/test/test_extorport.c | |
parent | 13784d47536704e8b2fea918ffe4f9bf8c019f88 (diff) | |
download | tor-33c3e60a376291faed073dcfb6c9b8a0098572a0.tar.gz tor-33c3e60a376291faed073dcfb6c9b8a0098572a0.zip |
Implement and use a generic auth. cookie initialization function.
Use the generic function for both the ControlPort cookie and the
ExtORPort cookie.
Also, place the global cookie variables in the heap so that we can
pass them around more easily as pointers.
Also also, fix the unit tests that broke by this change.
Conflicts:
src/or/config.h
src/or/ext_orport.c
Diffstat (limited to 'src/test/test_extorport.c')
-rw-r--r-- | src/test/test_extorport.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c index 1d97557e41..e76808fa9c 100644 --- a/src/test/test_extorport.c +++ b/src/test/test_extorport.c @@ -167,7 +167,8 @@ test_ext_or_init_auth(void *arg) /* Shouldn't be initialized already, or our tests will be a bit * meaningless */ - test_assert(tor_mem_is_zero(ext_or_auth_cookie, 32)); + ext_or_auth_cookie = tor_malloc_zero(32); + test_assert(tor_mem_is_zero((char*)ext_or_auth_cookie, 32)); /* Now make sure we use a temporary file */ fn = get_fname("ext_cookie_file"); @@ -184,7 +185,7 @@ test_ext_or_init_auth(void *arg) test_memeq(cp, "! Extended ORPort Auth Cookie !\x0a", 32); test_memeq(cp+32, ext_or_auth_cookie, 32); memcpy(cookie0, ext_or_auth_cookie, 32); - test_assert(!tor_mem_is_zero(ext_or_auth_cookie, 32)); + test_assert(!tor_mem_is_zero((char*)ext_or_auth_cookie, 32)); /* Operation should be idempotent. */ tt_int_op(0, ==, init_ext_or_cookie_authentication(1)); @@ -217,6 +218,7 @@ test_ext_or_cookie_auth(void *arg) tt_int_op(strlen(client_hash_input), ==, 46+32+32); tt_int_op(strlen(server_hash_input), ==, 46+32+32); + ext_or_auth_cookie = tor_malloc_zero(32); memcpy(ext_or_auth_cookie, "s beside you? When I count, ther", 32); ext_or_auth_cookie_is_set = 1; @@ -252,9 +254,9 @@ test_ext_or_cookie_auth(void *arg) memcpy(server_hash_input+46+32, reply+32, 32); memcpy(client_hash_input+46+32, reply+32, 32); /* Check the HMACs are correct... */ - crypto_hmac_sha256(hmac1, ext_or_auth_cookie, 32, server_hash_input, + crypto_hmac_sha256(hmac1, (char*)ext_or_auth_cookie, 32, server_hash_input, 46+32+32); - crypto_hmac_sha256(hmac2, ext_or_auth_cookie, 32, client_hash_input, + crypto_hmac_sha256(hmac2, (char*)ext_or_auth_cookie, 32, client_hash_input, 46+32+32); test_memeq(hmac1, reply, 32); test_memeq(hmac2, client_hash, 32); @@ -269,9 +271,9 @@ test_ext_or_cookie_auth(void *arg) memcpy(server_hash_input+46+32, reply2+32, 32); memcpy(client_hash_input+46+32, reply2+32, 32); /* Check the HMACs are correct... */ - crypto_hmac_sha256(hmac1, ext_or_auth_cookie, 32, server_hash_input, + crypto_hmac_sha256(hmac1, (char*)ext_or_auth_cookie, 32, server_hash_input, 46+32+32); - crypto_hmac_sha256(hmac2, ext_or_auth_cookie, 32, client_hash_input, + crypto_hmac_sha256(hmac2, (char*)ext_or_auth_cookie, 32, client_hash_input, 46+32+32); test_memeq(hmac1, reply2, 32); test_memeq(hmac2, client_hash2, 32); @@ -304,6 +306,7 @@ test_ext_or_cookie_auth_testvec(void *arg) const char client_nonce[] = "But when I look ahead up the whi"; (void)arg; + ext_or_auth_cookie = tor_malloc_zero(32); memcpy(ext_or_auth_cookie, "Gliding wrapt in a brown mantle," , 32); ext_or_auth_cookie_is_set = 1; @@ -393,6 +396,7 @@ test_ext_or_handshake(void *arg) MOCK(connection_write_to_buf_impl_, connection_write_to_buf_impl_replacement); /* Use same authenticators as for test_ext_or_cookie_auth_testvec */ + ext_or_auth_cookie = tor_malloc_zero(32); memcpy(ext_or_auth_cookie, "Gliding wrapt in a brown mantle," , 32); ext_or_auth_cookie_is_set = 1; |