fewer NO_ENGINE #ifdef's
authorRich Salz <rsalz@openssl.org>
Sat, 25 Apr 2015 19:41:29 +0000 (15:41 -0400)
committerRich Salz <rsalz@openssl.org>
Sat, 25 Apr 2015 19:41:29 +0000 (15:41 -0400)
Make setup_engine be a dummy if NO_ENGINE is enabled.
The option is not enabled if NO_ENGINE is enabled, so the one "wasted"
variable just sits there. Removes some variables and code.

Reviewed-by: Richard Levitte <levitte@openssl.org>
31 files changed:
apps/apps.h
apps/ca.c
apps/cms.c
apps/dgst.c
apps/dhparam.c
apps/dsa.c
apps/dsaparam.c
apps/ec.c
apps/ecparam.c
apps/enc.c
apps/gendsa.c
apps/genpkey.c
apps/genrsa.c
apps/pkcs12.c
apps/pkcs7.c
apps/pkcs8.c
apps/pkey.c
apps/pkeyparam.c
apps/pkeyutl.c
apps/rand.c
apps/req.c
apps/rsa.c
apps/rsautl.c
apps/s_client.c
apps/s_server.c
apps/smime.c
apps/speed.c
apps/spkac.c
apps/srp.c
apps/verify.c
apps/x509.c

index ad17b1a82117dc37e3cf6c96ee26c2a12c78542c..5d1b98f837252eb0ae51cc498856a5891777a43c 100644 (file)
@@ -431,7 +431,9 @@ STACK_OF(X509_CRL) *load_crls(const char *file, int format,
 X509_STORE *setup_verify(char *CAfile, char *CApath);
 int ctx_set_verify_locations(SSL_CTX *ctx,
                              const char *CAfile, const char *CApath);
 X509_STORE *setup_verify(char *CAfile, char *CApath);
 int ctx_set_verify_locations(SSL_CTX *ctx,
                              const char *CAfile, const char *CApath);
-# ifndef OPENSSL_NO_ENGINE
+# ifdef OPENSSL_NO_ENGINE
+#  define setup_engine(engine, debug) NULL
+# else
 ENGINE *setup_engine(const char *engine, int debug);
 # endif
 # ifndef OPENSSL_NO_OCSP
 ENGINE *setup_engine(const char *engine, int debug);
 # endif
 # ifndef OPENSSL_NO_OCSP
index af3afaabda7d8bf124deba40fc6445d73e4a95ac..38c96aeb0d6b9da22e198d437ad39d8e0345c57d 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -292,17 +292,15 @@ int ca_main(int argc, char **argv)
     X509_CRL *crl = NULL;
     const EVP_MD *dgst = NULL;
     char *configfile = NULL, *md = NULL, *policy = NULL, *keyfile = NULL;
     X509_CRL *crl = NULL;
     const EVP_MD *dgst = NULL;
     char *configfile = NULL, *md = NULL, *policy = NULL, *keyfile = NULL;
-    char *certfile = NULL, *crl_ext = NULL, *crlnumberfile = NULL, *enddate =
-        NULL;
+    char *certfile = NULL, *crl_ext = NULL, *crlnumberfile = NULL;
     char *infile = NULL, *spkac_file = NULL, *ss_cert_file = NULL;
     char *extensions = NULL, *extfile = NULL, *key = NULL, *passinarg = NULL;
     char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL;
     char *infile = NULL, *spkac_file = NULL, *ss_cert_file = NULL;
     char *extensions = NULL, *extfile = NULL, *key = NULL, *passinarg = NULL;
     char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL;
-    char *serialfile = NULL, *startdate = NULL, *subj = NULL, *tmp_email_dn =
-        NULL;
-    char *prog;
-    char *const *pp;
-    char *dbfile = NULL, *engine = NULL, *f, *randfile = NULL, *tofree = NULL;
+    char *serialfile = NULL, *startdate = NULL, *subj = NULL;
+    char *prog, *enddate = NULL, *tmp_email_dn = NULL;
+    char *dbfile = NULL, *f, *randfile = NULL, *tofree = NULL;
     char buf[3][BSIZE];
     char buf[3][BSIZE];
+    char *const *pp;
     const char *p;
     int create_ser = 0, free_key = 0, total = 0, total_done = 0;
     int batch = 0, default_op = 1, doupdatedb = 0, ext_copy = EXT_COPY_NONE;
     const char *p;
     int create_ser = 0, free_key = 0, total = 0, total_done = 0;
     int batch = 0, default_op = 1, doupdatedb = 0, ext_copy = EXT_COPY_NONE;
@@ -488,7 +486,7 @@ opthelp:
             rev_type = REV_CA_COMPROMISE;
             break;
         case OPT_ENGINE:
             rev_type = REV_CA_COMPROMISE;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         }
     }
             break;
         }
     }
@@ -542,9 +540,6 @@ end_of_options:
         OPENSSL_free(tofree);
         tofree = NULL;
     }
         OPENSSL_free(tofree);
         tofree = NULL;
     }
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
 
     /* Lets get the config section we are using */
     if (section == NULL) {
 
     /* Lets get the config section we are using */
     if (section == NULL) {
index 397071ca7f4985758e37f001880a07d8692d83a0..e3e8656eb105c162a06c158c57cf64a36735f789 100644 (file)
@@ -241,7 +241,7 @@ int cms_main(int argc, char **argv)
     X509_STORE *store = NULL;
     X509_VERIFY_PARAM *vpm = NULL;
     char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
     X509_STORE *store = NULL;
     X509_VERIFY_PARAM *vpm = NULL;
     char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
-    char *CAfile = NULL, *CApath = NULL, *certsoutfile = NULL, *engine = NULL;
+    char *CAfile = NULL, *CApath = NULL, *certsoutfile = NULL;
     char *infile = NULL, *outfile = NULL, *rctfile = NULL, *inrand = NULL;
     char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile =
         NULL;
     char *infile = NULL, *outfile = NULL, *rctfile = NULL, *inrand = NULL;
     char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile =
         NULL;
@@ -475,7 +475,7 @@ int cms_main(int argc, char **argv)
             need_rand = 1;
             break;
         case OPT_ENGINE:
             need_rand = 1;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
@@ -668,9 +668,6 @@ int cms_main(int argc, char **argv)
     } else if (!operation)
         goto opthelp;
 
     } else if (!operation)
         goto opthelp;
 
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
 
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
 
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
index 21b8c7fc66c7d319d4b012199ddbd1692e2967b4..adfa2a63ba969d076611df40a2dcd7355a5f21a3 100644 (file)
@@ -101,10 +101,6 @@ OPTIONS dgst_options[] = {
      "Verify a signature using private key in file"},
     {"signature", OPT_SIGNATURE, '<', "File with signature to verify"},
     {"keyform", OPT_KEYFORM, 'f', "Key file format (PEM or ENGINE)"},
      "Verify a signature using private key in file"},
     {"signature", OPT_SIGNATURE, '<', "File with signature to verify"},
     {"keyform", OPT_KEYFORM, 'f', "Key file format (PEM or ENGINE)"},
