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/common | |
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/common')
-rw-r--r-- | src/common/crypto.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 24a9590cd6..9551435f68 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -2165,9 +2165,14 @@ crypto_set_tls_dh_prime(void) int r; /* If the space is occupied, free the previous TLS DH prime */ - if (dh_param_p_tls) { + if (BUG(dh_param_p_tls)) { + /* LCOV_EXCL_START + * + * We shouldn't be calling this twice. + */ BN_clear_free(dh_param_p_tls); dh_param_p_tls = NULL; + /* LCOV_EXCL_STOP */ } tls_prime = BN_new(); @@ -2199,8 +2204,8 @@ init_dh_param(void) { BIGNUM *circuit_dh_prime; int r; - if (dh_param_p && dh_param_g) - return; + if (BUG(dh_param_p && dh_param_g)) + return; // LCOV_EXCL_LINE This function isn't supposed to be called twice. circuit_dh_prime = BN_new(); tor_assert(circuit_dh_prime); @@ -2366,8 +2371,8 @@ tor_check_dh_key(int severity, BIGNUM *bn) tor_assert(bn); x = BN_new(); tor_assert(x); - if (!dh_param_p) - init_dh_param(); + if (BUG(!dh_param_p)) + init_dh_param(); //LCOV_EXCL_LINE we already checked whether we did this. BN_set_word(x, 1); if (BN_cmp(bn,x)<=0) { log_fn(severity, LD_CRYPTO, "DH key must be at least 2."); |