diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-06-14 01:30:53 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-06-14 01:30:53 +0000 |
commit | 9182537238b9485f181379b463686d426105ae30 (patch) | |
tree | 51f59c438eb968a822729fcf39010671be8e5ac5 /src/or/test.c | |
parent | 9af577fee35201c93db343f95b125bf068a10113 (diff) | |
download | tor-9182537238b9485f181379b463686d426105ae30.tar tor-9182537238b9485f181379b463686d426105ae30.tar.gz |
Fix the periodic bug that would make handshaking fail.
The culprit: sometimes DH_calculate_key returns less than DH_KEY_LEN bytes;
we needed to check the return value.
svn:r322
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/or/test.c b/src/or/test.c index 65fc8a08e..512e13f12 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -165,6 +165,7 @@ test_crypto_dh() char p2[CRYPTO_DH_SIZE]; char s1[CRYPTO_DH_SIZE]; char s2[CRYPTO_DH_SIZE]; + int s1len, s2len; dh1 = crypto_dh_new(); dh2 = crypto_dh_new(); @@ -180,10 +181,12 @@ test_crypto_dh() test_memneq(p1, p2, CRYPTO_DH_SIZE); memset(s1, 0, CRYPTO_DH_SIZE); - memset(s2, 0, CRYPTO_DH_SIZE); - test_assert(! crypto_dh_compute_secret(dh1, p2, CRYPTO_DH_SIZE, s1)); - test_assert(! crypto_dh_compute_secret(dh2, p1, CRYPTO_DH_SIZE, s2)); - test_memeq(s1, s2, CRYPTO_DH_SIZE); + memset(s2, 0xFF, CRYPTO_DH_SIZE); + s1len = crypto_dh_compute_secret(dh1, p2, CRYPTO_DH_SIZE, s1); + s2len = crypto_dh_compute_secret(dh2, p1, CRYPTO_DH_SIZE, s2); + test_assert(s1len > 0); + test_eq(s1len, s2len); + test_memeq(s1, s2, s1len); crypto_dh_free(dh1); crypto_dh_free(dh2); @@ -597,22 +600,18 @@ main(int c, char**v) { #ifndef DEBUG_ONION_SKINS puts("========================== Buffers ========================="); test_buffers(); - puts("========================== Crypto =========================="); + puts("\n========================== Crypto =========================="); test_crypto(); test_crypto_dh(); puts("\n========================= Util ============================"); test_util(); puts("\n========================= Onion Skins ====================="); #endif -#ifdef DEBUG_ONION_SKINS crypto_seed_rng(); while(1) { -#endif test_onion_handshake(); -#ifdef DEBUG_ONION_SKINS fflush(NULL); } -#endif puts("\n========================= Directory Formats ==============="); test_dir_format(); puts(""); |