-#ifndef OPENSSL_NO_ENGINE
-    {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
-#endif
-    {"engine_impl", OPT_ENGINE_IMPL, '-'},
     {"hex", OPT_HEX, '-', "Print as hex dump"},
     {"binary", OPT_BINARY, '-', "Print in binary form"},
     {"d", OPT_DEBUG, '-', "Print debug info"},
     {"hex", OPT_HEX, '-', "Print as hex dump"},
     {"binary", OPT_BINARY, '-', "Print in binary form"},
     {"d", OPT_DEBUG, '-', "Print debug info"},
@@ -115,6 +111,10 @@ OPTIONS dgst_options[] = {
     {"mac", OPT_MAC, 's', "Create MAC (not neccessarily HMAC)"},
     {"sigop", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
     {"macop", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
     {"mac", OPT_MAC, 's', "Create MAC (not neccessarily HMAC)"},
     {"sigop", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
     {"macop", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
+#ifndef OPENSSL_NO_ENGINE
+    {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
+    {"engine_impl", OPT_ENGINE_IMPL, '-'},
+#endif
     {"", OPT_DIGEST, '-', "Any supported digest"},
     {NULL}
 };
     {"", OPT_DIGEST, '-', "Any supported digest"},
     {NULL}
 };
@@ -136,10 +136,7 @@ int dgst_main(int argc, char **argv)
     int i, ret = 1, out_bin = -1, want_pub = 0, do_verify =
         0, non_fips_allow = 0;
     unsigned char *buf = NULL, *sigbuf = NULL;
     int i, ret = 1, out_bin = -1, want_pub = 0, do_verify =
         0, non_fips_allow = 0;
     unsigned char *buf = NULL, *sigbuf = NULL;
-#ifndef OPENSSL_NO_ENGINE
-    char *engine = NULL;
     int engine_impl = 0;
     int engine_impl = 0;
-#endif
 
     prog = opt_progname(argv[0]);
     if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) {
 
     prog = opt_progname(argv[0]);
     if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) {
@@ -193,15 +190,12 @@ int dgst_main(int argc, char **argv)
             if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyform))
                 goto opthelp;
             break;
             if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyform))
                 goto opthelp;
             break;
-#ifndef OPENSSL_NO_ENGINE
         case OPT_ENGINE:
         case OPT_ENGINE:
-            engine = opt_arg();
-            e = setup_engine(engine, 0);
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_ENGINE_IMPL:
             engine_impl = 1;
             break;
             break;
         case OPT_ENGINE_IMPL:
             engine_impl = 1;
             break;
-#endif
         case OPT_HEX:
             out_bin = 0;
             break;
         case OPT_HEX:
             out_bin = 0;
             break;
@@ -250,10 +244,8 @@ int dgst_main(int argc, char **argv)
                    "No signature to verify: use the -signature option\n");
         goto end;
     }
                    "No signature to verify: use the -signature option\n");
         goto end;
     }
-#ifndef OPENSSL_NO_ENGINE
     if (engine_impl)
         impl = e;
     if (engine_impl)
         impl = e;
-#endif
 
     in = BIO_new(BIO_s_file());
     bmd = BIO_new(BIO_f_md());
 
     in = BIO_new(BIO_s_file());
     bmd = BIO_new(BIO_f_md());
index e842ca5f20ed5cb5a99a5addba2ca1cbe9a5afac..6e51c0b82e78fb99a9d03bea74c2fa1a81032be9 100644 (file)
@@ -167,8 +167,7 @@ int dhparam_main(int argc, char **argv)
 {
     BIO *in = NULL, *out = NULL;
     DH *dh = NULL;
 {
     BIO *in = NULL, *out = NULL;
     DH *dh = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog, *inrand =
-        NULL;
+    char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
     int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
     OPTION_CHOICE o;
     int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
     OPTION_CHOICE o;
@@ -200,7 +199,7 @@ int dhparam_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_CHECK:
             check = 1;
             break;
         case OPT_CHECK:
             check = 1;
@@ -234,10 +233,6 @@ int dhparam_main(int argc, char **argv)
     if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
         goto end;
 
     if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
         goto end;
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (g && !num)
         num = DEFBITS;
 
     if (g && !num)
         num = DEFBITS;
 
index 9d7c97f609a3a4864689557d129c3a18cb8766e6..c23ed5dac81edae0f12646098b23d8695744c13e 100644 (file)
@@ -107,9 +107,8 @@ int dsa_main(int argc, char **argv)
     DSA *dsa = NULL;
     ENGINE *e = NULL;
     const EVP_CIPHER *enc = NULL;
     DSA *dsa = NULL;
     ENGINE *e = NULL;
     const EVP_CIPHER *enc = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog;
-    char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg =
-        NULL;
+    char *infile = NULL, *outfile = NULL, *prog;
+    char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
     OPTION_CHOICE o;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
     int i, modulus = 0, pubin = 0, pubout = 0, pvk_encr = 2, ret = 1;
     OPTION_CHOICE o;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
     int i, modulus = 0, pubin = 0, pubout = 0, pvk_encr = 2, ret = 1;
@@ -149,7 +148,7 @@ int dsa_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
@@ -192,10 +191,6 @@ int dsa_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
index b3144097625aadce2efff1085efde42fd25347be..f7365b92d0b1e39ee72fe924a0b525049961f643 100644 (file)
@@ -124,8 +124,7 @@ int dsaparam_main(int argc, char **argv)
 # ifdef GENCB_TEST
     int timebomb = 0;
 # endif
 # ifdef GENCB_TEST
     int timebomb = 0;
 # endif
-    char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL, *engine =
-        NULL;
+    char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
     OPTION_CHOICE o;
 
     prog = opt_init(argc, argv, dsaparam_options);
     OPTION_CHOICE o;
 
     prog = opt_init(argc, argv, dsaparam_options);
@@ -155,7 +154,7 @@ int dsaparam_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_TIMEBOMB:
 # ifdef GENCB_TEST
             break;
         case OPT_TIMEBOMB:
 # ifdef GENCB_TEST
@@ -201,10 +200,6 @@ int dsaparam_main(int argc, char **argv)
     if (out == NULL)
         goto end;
 
     if (out == NULL)
         goto end;
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (need_rand) {
         app_RAND_load_file(NULL, (inrand != NULL));
         if (inrand != NULL)
     if (need_rand) {
         app_RAND_load_file(NULL, (inrand != NULL));
         if (inrand != NULL)
index d6bce6d28ae029f00502079eeff6189687ac8975..471de474e447948d63f47e16c64d1ca8c6dc756b 100644 (file)
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -116,9 +116,8 @@ int ec_main(int argc, char **argv)
     const EC_GROUP *group;
     const EVP_CIPHER *enc = NULL;
     point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
     const EC_GROUP *group;
     const EVP_CIPHER *enc = NULL;
     point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
-    char *infile = NULL, *outfile = NULL, *prog, *engine = NULL;
-    char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg =
-        NULL;
+    char *infile = NULL, *outfile = NULL, *prog;
+    char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
     OPTION_CHOICE o;
     int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_form = 0, new_asn1_flag = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
     OPTION_CHOICE o;
     int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_form = 0, new_asn1_flag = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
@@ -172,7 +171,7 @@ int ec_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_CIPHER:
             if (!opt_cipher(opt_unknown(), &enc))
             break;
         case OPT_CIPHER:
             if (!opt_cipher(opt_unknown(), &enc))
@@ -194,10 +193,6 @@ int ec_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
index 167ef39f6d3d696ff276548943365f9c4b39e49f..049fc78092dcb99fea9a02230b967d58358a5498 100644 (file)
@@ -138,7 +138,7 @@ int ecparam_main(int argc, char **argv)
     EC_GROUP *group = NULL;
     point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
     char *curve_name = NULL, *inrand = NULL;
     EC_GROUP *group = NULL;
     point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
     char *curve_name = NULL, *inrand = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog;
+    char *infile = NULL, *outfile = NULL, *prog;
     unsigned char *buffer = NULL;
     OPTION_CHOICE o;
     int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_asn1_flag = 0;
     unsigned char *buffer = NULL;
     OPTION_CHOICE o;
     int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_asn1_flag = 0;
@@ -213,7 +213,7 @@ int ecparam_main(int argc, char **argv)
             need_rand = 1;
             break;
         case OPT_ENGINE:
             need_rand = 1;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         }
     }
             break;
         }
     }
