diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2002-03-09 18:24:14 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2002-03-09 18:24:14 +0000 |
commit | 1619add90c277ec9c0ecfb378c22f7fcb0793e76 (patch) | |
tree | 7b555e9152ec9ebf1d17380fdf2b13695d53b25a /crypto/rsa | |
parent | a1a4e8b6bb143f67e2969613135f374ec7d85854 (diff) |
Make {RSA,DSA,DH}_new_method obtain and release an ENGINE
functional reference.
Diffstat (limited to 'crypto/rsa')
-rw-r--r-- | crypto/rsa/rsa_lib.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 3856ea5da7..93235744f7 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -130,8 +130,17 @@ RSA *RSA_new_method(ENGINE *engine) } ret->meth = RSA_get_default_method(); - ret->engine = engine; - if(!ret->engine) + if (engine) + { + if (!ENGINE_init(engine)) + { + RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB); + OPENSSL_free(ret); + return NULL; + } + ret->engine = engine; + } + else ret->engine = ENGINE_get_default_RSA(); if(ret->engine) { @@ -166,6 +175,8 @@ RSA *RSA_new_method(ENGINE *engine) CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { + if (ret->engine) + ENGINE_finish(ret->engine); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); OPENSSL_free(ret); ret=NULL; |