[or-cvs] document an openssl gotcha

Roger Dingledine arma at seul.org
Wed Dec 17 05:31:56 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	crypto.c crypto.h 
Log Message:
document an openssl gotcha


Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- crypto.c	16 Dec 2003 08:13:26 -0000	1.49
+++ crypto.c	17 Dec 2003 05:31:52 -0000	1.50
@@ -997,7 +997,7 @@
     goto error;
   secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1);
   secret_len = DH_compute_key(secret_tmp, pubkey_bn, dh->dh);
-  assert(secret_len == crypto_dh_get_bytes(dh));
+  /* sometimes secret_len might be less than 128, e.g., 127. that's ok. */
   for (i = 0; i < secret_bytes_out; i += 20) {
     secret_tmp[secret_len] = (unsigned char) i/20;
     if (crypto_SHA_digest(secret_tmp, secret_len+1, hash))
@@ -1012,8 +1012,7 @@
  done:
   if (pubkey_bn)
     BN_free(pubkey_bn);
-  if (secret_tmp)
-    free(secret_tmp);
+  tor_free(secret_tmp);
   return secret_len;
 }
 void crypto_dh_free(crypto_dh_env_t *dh)

Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- crypto.h	16 Dec 2003 08:13:26 -0000	1.26
+++ crypto.h	17 Dec 2003 05:31:52 -0000	1.27
@@ -99,7 +99,7 @@
 
 /* SHA-1 */
 int crypto_SHA_digest(const unsigned char *m, int len, unsigned char *digest);
-crypto_digest_env_t *crypto_digest_new_env(int type);
+crypto_digest_env_t *crypto_new_digest_env(int type);
 void crypto_free_digest_env(crypto_digest_env_t *digest);
 void crypto_digest_add_bytes(crypto_digest_env_t *digest, const char *data,
                              size_t len);



More information about the tor-commits mailing list