@@ -227,10 +227,6 @@ int ecparam_main(int argc, char **argv)
     if (out == NULL)
         goto end;
 
     if (out == NULL)
         goto end;
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (list_curves) {
         EC_builtin_curve *curves = NULL;
         size_t crv_len = 0;
     if (list_curves) {
         EC_builtin_curve *curves = NULL;
         size_t crv_len = 0;
index 06b056b45d4cbe22b3b3344866173993d97b419e..61a64d4469c6da259cffc0a88055ff7f596be882 100644 (file)
@@ -132,7 +132,7 @@ int enc_main(int argc, char **argv)
     EVP_CIPHER_CTX *ctx = NULL;
     const EVP_CIPHER *cipher = NULL, *c;
     const EVP_MD *dgst = NULL;
     EVP_CIPHER_CTX *ctx = NULL;
     const EVP_CIPHER *cipher = NULL, *c;
     const EVP_MD *dgst = NULL;
-    char *engine = NULL, *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p;
+    char *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p;
     char *infile = NULL, *outfile = NULL, *prog;
     char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL;
     char mbuf[sizeof magic - 1];
     char *infile = NULL, *outfile = NULL, *prog;
     char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL;
     char mbuf[sizeof magic - 1];
@@ -193,7 +193,7 @@ int enc_main(int argc, char **argv)
             passarg = opt_arg();
             break;
         case OPT_ENGINE:
             passarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_D:
             enc = 0;
             break;
         case OPT_D:
             enc = 0;
@@ -294,10 +294,6 @@ int enc_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-#endif
-
     if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
         BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
         goto end;
     if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
         BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
         goto end;
index 1eaaa455049e1e96245c4c1ae0167ef036c645e1..21988a06522dce5c78de4771e04a6bd6b3679189 100644 (file)
@@ -96,7 +96,7 @@ int gendsa_main(int argc, char **argv)
     BIO *out = NULL, *in = NULL;
     DSA *dsa = NULL;
     const EVP_CIPHER *enc = NULL;
     BIO *out = NULL, *in = NULL;
     DSA *dsa = NULL;
     const EVP_CIPHER *enc = NULL;
-    char *engine = NULL, *inrand = NULL, *dsaparams = NULL;
+    char *inrand = NULL, *dsaparams = NULL;
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
     OPTION_CHOICE o;
     int ret = 1;
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
     OPTION_CHOICE o;
     int ret = 1;
@@ -120,7 +120,7 @@ int gendsa_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_RAND:
             inrand = opt_arg();
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -138,10 +138,6 @@ int gendsa_main(int argc, char **argv)
         goto opthelp;
     dsaparams = *argv;
 
         goto opthelp;
     dsaparams = *argv;
 
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
-
     if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
index 5130b40a82cf00862f04eb86f91021af480e03fd..ae68e7a4427110d0c9b92e2553c3f0728ab88cb9 100644 (file)
@@ -128,11 +128,9 @@ int genpkey_main(int argc, char **argv)
         case OPT_PASS:
             passarg = opt_arg();
             break;
         case OPT_PASS:
             passarg = opt_arg();
             break;
-#ifndef OPENSSL_NO_ENGINE
         case OPT_ENGINE:
             e = setup_engine(opt_arg(), 0);
             break;
         case OPT_ENGINE:
             e = setup_engine(opt_arg(), 0);
             break;
-#endif
         case OPT_PARAMFILE:
             if (do_param == 1)
                 goto opthelp;
         case OPT_PARAMFILE:
             if (do_param == 1)
                 goto opthelp;
index b7275aef7a866f8bdae0bc62e671db1efd043e63..7d0466aaf98ec3edf9b2f0f9a67c0b8678e0f690 100644 (file)
@@ -110,8 +110,7 @@ int genrsa_main(int argc, char **argv)
     int ret = 1, non_fips_allow = 0, num = DEFBITS;
     unsigned long f4 = RSA_F4;
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
     int ret = 1, non_fips_allow = 0, num = DEFBITS;
     unsigned long f4 = RSA_F4;
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
-    char *engine = NULL, *inrand = NULL, *prog;
-    char *hexe, *dece;
+    char *inrand = NULL, *prog, *hexe, *dece;
     OPTION_CHOICE o;
 
     if (!bn || !cb)
     OPTION_CHOICE o;
 
     if (!bn || !cb)
@@ -142,7 +141,7 @@ int genrsa_main(int argc, char **argv)
         case OPT_OUT:
             outfile = opt_arg();
         case OPT_ENGINE:
         case OPT_OUT:
             outfile = opt_arg();
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_RAND:
             inrand = opt_arg();
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -166,9 +165,6 @@ int genrsa_main(int argc, char **argv)
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     }
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     }
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
 
     out = bio_open_default(outfile, "w");
     if (out == NULL)
 
     out = bio_open_default(outfile, "w");
     if (out == NULL)
