[tor-commits] [tor/maint-0.3.5] Stop re-checking our hardcoded dh parameters on every startup

nickm at torproject.org nickm at torproject.org
Thu Jan 3 14:46:02 UTC 2019


commit b82717b27378a0f8048da9d865a8bd3c6dfedd6f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Dec 14 14:07:00 2018 -0500

    Stop re-checking our hardcoded dh parameters on every startup
    
    Closes ticket 28851.
---
 changes/ticket28851                   | 4 ++++
 src/lib/crypt_ops/crypto_dh_openssl.c | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/changes/ticket28851 b/changes/ticket28851
new file mode 100644
index 000000000..bab031866
--- /dev/null
+++ b/changes/ticket28851
@@ -0,0 +1,4 @@
+  o Minor features (performance):
+    - Stop re-validating our hardcoded Diffie-Hellman parameters on every
+      startup. Doing this wasted time and cycles, especially on low-powered
+      devices. Closes ticket 28851.
diff --git a/src/lib/crypt_ops/crypto_dh_openssl.c b/src/lib/crypt_ops/crypto_dh_openssl.c
index 54946458d..0d9bd513c 100644
--- a/src/lib/crypt_ops/crypto_dh_openssl.c
+++ b/src/lib/crypt_ops/crypto_dh_openssl.c
@@ -45,6 +45,8 @@ static BIGNUM *dh_param_p_tls = NULL;
 /** Shared G parameter for our DH key exchanges. */
 static BIGNUM *dh_param_g = NULL;
 
+/* This function is disabled unless we change the DH parameters. */
+#if 0
 /** Validate a given set of Diffie-Hellman parameters.  This is moderately
  * computationally expensive (milliseconds), so should only be called when
  * the DH parameters change. Returns 0 on success, * -1 on failure.
@@ -98,6 +100,7 @@ crypto_validate_dh_params(const BIGNUM *p, const BIGNUM *g)
     DH_free(dh);
   return ret;
 }
+#endif
 
 /**
  * Helper: convert <b>hex<b> to a bignum, and return it.  Assert that the
@@ -151,8 +154,11 @@ crypto_dh_init_openssl(void)
   dh_param_p = bignum_from_hex(OAKLEY_PRIME_2);
   dh_param_p_tls = bignum_from_hex(TLS_DH_PRIME);
 
+  /* Checks below are disabled unless we change the hardcoded DH parameters. */
+#if 0
   tor_assert(0 == crypto_validate_dh_params(dh_param_p, dh_param_g));
   tor_assert(0 == crypto_validate_dh_params(dh_param_p_tls, dh_param_g));
+#endif
 }
 
 /** Number of bits to use when choosing the x or y value in a Diffie-Hellman





More information about the tor-commits mailing list