Commit 7c96dbcd authored by Rich Salz's avatar Rich Salz Committed by Rich Salz
Browse files

GH715: ENGINE_finish can take NULL



Simplifies calling code.  Also fixed up any !ptr tests that were
nearby, turning them into NULL tests.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 07b3ce8f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -317,7 +317,6 @@ int init_gen_str(EVP_PKEY_CTX **pctx,

    EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
#ifndef OPENSSL_NO_ENGINE
    if (tmpeng)
    ENGINE_finish(tmpeng);
#endif
    ctx = EVP_PKEY_CTX_new_id(pkey_id, e);
+2 −4
Original line number Diff line number Diff line
@@ -1376,7 +1376,6 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,

        EVP_PKEY_asn1_get0_info(NULL, pkey_type, NULL, NULL, NULL, ameth);
#ifndef OPENSSL_NO_ENGINE
        if (tmpeng)
        ENGINE_finish(tmpeng);
#endif
        if (*pkey_type == EVP_PKEY_RSA) {
@@ -1434,7 +1433,6 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
        EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &anam, ameth);
        *palgnam = OPENSSL_strdup(anam);
#ifndef OPENSSL_NO_ENGINE
        if (tmpeng)
        ENGINE_finish(tmpeng);
#endif
    }
+2 −4
Original line number Diff line number Diff line
@@ -82,10 +82,8 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
    } else {
        ret = *a;
#ifndef OPENSSL_NO_ENGINE
        if (ret->engine) {
        ENGINE_finish(ret->engine);
        ret->engine = NULL;
        }
#endif
    }

+5 −9
Original line number Diff line number Diff line
@@ -88,10 +88,8 @@ int DH_set_method(DH *dh, const DH_METHOD *meth)
    if (mtmp->finish)
        mtmp->finish(dh);
#ifndef OPENSSL_NO_ENGINE
    if (dh->engine) {
    ENGINE_finish(dh->engine);
    dh->engine = NULL;
    }
#endif
    dh->meth = meth;
    if (meth->init)
@@ -126,7 +124,7 @@ DH *DH_new_method(ENGINE *engine)
        ret->engine = ENGINE_get_default_DH();
    if (ret->engine) {
        ret->meth = ENGINE_get_DH(ret->engine);
        if (!ret->meth) {
        if (ret->meth == NULL) {
            DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);
            ENGINE_finish(ret->engine);
            OPENSSL_free(ret);
@@ -140,7 +138,6 @@ DH *DH_new_method(ENGINE *engine)
    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
    if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
#ifndef OPENSSL_NO_ENGINE
        if (ret->engine)
        ENGINE_finish(ret->engine);
#endif
        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
@@ -165,7 +162,6 @@ void DH_free(DH *r)
    if (r->meth->finish)
        r->meth->finish(r);
#ifndef OPENSSL_NO_ENGINE
    if (r->engine)
    ENGINE_finish(r->engine);
#endif

+3 −5
Original line number Diff line number Diff line
@@ -99,10 +99,8 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
    if (mtmp->finish)
        mtmp->finish(dsa);
#ifndef OPENSSL_NO_ENGINE
    if (dsa->engine) {
    ENGINE_finish(dsa->engine);
    dsa->engine = NULL;
    }
#endif
    dsa->meth = meth;
    if (meth->init)
@@ -132,7 +130,7 @@ DSA *DSA_new_method(ENGINE *engine)
        ret->engine = ENGINE_get_default_DSA();
    if (ret->engine) {
        ret->meth = ENGINE_get_DSA(ret->engine);
        if (!ret->meth) {
        if (ret->meth == NULL) {
            DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB);
            ENGINE_finish(ret->engine);
            OPENSSL_free(ret);
Loading