@@ -185,11 +181,7 @@ int genrsa_main(int argc, char **argv)
 
     BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
                num);
 
     BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
                num);
-# ifdef OPENSSL_NO_ENGINE
-    rsa = RSA_new();
-# else
-    rsa = RSA_new_method(e);
-# endif
+    rsa = e ? RSA_new_method(e) : RSA_new();
     if (!rsa)
         goto end;
 
     if (!rsa)
         goto end;
 
index a031c1ba25ee76154eea223134fb441f25bb8662..5cdd71b6c0dec52dadc1b8765885ae2815ea9b38 100644 (file)
@@ -173,7 +173,7 @@ int pkcs12_main(int argc, char **argv)
     char *passinarg = NULL, *passoutarg = NULL, *passarg = NULL;
     char *passin = NULL, *passout = NULL, *inrand = NULL, *macalg = NULL;
     char *cpass = NULL, *mpass = NULL, *CApath = NULL, *CAfile = NULL;
     char *passinarg = NULL, *passoutarg = NULL, *passarg = NULL;
     char *passin = NULL, *passout = NULL, *inrand = NULL, *macalg = NULL;
     char *cpass = NULL, *mpass = NULL, *CApath = NULL, *CAfile = NULL;
-    char *engine = NULL, *prog;
+    char *prog;
     ENGINE *e = NULL;
     BIO *in = NULL, *out = NULL;
     PKCS12 *p12 = NULL;
     ENGINE *e = NULL;
     BIO *in = NULL, *out = NULL;
     PKCS12 *p12 = NULL;
@@ -308,17 +308,13 @@ int pkcs12_main(int argc, char **argv)
             CAfile = opt_arg();
             break;
         case OPT_ENGINE:
             CAfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
-
     if (passarg) {
         if (export_cert)
             passoutarg = passarg;
     if (passarg) {
         if (export_cert)
             passoutarg = passarg;
index ca052730ea0c8fd255ee0bcce3e64feebef7f450..7c62a8658e6939b3e8d964823dc3aa09817c5eed 100644 (file)
@@ -143,7 +143,7 @@ int pkcs7_main(int argc, char **argv)
     PKCS7 *p7 = NULL;
     BIO *in = NULL, *out = NULL;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM;
     PKCS7 *p7 = NULL;
     BIO *in = NULL, *out = NULL;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog;
+    char *infile = NULL, *outfile = NULL, *prog;
     int i, print_certs = 0, text = 0, noout = 0, p7_print = 0, ret = 1;
     OPTION_CHOICE o;
 
     int i, print_certs = 0, text = 0, noout = 0, p7_print = 0, ret = 1;
     OPTION_CHOICE o;
 
@@ -186,17 +186,13 @@ int pkcs7_main(int argc, char **argv)
             print_certs = 1;
             break;
         case OPT_ENGINE:
             print_certs = 1;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-#endif
-
     in = bio_open_default(infile, RB(informat));
     if (in == NULL)
         goto end;
     in = bio_open_default(infile, RB(informat));
     if (in == NULL)
         goto end;
index 7b361cfec6b823214cbf20a28376eb61e38cb1ec..105c1cb61c4829cc6114d5f011f2d37b35005a7b 100644 (file)
@@ -104,14 +104,12 @@ int pkcs8_main(int argc, char **argv)
     PKCS8_PRIV_KEY_INFO *p8inf = NULL;
     X509_SIG *p8 = NULL;
     const EVP_CIPHER *cipher = NULL;
     PKCS8_PRIV_KEY_INFO *p8inf = NULL;
     X509_SIG *p8 = NULL;
     const EVP_CIPHER *cipher = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL;
+    char *infile = NULL, *outfile = NULL;
     char *passinarg = NULL, *passoutarg = NULL, *prog;
     char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
     OPTION_CHOICE o;
     char *passinarg = NULL, *passoutarg = NULL, *prog;
     char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
     OPTION_CHOICE o;
-    int nocrypt = 0, ret = 1, iter = PKCS12_DEFAULT_ITER, p8_broken =
-        PKCS8_OK;
-    int informat = FORMAT_PEM, outformat = FORMAT_PEM, topk8 = 0, pbe_nid =
-        -1;
+    int nocrypt = 0, ret = 1, iter = PKCS12_DEFAULT_ITER, p8_broken = PKCS8_OK;
+    int informat = FORMAT_PEM, outformat = FORMAT_PEM, topk8 = 0, pbe_nid = -1;
 
     prog = opt_init(argc, argv, pkcs8_options);
     while ((o = opt_next()) != OPT_EOF) {
 
     prog = opt_init(argc, argv, pkcs8_options);
     while ((o = opt_next()) != OPT_EOF) {
@@ -188,17 +186,13 @@ int pkcs8_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
             break;
         }
     }
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
index 3597be0ee6afd83c4a2ce5cda71698c4bd364f6b..716d6d01e80df2bdbc627a9608c8fa0465556a8f 100644 (file)
@@ -97,7 +97,7 @@ int pkey_main(int argc, char **argv)
     EVP_PKEY *pkey = NULL;
     const EVP_CIPHER *cipher = NULL;
     char *infile = NULL, *outfile = NULL, *passin = NULL, *passout = NULL;
     EVP_PKEY *pkey = NULL;
     const EVP_CIPHER *cipher = NULL;
     char *infile = NULL, *outfile = NULL, *passin = NULL, *passout = NULL;
-    char *passinarg = NULL, *passoutarg = NULL, *prog, *engine = NULL;
+    char *passinarg = NULL, *passoutarg = NULL, *prog;
     OPTION_CHOICE o;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM;
     int pubin = 0, pubout = 0, pubtext = 0, text = 0, noout = 0, ret = 1;
     OPTION_CHOICE o;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM;
     int pubin = 0, pubout = 0, pubtext = 0, text = 0, noout = 0, ret = 1;
@@ -129,7 +129,7 @@ int pkey_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_IN:
             infile = opt_arg();
             break;
         case OPT_IN:
             infile = opt_arg();
@@ -160,10 +160,6 @@ int pkey_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
index 5a5caf56bda8c58e6f4ca39334d84f4e9a6b9bc6..fbd19a78cd7a9ced9f0266cbc36a5f8e70437a58 100644 (file)
@@ -85,7 +85,7 @@ int pkeyparam_main(int argc, char **argv)
     EVP_PKEY *pkey = NULL;
     int text = 0, noout = 0, ret = 1;
     OPTION_CHOICE o;
     EVP_PKEY *pkey = NULL;
     int text = 0, noout = 0, ret = 1;
     OPTION_CHOICE o;
-    char *infile = NULL, *outfile = NULL, *prog, *engine = NULL;
+    char *infile = NULL, *outfile = NULL, *prog;
 
     prog = opt_init(argc, argv, pkeyparam_options);
     while ((o = opt_next()) != OPT_EOF) {
 
     prog = opt_init(argc, argv, pkeyparam_options);
     while ((o = opt_next()) != OPT_EOF) {
@@ -105,7 +105,7 @@ int pkeyparam_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_TEXT:
             text = 1;
             break;
         case OPT_TEXT:
             text = 1;
@@ -118,10 +118,6 @@ int pkeyparam_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-#endif
-
     in = bio_open_default(infile, "r");
     if (in == NULL)
         goto end;
     in = bio_open_default(infile, "r");
     if (in == NULL)
         goto end;
index 942ba05ded03de93bc17f74ae93f3f3643fb5310..da7dc2e4cdf4baf960a6bab482bfd76e5a58a4b3 100644 (file)
@@ -174,11 +174,9 @@ int pkeyutl_main(int argc, char **argv)
             if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &keyform))
                 goto opthelp;
             break;
             if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &keyform))
                 goto opthelp;
             break;
