diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2001-06-23 23:07:34 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2001-06-23 23:07:34 +0000 |
commit | 0c9de428ae03a3dd9272aba90c595f6c25a4525d (patch) | |
tree | 0432aee5cab40ad7e686f1b44dd58affbd0840c8 | |
parent | f13def508cdec14c02817d5e52946758fd0289b7 (diff) | |
download | openssl-new-0c9de428ae03a3dd9272aba90c595f6c25a4525d.tar.gz |
In {RSA,DSA,DH}_new_method(x) need to increase the reference
count of the ENGINE is x is not NULL since it will be freed
in {RSA,DSA,DH}_free().
-rw-r--r-- | crypto/dh/dh_lib.c | 21 | ||||
-rw-r--r-- | crypto/dsa/dsa_lib.c | 23 | ||||
-rw-r--r-- | crypto/rsa/rsa_lib.c | 22 |
3 files changed, 42 insertions, 24 deletions
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index b3c609e8be..2d778ef300 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -142,16 +142,21 @@ DH *DH_new_method(ENGINE *engine) DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } - if(engine) - ret->engine = engine; + + if (engine) + { + if(ENGINE_init(engine)) + ret->engine = engine; + else + ret->engine = NULL; + } else + ret->engine=ENGINE_get_default_DH(); + if(ret->engine == NULL) { - if((ret->engine=ENGINE_get_default_DH()) == NULL) - { - DHerr(DH_F_DH_NEW,ERR_LIB_ENGINE); - OPENSSL_free(ret); - return NULL; - } + DHerr(DH_F_DH_NEW,ERR_LIB_ENGINE); + OPENSSL_free(ret); + return NULL; } meth = ENGINE_get_DH(ret->engine); ret->pad=0; diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 1b33705f46..48b228f3a1 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -146,17 +146,24 @@ DSA *DSA_new_method(ENGINE *engine) DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } - if(engine) - ret->engine = engine; + + if (engine) + { + if(ENGINE_init(engine)) + ret->engine = engine; + else + ret->engine = NULL; + } else + ret->engine=ENGINE_get_default_DSA(); + + if(ret->engine == NULL) { - if((ret->engine=ENGINE_get_default_DSA()) == NULL) - { - DSAerr(DSA_F_DSA_NEW,ERR_LIB_ENGINE); - OPENSSL_free(ret); - return NULL; - } + DSAerr(DSA_F_DSA_NEW,ERR_LIB_ENGINE); + OPENSSL_free(ret); + return NULL; } + meth = ENGINE_get_DSA(ret->engine); ret->pad=0; ret->version=0; diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 3a4760c8d4..315671a60e 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -162,17 +162,23 @@ RSA *RSA_new_method(ENGINE *engine) return(NULL); } - if (engine == NULL) + if (engine) { - if((ret->engine=ENGINE_get_default_RSA()) == NULL) - { - RSAerr(RSA_F_RSA_NEW_METHOD,ERR_LIB_ENGINE); - OPENSSL_free(ret); - return NULL; - } + if(ENGINE_init(engine)) + ret->engine = engine; + else + ret->engine = NULL; } else - ret->engine=engine; + ret->engine=ENGINE_get_default_RSA(); + + if(ret->engine == NULL) + { + RSAerr(RSA_F_RSA_NEW_METHOD,ERR_LIB_ENGINE); + OPENSSL_free(ret); + return NULL; + } + meth = ENGINE_get_RSA(ret->engine); ret->pad=0; |