]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a crypto_dh_dup, for benchmark support
authorNick Mathewson <nickm@torproject.org>
Wed, 28 Nov 2012 20:38:37 +0000 (15:38 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 6 Dec 2012 06:54:09 +0000 (01:54 -0500)
src/common/crypto.c
src/common/crypto.h

index 39f5a4a642386506def435701828b687cbf56f23..37d843396692c0e37a5f5892202fde793e368aa3 100644 (file)
@@ -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
index 4c5fa6ad97d4df0d69f006f650140068521f654b..eb8b1de1630b94e3259b10a72c963309ce6cd142 100644 (file)
@@ -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,