-#ifndef OPENSSL_NO_ENGINE
         case OPT_ENGINE:
             e = setup_engine(opt_arg(), 0);
             break;
         case OPT_ENGINE:
             e = setup_engine(opt_arg(), 0);
             break;
-#endif
         case OPT_PUBIN:
             key_type = KEY_PUBKEY;
             break;
         case OPT_PUBIN:
             key_type = KEY_PUBKEY;
             break;
index 9a73935acc2d3c9793ddd69e8ab7c141777f2d8e..498e7dae7065f628bf20847c420df5d99b98f4fa 100644 (file)
@@ -85,7 +85,7 @@ OPTIONS rand_options[] = {
 int rand_main(int argc, char **argv)
 {
     BIO *out = NULL;
 int rand_main(int argc, char **argv)
 {
     BIO *out = NULL;
-    char *engine = NULL, *inrand = NULL, *outfile = NULL, *prog;
+    char *inrand = NULL, *outfile = NULL, *prog;
     OPTION_CHOICE o;
     int base64 = 0, hex = 0, i, num = -1, r, ret = 1;
 
     OPTION_CHOICE o;
     int base64 = 0, hex = 0, i, num = -1, r, ret = 1;
 
@@ -105,7 +105,7 @@ int rand_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_RAND:
             inrand = opt_arg();
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -126,10 +126,6 @@ int rand_main(int argc, char **argv)
     if (sscanf(argv[0], "%d", &num) != 1 || num < 0)
         goto opthelp;
 
     if (sscanf(argv[0], "%d", &num) != 1 || num < 0)
         goto opthelp;
 
-#ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-#endif
-
     app_RAND_load_file(NULL, (inrand != NULL));
     if (inrand != NULL)
         BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
     app_RAND_load_file(NULL, (inrand != NULL));
     if (inrand != NULL)
         BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
index 1237c33ec19d10e8b807ccdf6f016dafe4556eb8..0502a64abf20561359b62deda2151c643eb3f544 100644 (file)
@@ -136,7 +136,6 @@ OPTIONS req_options[] = {
     {"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
     {"in", OPT_IN, '<', "Input file"},
     {"out", OPT_OUT, '>', "Output file"},
     {"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
     {"in", OPT_IN, '<', "Input file"},
     {"out", OPT_OUT, '>', "Output file"},
-    {"keygen_engine", OPT_KEYGEN_ENGINE, 's'},
     {"key", OPT_KEY, '<', "Use the private key contained in file"},
     {"keyform", OPT_KEYFORM, 'F', "Key file format"},
     {"pubkey", OPT_PUBKEY, '-', "Output public key"},
     {"key", OPT_KEY, '<', "Use the private key contained in file"},
     {"keyform", OPT_KEYFORM, 'F', "Key file format"},
     {"pubkey", OPT_PUBKEY, '-', "Output public key"},
@@ -179,6 +178,7 @@ OPTIONS req_options[] = {
      "Request extension section (override value in config file)"},
 #ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
      "Request extension section (override value in config file)"},
 #ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
+    {"keygen_engine", OPT_KEYGEN_ENGINE, 's'},
 #endif
     {"", OPT_MD, '-', "Any supported digest"},
     {NULL}
 #endif
     {"", OPT_MD, '-', "Any supported digest"},
     {NULL}
@@ -196,7 +196,7 @@ int req_main(int argc, char **argv)
     X509_REQ *req = NULL;
     const EVP_CIPHER *cipher = NULL;
     const EVP_MD *md_alg = NULL, *digest = NULL;
     X509_REQ *req = NULL;
     const EVP_CIPHER *cipher = NULL;
     const EVP_MD *md_alg = NULL, *digest = NULL;
-    char *engine = NULL, *extensions = NULL, *infile = NULL;
+    char *extensions = NULL, *infile = NULL;
     char *outfile = NULL, *keyfile = NULL, *inrand = NULL;
     char *keyalgstr = NULL, *p, *prog, *passargin = NULL, *passargout = NULL;
     char *passin = NULL, *passout = NULL, *req_exts = NULL, *subj = NULL;
     char *outfile = NULL, *keyfile = NULL, *inrand = NULL;
     char *keyalgstr = NULL, *p, *prog, *passargin = NULL, *passargout = NULL;
     char *passin = NULL, *passout = NULL, *req_exts = NULL, *subj = NULL;
@@ -235,18 +235,18 @@ int req_main(int argc, char **argv)
             if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
                 goto opthelp;
             break;
             if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
                 goto opthelp;
             break;
-#ifndef OPENSSL_NO_ENGINE
         case OPT_ENGINE:
         case OPT_ENGINE:
-            engine = optarg;
+            (void)setup_engine(opt_arg(), 0);
             break;
         case OPT_KEYGEN_ENGINE:
             break;
         case OPT_KEYGEN_ENGINE:
+#ifndef OPENSSL_NO_ENGINE
             gen_eng = ENGINE_by_id(opt_arg());
             if (gen_eng == NULL) {
                 BIO_printf(bio_err, "Can't find keygen engine %s\n", *argv);
             gen_eng = ENGINE_by_id(opt_arg());
             if (gen_eng == NULL) {
                 BIO_printf(bio_err, "Can't find keygen engine %s\n", *argv);
-                goto end;
+                goto opthelp;
             }
             }
-            break;
 #endif
 #endif
+            break;
         case OPT_KEY:
             keyfile = opt_arg();
             break;
         case OPT_KEY:
             keyfile = opt_arg();
             break;
@@ -498,9 +498,6 @@ int req_main(int argc, char **argv)
             goto end;
         }
     }
             goto end;
         }
     }
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
 
     if (keyfile != NULL) {
         pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
 
     if (keyfile != NULL) {
         pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
index 7f7069c899623bf7c0613bb4e732e480ed475ba5..07cc5fb5dca01a7160580ac6037a6f8e55dee755 100644 (file)
@@ -158,7 +158,7 @@ int rsa_main(int argc, char **argv)
     BIO *out = NULL;
     RSA *rsa = NULL;
     const EVP_CIPHER *enc = NULL;
     BIO *out = NULL;
     RSA *rsa = NULL;
     const EVP_CIPHER *enc = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog;
+    char *infile = NULL, *outfile = NULL, *prog;
     char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
     int i;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0;
     char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
     int i;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0;
@@ -203,7 +203,7 @@ int rsa_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_PUBIN:
             pubin = 1;
             break;
         case OPT_PUBIN:
             pubin = 1;
@@ -249,10 +249,6 @@ int rsa_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
index 04667469f6b59a8078f12114c448580c334a8a6a..67cb76e8ce49ae0c748f3ad43c1cb8c0b8637e72 100644 (file)
@@ -116,7 +116,7 @@ int rsautl_main(int argc, char **argv)
     EVP_PKEY *pkey = NULL;
     RSA *rsa = NULL;
     X509 *x;
     EVP_PKEY *pkey = NULL;
     RSA *rsa = NULL;
     X509 *x;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *keyfile = NULL;
+    char *infile = NULL, *outfile = NULL, *keyfile = NULL;
     char *passinarg = NULL, *passin = NULL, *prog;
     char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
     unsigned char *rsa_in = NULL, *rsa_out = NULL, pad = RSA_PKCS1_PADDING;
     char *passinarg = NULL, *passin = NULL, *prog;
     char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
     unsigned char *rsa_in = NULL, *rsa_out = NULL, pad = RSA_PKCS1_PADDING;
@@ -147,7 +147,7 @@ int rsautl_main(int argc, char **argv)
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
             outfile = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_ASN1PARSE:
             asn1parse = 1;
             break;
         case OPT_ASN1PARSE:
             asn1parse = 1;
@@ -208,9 +208,7 @@ int rsautl_main(int argc, char **argv)
         BIO_printf(bio_err, "A private key is needed for this operation\n");
         goto end;
     }
         BIO_printf(bio_err, "A private key is needed for this operation\n");
         goto end;
     }
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
+
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
index 900efe7c86e5a0ccec00fd54dc37164ed6ea91bd..0d030056fc7357e1d994a0a22f6d28b27b9a3b2b 100644 (file)
@@ -591,7 +591,6 @@ OPTIONS s_client_options[] = {
     {"verify_quiet", OPT_VERIFY_QUIET, '-'},
     {"brief", OPT_BRIEF, '-'},
     {"prexit", OPT_PREXIT, '-'},
     {"verify_quiet", OPT_VERIFY_QUIET, '-'},
     {"brief", OPT_BRIEF, '-'},
     {"prexit", OPT_PREXIT, '-'},
-    {"ssl_client_engine", OPT_SSL_CLIENT_ENGINE, 's'},
     {"trace", OPT_TRACE, '-'},
     {"security_debug", OPT_SECURITY_DEBUG, '-'},
     {"security_debug_verbose", OPT_SECURITY_DEBUG_VERBOSE, '-'},
     {"trace", OPT_TRACE, '-'},
     {"security_debug", OPT_SECURITY_DEBUG, '-'},
     {"security_debug_verbose", OPT_SECURITY_DEBUG_VERBOSE, '-'},
@@ -603,6 +602,7 @@ OPTIONS s_client_options[] = {
     {"verifyCAfile", OPT_VERIFYCAFILE, '<'},
 #ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
     {"verifyCAfile", OPT_VERIFYCAFILE, '<'},
 #ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
+    {"ssl_client_engine", OPT_SSL_CLIENT_ENGINE, 's'},
 #endif
     OPT_S_OPTIONS,
     OPT_V_OPTIONS,
 #endif
     OPT_S_OPTIONS,
     OPT_V_OPTIONS,
@@ -649,7 +649,6 @@ int s_client_main(int argc, char **argv)
         NULL;
     char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
     char *sess_in = NULL, *sess_out = NULL, *crl_file = NULL, *p;
         NULL;
     char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
     char *sess_in = NULL, *sess_out = NULL, *crl_file = NULL, *p;
-    char *engine_id = NULL, *ssl_client_engine_id = NULL;
     char *jpake_secret = NULL;
     const char *unix_path = NULL;
     struct sockaddr peer;
     char *jpake_secret = NULL;
     const char *unix_path = NULL;
     struct sockaddr peer;
@@ -674,8 +673,8 @@ int s_client_main(int argc, char **argv)
 #endif
 #ifndef OPENSSL_NO_ENGINE
     ENGINE *ssl_client_engine = NULL;
 #endif
 #ifndef OPENSSL_NO_ENGINE
     ENGINE *ssl_client_engine = NULL;
-    ENGINE *e = NULL;
 #endif
 #endif
+    ENGINE *e = NULL;
 #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE)
     struct timeval tv;
 #endif
 #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE)
     struct timeval tv;
 #endif
@@ -829,10 +828,17 @@ int s_client_main(int argc, char **argv)
 #endif
             break;
         case OPT_ENGINE:
 #endif
             break;
         case OPT_ENGINE:
-            engine_id = opt_arg();
+            e = setup_engine(opt_arg(), 1);
             break;
         case OPT_SSL_CLIENT_ENGINE:
             break;
         case OPT_SSL_CLIENT_ENGINE:
-            ssl_client_engine_id = opt_arg();
+#ifndef OPENSSL_NO_ENGINE
+            ssl_client_engine = ENGINE_by_id(opt_arg());
+            if (ssl_client_engine == NULL) {
+                BIO_printf(bio_err, "Error getting client auth engine\n");
+                goto opthelp;
+            }
+            break;
+#endif
             break;
         case OPT_RAND:
             inrand = opt_arg();
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -1075,17 +1081,6 @@ int s_client_main(int argc, char **argv)
         next_proto.data = NULL;
 #endif
 
         next_proto.data = NULL;
 #endif
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine_id, 1);
-    if (ssl_client_engine_id) {
-        ssl_client_engine = ENGINE_by_id(ssl_client_engine_id);
-        if (ssl_client_engine == NULL) {
-            BIO_printf(bio_err, "Error getting client auth engine\n");
-            goto end;
-        }
-    }
-#endif
-
     if (!app_passwd(passarg, NULL, &pass, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     if (!app_passwd(passarg, NULL, &pass, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
index 8199b888f89485591dc71402318da197082ee24c..3644381ece1d3a4404dc4cda2b2ad78aa0c3d99e 100644 (file)
@@ -1378,7 +1378,7 @@ int s_server_main(int argc, char *argv[])
             session_id_prefix = opt_arg();
             break;
         case OPT_ENGINE:
             session_id_prefix = opt_arg();
             break;
         case OPT_ENGINE:
-            engine_id = opt_arg();
+            e = setup_engine(opt_arg(), 1);
             break;
         case OPT_RAND:
             inrand = opt_arg();
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -1449,10 +1449,6 @@ int s_server_main(int argc, char *argv[])
     }
 #endif
 
     }
 #endif
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine_id, 1);
-#endif
-
     if (!app_passwd(passarg, dpassarg, &pass, &dpass)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     if (!app_passwd(passarg, dpassarg, &pass, &dpass)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
index 532446f49ff6778e30dcb69970f0ffe0e897e1e7..0c683f5b3c2446e84bf3a72aaf05fe01f5d3182a 100644 (file)
@@ -164,7 +164,7 @@ int smime_main(int argc, char **argv)
     X509_VERIFY_PARAM *vpm = NULL;
     const EVP_CIPHER *cipher = NULL;
     const EVP_MD *sign_md = NULL;
     X509_VERIFY_PARAM *vpm = NULL;
     const EVP_CIPHER *cipher = NULL;
     const EVP_MD *sign_md = NULL;
-    char *CAfile = NULL, *CApath = NULL, *inrand = NULL, *engine = NULL;
+    char *CAfile = NULL, *CApath = NULL, *inrand = NULL;
     char *certfile = NULL, *keyfile = NULL, *contfile = NULL, *prog;
     char *infile = NULL, *outfile = NULL, *signerfile = NULL, *recipfile =
         NULL;
     char *certfile = NULL, *keyfile = NULL, *contfile = NULL, *prog;
     char *infile = NULL, *outfile = NULL, *signerfile = NULL, *recipfile =
         NULL;
@@ -177,9 +177,7 @@ int smime_main(int argc, char **argv)
     int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform =
         FORMAT_PEM;
     int vpmtouched = 0, rv = 0;
     int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform =
         FORMAT_PEM;
     int vpmtouched = 0, rv = 0;
-#ifndef OPENSSL_NO_ENGINE
     ENGINE *e = NULL;
     ENGINE *e = NULL;
-#endif
 
     if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
         return 1;
 
     if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
         return 1;
@@ -276,7 +274,7 @@ int smime_main(int argc, char **argv)
             need_rand = 1;
             break;
         case OPT_ENGINE:
             need_rand = 1;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
             break;
         case OPT_PASSIN:
             passinarg = opt_arg();
@@ -408,10 +406,6 @@ int smime_main(int argc, char **argv)
     } else if (!operation)
         goto opthelp;
 
     } else if (!operation)
         goto opthelp;
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
-
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     if (!app_passwd(passinarg, NULL, &passin, NULL)) {
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
index 1a01d333b7f8752f5f30f266e9b109a262b6afbc..57587053ccf60457025b1c309fc431b986895f15 100644 (file)
@@ -835,11 +835,9 @@ int speed_main(int argc, char **argv)
         case OPT_DECRYPT:
             decrypt = 1;
             break;
         case OPT_DECRYPT:
             decrypt = 1;
             break;
-#ifndef OPENSSL_NO_ENGINE
         case OPT_ENGINE:
         case OPT_ENGINE:
-            setup_engine(opt_arg(), 0);
+            (void)setup_engine(opt_arg(), 0);
             break;
             break;
-#endif
 #ifndef NO_FORK
         case OPT_MULTI:
             multi = atoi(opt_arg());
 #ifndef NO_FORK
         case OPT_MULTI:
             multi = atoi(opt_arg());
index ee2e5969f01b01bd8c77ba328057653687dbfd45..7ceff9feca1427e5984c771e4124050864fe697e 100644 (file)
@@ -100,7 +100,7 @@ int spkac_main(int argc, char **argv)
     ENGINE *e = NULL;
     EVP_PKEY *pkey = NULL;
     NETSCAPE_SPKI *spki = NULL;
     ENGINE *e = NULL;
     EVP_PKEY *pkey = NULL;
     NETSCAPE_SPKI *spki = NULL;
-    char *challenge = NULL, *keyfile = NULL, *engine = NULL;
+    char *challenge = NULL, *keyfile = NULL;
     char *infile = NULL, *outfile = NULL, *passinarg = NULL, *passin = NULL;
     char *spkstr = NULL, *prog;
     const char *spkac = "SPKAC", *spksect = "default";
     char *infile = NULL, *outfile = NULL, *passinarg = NULL, *passin = NULL;
     char *spkstr = NULL, *prog;
     const char *spkac = "SPKAC", *spksect = "default";
@@ -149,9 +149,8 @@ int spkac_main(int argc, char **argv)
             spksect = opt_arg();
             break;
         case OPT_ENGINE:
             spksect = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
             break;
-
         }
     }
     argc = opt_num_rest();
         }
     }
     argc = opt_num_rest();
