diff options
Diffstat (limited to 'crypto/evp/p_lib.c')
-rw-r--r-- | crypto/evp/p_lib.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index dba08525a3..14ad90cec5 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -206,7 +206,13 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key) } #ifndef NO_RSA -RSA *EVP_PKEY_get_RSA(EVP_PKEY *pkey) +int EVP_PKEY_rset_RSA(EVP_PKEY *pkey, RSA *key) +{ + CRYPTO_add(&key->references, 1, CRYPTO_LOCK_RSA); + return EVP_PKEY_assign_RSA(pkey, key); +} + +RSA *EVP_PKEY_rget_RSA(EVP_PKEY *pkey) { if(pkey->type != EVP_PKEY_RSA) { EVPerr(EVP_F_EVP_PKEY_GET_RSA, EVP_R_EXPECTING_AN_RSA_KEY); @@ -218,19 +224,32 @@ RSA *EVP_PKEY_get_RSA(EVP_PKEY *pkey) #endif #ifndef NO_DSA -DSA *EVP_PKEY_get_DSA(EVP_PKEY *pkey) +int EVP_PKEY_rset_DSA(EVP_PKEY *pkey, DSA *key) +{ + CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DSA); + return EVP_PKEY_assign_DSA(pkey, key); +} + +DSA *EVP_PKEY_rget_DSA(EVP_PKEY *pkey) { if(pkey->type != EVP_PKEY_DSA) { EVPerr(EVP_F_EVP_PKEY_GET_DSA, EVP_R_EXPECTING_A_DSA_KEY); return NULL; } - CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_DSA); + CRYPTO_add(&pkey->pkey.dsa->references, 1, CRYPTO_LOCK_DSA); return pkey->pkey.dsa; } #endif #ifndef NO_DH -DH *EVP_PKEY_get_DH(EVP_PKEY *pkey) + +int EVP_PKEY_rset_DH(EVP_PKEY *pkey, DH *key) +{ + CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DH); + return EVP_PKEY_assign_DH(pkey, key); +} + +DH *EVP_PKEY_rget_DH(EVP_PKEY *pkey) { if(pkey->type != EVP_PKEY_DH) { EVPerr(EVP_F_EVP_PKEY_GET_DH, EVP_R_EXPECTING_A_DH_KEY); |