[tor-commits] [tor/master] Add a crypto_dh_dup, for benchmark support
nickm at torproject.org
nickm at torproject.org
Thu Jan 3 16:52:57 UTC 2013
commit 3c3084e1656888d43be3b92169734a6195ec6d75
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed Nov 28 15:38:37 2012 -0500
Add a crypto_dh_dup, for benchmark support
---
src/common/crypto.c | 10 ++++++++++
src/common/crypto.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 39f5a4a..37d8433 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2036,6 +2036,16 @@ crypto_dh_new(int dh_type)
return NULL;
}
+/** Return a copy of <b>dh</b>, sharing its internal state. */
+crypto_dh_t *
+crypto_dh_dup(const crypto_dh_t *dh)
+{
+ crypto_dh_t *dh_new = tor_malloc_zero(sizeof(crypto_dh_t));
+ dh_new->dh = dh->dh;
+ DH_up_ref(dh->dh);
+ return dh_new;
+}
+
/** Return the length of the DH key in <b>dh</b>, in bytes.
*/
int
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 4c5fa6a..eb8b1de 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -230,6 +230,7 @@ void crypto_hmac_sha256(char *hmac_out,
#define DH_TYPE_REND 2
#define DH_TYPE_TLS 3
crypto_dh_t *crypto_dh_new(int dh_type);
+crypto_dh_t *crypto_dh_dup(const crypto_dh_t *dh);
int crypto_dh_get_bytes(crypto_dh_t *dh);
int crypto_dh_generate_public(crypto_dh_t *dh);
int crypto_dh_get_public(crypto_dh_t *dh, char *pubkey_out,
More information about the tor-commits
mailing list