summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-12-17 05:31:52 +0000
committerRoger Dingledine <arma@torproject.org>2003-12-17 05:31:52 +0000
commit389eb48690bb8aa6b50efecb735dbf2cb6ef9665 (patch)
tree1e958d6492c99e242f8805a73ae808b57aefb03a
parent21cc01299bfb694790c0602fc9edc16ce9f147a1 (diff)
downloadtor-389eb48690bb8aa6b50efecb735dbf2cb6ef9665.tar.gz
tor-389eb48690bb8aa6b50efecb735dbf2cb6ef9665.zip
document an openssl gotcha
svn:r947
-rw-r--r--src/common/crypto.c5
-rw-r--r--src/common/crypto.h2
2 files changed, 3 insertions, 4 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index a60b17208a..73f015f0ec 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -997,7 +997,7 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
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 @@ int crypto_dh_compute_secret(crypto_dh_env_t *dh,
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)
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 8ba57445be..0ec4e92456 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -99,7 +99,7 @@ crypto_cipher_env_t *crypto_create_init_cipher(int cipher_type, char *key, char
/* 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);