Commit 0df1caa7 authored by Richard Levitte's avatar Richard Levitte
Browse files

apps: make setup_engine() and release_engine() available always



This removes some #ifndef clutter.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1644)
parent aa01b82c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1535,11 +1535,13 @@ static ENGINE *try_load_engine(BIO *err, const char *engine, int debug)
    }
    return e;
}
#endif

ENGINE *setup_engine(BIO *err, const char *engine, int debug)
{
    ENGINE *e = NULL;

#ifndef OPENSSL_NO_ENGINE
    if (engine) {
        if (strcmp(engine, "auto") == 0) {
            BIO_printf(err, "enabling auto ENGINE support\n");
@@ -1565,16 +1567,18 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug)

        BIO_printf(err, "engine \"%s\" set.\n", ENGINE_get_id(e));
    }
#endif
    return e;
}

void release_engine(ENGINE *e)
{
#ifndef OPENSSL_NO_ENGINE
    if (e != NULL)
        /* Free our "structural" reference. */
        ENGINE_free(e);
}
#endif
}

int load_config(BIO *err, CONF *cnf)
{
+1 −2
Original line number Diff line number Diff line
@@ -259,10 +259,9 @@ STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format,
                              const char *pass, ENGINE *e,
                              const char *cert_descrip);
X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
# ifndef OPENSSL_NO_ENGINE

ENGINE *setup_engine(BIO *err, const char *engine, int debug);
void release_engine(ENGINE *e);
# endif

# ifndef OPENSSL_NO_OCSP
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
+1 −8
Original line number Diff line number Diff line
@@ -319,9 +319,7 @@ int MAIN(int argc, char **argv)
#define BSIZE 256
    MS_STATIC char buf[3][BSIZE];
    char *randfile = NULL;
#ifndef OPENSSL_NO_ENGINE
    char *engine = NULL;
#endif
    char *tofree = NULL;
    DB_ATTR db_attr;

@@ -595,9 +593,7 @@ int MAIN(int argc, char **argv)
    if (!load_config(bio_err, conf))
        goto err;

#ifndef OPENSSL_NO_ENGINE
    e = setup_engine(bio_err, engine, 0);
#endif

    /* Lets get the config section we are using */
    if (section == NULL) {
@@ -1485,10 +1481,7 @@ int MAIN(int argc, char **argv)
    X509_CRL_free(crl);
    NCONF_free(conf);
    NCONF_free(extconf);
#ifndef OPENSSL_NO_ENGINE
    if (e != NULL)
    release_engine(e);
#endif
    OBJ_cleanup();
    apps_shutdown();
    OPENSSL_EXIT(ret);
+1 −8
Original line number Diff line number Diff line
@@ -143,9 +143,7 @@ int MAIN(int argc, char **argv)
    const EVP_MD *sign_md = NULL;
    int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
    int rctformat = FORMAT_SMIME, keyform = FORMAT_PEM;
# ifndef OPENSSL_NO_ENGINE
    char *engine = NULL;
# endif
    unsigned char *secret_key = NULL, *secret_keyid = NULL;
    unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;
    size_t secret_keylen = 0, secret_keyidlen = 0;
@@ -665,9 +663,7 @@ int MAIN(int argc, char **argv)
                   "cert.pem       recipient certificate(s) for encryption\n");
        goto end;
    }
# ifndef OPENSSL_NO_ENGINE
    e = setup_engine(bio_err, engine, 0);
# endif

    if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
        BIO_printf(bio_err, "Error getting password\n");
@@ -1170,10 +1166,7 @@ int MAIN(int argc, char **argv)
    EVP_PKEY_free(key);
    CMS_ContentInfo_free(cms);
    CMS_ContentInfo_free(rcms);
#ifndef OPENSSL_NO_ENGINE
    if (e != NULL)
    release_engine(e);
#endif
    BIO_free(rctin);
    BIO_free(in);
    BIO_free(indata);
+1 −4
Original line number Diff line number Diff line
@@ -537,10 +537,7 @@ int MAIN(int argc, char **argv)
        OPENSSL_free(sigbuf);
    if (bmd != NULL)
        BIO_free(bmd);
#ifndef OPENSSL_NO_ENGINE
    if (e != NULL)
    release_engine(e);
#endif
    apps_shutdown();
    OPENSSL_EXIT(err);
}
Loading