summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 16f5afef3e..275a8988f7 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -631,6 +631,23 @@ crypto_pk_dup_key(crypto_pk_env_t *env)
return env;
}
+/** Make a real honest-to-goodness copy of <b>env</b>, and return it. */
+crypto_pk_env_t *
+crypto_pk_copy_full(crypto_pk_env_t *env)
+{
+ RSA *new_key;
+ tor_assert(env);
+ tor_assert(env->key);
+
+ if (PRIVATE_KEY_OK(env)) {
+ new_key = RSAPrivateKey_dup(env->key);
+ } else {
+ new_key = RSAPublicKey_dup(env->key);
+ }
+
+ return _crypto_new_pk_env_rsa(new_key);
+}
+
/** Encrypt <b>fromlen</b> bytes from <b>from</b> with the public key
* in <b>env</b>, using the padding method <b>padding</b>. On success,
* write the result to <b>to</b>, and return the number of bytes