diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2002-03-09 18:25:03 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2002-03-09 18:25:03 +0000 |
commit | 0c372b94f77bebed947b6a5d217a141a3259b3ed (patch) | |
tree | 11484ae0861431320e02ea15ed47b2620b91abd5 /crypto/rsa | |
parent | 26e123738028da5e767cbf7e71c6af114cab6ec3 (diff) | |
download | openssl-new-0c372b94f77bebed947b6a5d217a141a3259b3ed.tar.gz |
Make {RSA,DSA,DH}_new_method obtain and release an ENGINE
functional reference in all cases.
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; |