diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-05-04 09:43:47 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-05-16 08:26:00 -0400 |
commit | 365d0fcc6db6a628c0ff118f2d5b03cebdcd4734 (patch) | |
tree | 62f3cdcdde895f46d1aa068fd9c4f1d856def627 /src/test/test_crypto.c | |
parent | 94b34d1be6f20c967736ba858d6e765fd369c4e8 (diff) | |
download | tor-365d0fcc6db6a628c0ff118f2d5b03cebdcd4734.tar.gz tor-365d0fcc6db6a628c0ff118f2d5b03cebdcd4734.zip |
Cover all our DH code, and/or mark it unreachable.
Diffstat (limited to 'src/test/test_crypto.c')
-rw-r--r-- | src/test/test_crypto.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index dd9a3765f6..e981eac602 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -58,7 +58,6 @@ test_crypto_dh(void *arg) tt_int_op(s1len,OP_EQ, s2len); tt_mem_op(s1,OP_EQ, s2, s1len); - /* test dh_dup; make sure it works the same. */ dh1_dup = crypto_dh_dup(dh1); s1len = crypto_dh_compute_secret(LOG_WARN, dh1_dup, p2, DH_BYTES, s1, 50); @@ -132,6 +131,19 @@ test_crypto_dh(void *arg) tt_int_op(-1, OP_EQ, s1len); } + { + /* provoke an error in the openssl DH_compute_key function; make sure we + * survive. */ + tt_assert(! crypto_dh_get_public(dh1, p1, DH_BYTES)); + + crypto_dh_free(dh2); + dh2= crypto_dh_new(DH_TYPE_CIRCUIT); /* no private key set */ + s1len = crypto_dh_compute_secret(LOG_WARN, dh2, + p1, DH_BYTES, + s1, 50); + tt_int_op(s1len, OP_EQ, -1); + } + done: crypto_dh_free(dh1); crypto_dh_free(dh2); |