@@ -161,9 +160,6 @@ int spkac_main(int argc, char **argv)
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     }
         BIO_printf(bio_err, "Error getting password\n");
         goto end;
     }
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
 
     if (keyfile) {
         pkey = load_key(strcmp(keyfile, "-") ? keyfile : NULL,
 
     if (keyfile) {
         pkey = load_key(strcmp(keyfile, "-") ? keyfile : NULL,
@@ -194,7 +190,6 @@ int spkac_main(int argc, char **argv)
 
     conf = NCONF_new(NULL);
     i = NCONF_load_bio(conf, in, NULL);
 
     conf = NCONF_new(NULL);
     i = NCONF_load_bio(conf, in, NULL);
-
     if (!i) {
         BIO_printf(bio_err, "Error parsing config file\n");
         ERR_print_errors(bio_err);
     if (!i) {
         BIO_printf(bio_err, "Error parsing config file\n");
         ERR_print_errors(bio_err);
index bacd6701855bc529cc19a94a5ba8da961cde1496..0585952440b6098d3be5f8609f0a712b0a9144cf 100644 (file)
@@ -272,7 +272,7 @@ int srp_main(int argc, char **argv)
     int mode = OPT_ERR;
     char *user = NULL, *passinarg = NULL, *passoutarg = NULL;
     char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL;
     int mode = OPT_ERR;
     char *user = NULL, *passinarg = NULL, *passoutarg = NULL;
     char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL;
-    char *randfile = NULL, *engine = NULL, *tofree = NULL, *section = NULL;
+    char *randfile = NULL, *tofree = NULL, *section = NULL;
     char **gNrow = NULL, *configfile = NULL, *dbfile = NULL, **pp, *prog;
     long errorline = -1;
     OPTION_CHOICE o;
     char **gNrow = NULL, *configfile = NULL, *dbfile = NULL, **pp, *prog;
     long errorline = -1;
     OPTION_CHOICE o;
@@ -332,7 +332,7 @@ int srp_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            (void)setup_engine(opt_arg(), 0);
             break;
         }
     }
             break;
         }
     }
@@ -359,9 +359,6 @@ int srp_main(int argc, char **argv)
                    "-passin, -passout arguments only valid with one user.\n");
         goto opthelp;
     }
                    "-passin, -passout arguments only valid with one user.\n");
         goto opthelp;
     }
