diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/crypto.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 1a1dad616c..06b6aa4b51 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -779,14 +779,25 @@ crypto_pk_env_t * crypto_pk_copy_full(crypto_pk_env_t *env) { RSA *new_key; + int privatekey = 0; tor_assert(env); tor_assert(env->key); if (PRIVATE_KEY_OK(env)) { new_key = RSAPrivateKey_dup(env->key); + privatekey = 1; } else { new_key = RSAPublicKey_dup(env->key); } + if (!new_key) { + log_err(LD_CRYPTO, "Unable to duplicate a %s key: openssl failed.", + privatekey?"private":"public"); + crypto_log_errors(LOG_ERR, + privatekey ? "Duplicating a private key" : + "Duplicating a public key"); + tor_fragile_assert(); + return NULL; + } return _crypto_new_pk_env_rsa(new_key); } |