[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Oops. It looks like there *was* an easy way to make openssl...



Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv15473/common

Modified Files:
	crypto.c 
Log Message:
Oops. It looks like there *was* an easy way to make openssl do what we wanted.

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- crypto.c	11 Nov 2005 21:44:38 -0000	1.174
+++ crypto.c	14 Nov 2005 19:18:31 -0000	1.175
@@ -1361,6 +1361,8 @@
   dh_param_g = g;
 }
 
+#define DH_PRIVATE_KEY_BITS 320
+
 /** Allocate and return a new DH object for a key exchange.
  */
 crypto_dh_env_t *
@@ -1382,6 +1384,8 @@
   if (!(res->dh->g = BN_dup(dh_param_g)))
     goto err;
 
+  res->dh->length = DH_PRIVATE_KEY_BITS;
+
   return res;
  err:
   crypto_log_errors(LOG_WARN, "creating DH object");
@@ -1390,8 +1394,6 @@
   return NULL;
 }
 
-#define DH_PRIVATE_KEY_BITS 320
-
 /** Return the length of the DH key in <b>dh</b>, in bytes.
  */
 int
@@ -1407,22 +1409,7 @@
 int
 crypto_dh_generate_public(crypto_dh_env_t *dh)
 {
-  int pk_bits = BN_num_bits(dh->dh->p);
-  if (pk_bits > DH_PRIVATE_KEY_BITS)
-    pk_bits = DH_PRIVATE_KEY_BITS;
  again:
-  if (!dh->dh->priv_key) {
-    dh->dh->priv_key = BN_new();
-    if (!dh->dh->priv_key) {
-      err(LD_MM, "Unable to allocate BN.");
-      return -1;
-    }
-  }
-  /* We generate the key ourselves so that we can get a 2-3x speedup by using
-   * a 320-bit x instead of a 1024-bit x. */
-  if (!BN_rand(dh->dh->priv_key, pk_bits, 0, 0)) {
-    crypto_log_errors(LOG_WARN, "Generating DH private key");
-  }
   if (!DH_generate_key(dh->dh)) {
     crypto_log_errors(LOG_WARN, "generating DH key");
     return -1;