-# ifndef OPENSSL_NO_ENGINE
-    setup_engine(engine, 0);
-# endif
 
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
 
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
index 61e85ce87e89de54a486af863a31cd57206b8fee..35085e73563ad9bd2b3fd9e6bdbf20ad1f89d20b 100644 (file)
@@ -105,7 +105,7 @@ int verify_main(int argc, char **argv)
     STACK_OF(X509_CRL) *crls = NULL;
     X509_STORE *store = NULL;
     X509_VERIFY_PARAM *vpm = NULL;
     STACK_OF(X509_CRL) *crls = NULL;
     X509_STORE *store = NULL;
     X509_VERIFY_PARAM *vpm = NULL;
-    char *prog, *CApath = NULL, *CAfile = NULL, *engine = NULL;
+    char *prog, *CApath = NULL, *CAfile = NULL;
     char *untfile = NULL, *trustfile = NULL, *crlfile = NULL;
     int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
     OPTION_CHOICE o;
     char *untfile = NULL, *trustfile = NULL, *crlfile = NULL;
     int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
     OPTION_CHOICE o;
@@ -167,7 +167,7 @@ int verify_main(int argc, char **argv)
             show_chain = 1;
             break;
         case OPT_ENGINE:
             show_chain = 1;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_VERBOSE:
             v_verbose = 1;
             break;
         case OPT_VERBOSE:
             v_verbose = 1;
@@ -177,9 +177,6 @@ int verify_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
     argc = opt_num_rest();
     argv = opt_rest();
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
     if (!(store = setup_verify(CAfile, CApath)))
         goto end;
     X509_STORE_set_verify_cb(store, cb);
     if (!(store = setup_verify(CAfile, CApath)))
         goto end;
     X509_STORE_set_verify_cb(store, cb);
index 903e6b94b9dcc2404310745dc424de9a6e7257a8..e1cc3cde1fca2c85e4708ddbe7f9e921ef5a76a0 100644 (file)
@@ -220,25 +220,20 @@ int x509_main(int argc, char **argv)
     char *checkhost = NULL, *checkemail = NULL, *checkip = NULL;
     char *extsect = NULL, *extfile = NULL, *passin = NULL, *passinarg = NULL;
     char *infile = NULL, *outfile = NULL, *keyfile = NULL, *CAfile = NULL;
     char *checkhost = NULL, *checkemail = NULL, *checkip = NULL;
     char *extsect = NULL, *extfile = NULL, *passin = NULL, *passinarg = NULL;
     char *infile = NULL, *outfile = NULL, *keyfile = NULL, *CAfile = NULL;
-    char buf[256];
-    char *engine = NULL, *prog;
-    int C = 0, x509req = 0, days = DEF_DAYS, modulus = 0, pubkey = 0, pprint =
-        0;
-    int CAformat = FORMAT_PEM, CAkeyformat = FORMAT_PEM;
-    int fingerprint = 0, reqfile = 0, need_rand = 0, checkend =
-        0, checkoffset = 0;
+    char buf[256], *prog;
+    int x509req = 0, days = DEF_DAYS, modulus = 0, pubkey = 0, pprint = 0;
+    int C = 0, CAformat = FORMAT_PEM, CAkeyformat = FORMAT_PEM;
+    int fingerprint = 0, reqfile = 0, need_rand = 0, checkend = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM;
     int next_serial = 0, subject_hash = 0, issuer_hash = 0, ocspid = 0;
     int noout = 0, sign_flag = 0, CA_flag = 0, CA_createserial = 0, email = 0;
     int ocsp_uri = 0, trustout = 0, clrtrust = 0, clrreject = 0, aliasout = 0;
     int ret = 1, i, num = 0, badsig = 0, clrext = 0, nocert = 0;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM;
     int next_serial = 0, subject_hash = 0, issuer_hash = 0, ocspid = 0;
     int noout = 0, sign_flag = 0, CA_flag = 0, CA_createserial = 0, email = 0;
     int ocsp_uri = 0, trustout = 0, clrtrust = 0, clrreject = 0, aliasout = 0;
     int ret = 1, i, num = 0, badsig = 0, clrext = 0, nocert = 0;
-    int text = 0, serial = 0, subject = 0, issuer = 0, startdate =
-        0, enddate = 0;
+    int text = 0, serial = 0, subject = 0, issuer = 0, startdate = 0;
+    int checkoffset = 0, enddate = 0;
     unsigned long nmflag = 0, certflag = 0;
     OPTION_CHOICE o;
     unsigned long nmflag = 0, certflag = 0;
     OPTION_CHOICE o;
-#ifndef OPENSSL_NO_ENGINE
     ENGINE *e = NULL;
     ENGINE *e = NULL;
-#endif
 #ifndef OPENSSL_NO_MD5
     int subject_hash_old = 0, issuer_hash_old = 0;
 #endif
 #ifndef OPENSSL_NO_MD5
     int subject_hash_old = 0, issuer_hash_old = 0;
 #endif
@@ -374,7 +369,7 @@ int x509_main(int argc, char **argv)
                 goto opthelp;
             break;
         case OPT_ENGINE:
                 goto opthelp;
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_C:
             C = ++num;
             break;
         case OPT_C:
             C = ++num;
@@ -498,10 +493,6 @@ int x509_main(int argc, char **argv)
     if (out == NULL)
         goto end;
 
     if (out == NULL)
         goto end;
 
-#ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-#endif
-
     if (need_rand)
         app_RAND_load_file(NULL, 0);
 
     if (need_rand)
         app_RAND_load_file(NULL, 0);