Simplify preprocessor statements.
[openssl.git] / apps / apps.c
index 0190d71ee2e68b29af6c8f1b1850bdff2fc3515f..ca3f557ca2efd3b877eb7f5a96383988034d9749 100644 (file)
@@ -442,7 +442,11 @@ int add_oid_section(BIO *err, LHASH *conf)
        STACK_OF(CONF_VALUE) *sktmp;
        CONF_VALUE *cnf;
        int i;
-       if(!(p=CONF_get_string(conf,NULL,"oid_section"))) return 1;
+       if(!(p=CONF_get_string(conf,NULL,"oid_section")))
+               {
+               ERR_clear_error();
+               return 1;
+               }
        if(!(sktmp = CONF_get_section(conf, p))) {
                BIO_printf(err, "problem loading oid section %s\n", p);
                return 0;
@@ -553,7 +557,7 @@ end:
        return(x);
        }
 
-EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
+EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass, ENGINE *e)
        {
        BIO *key=NULL;
        EVP_PKEY *pkey=NULL;
@@ -563,6 +567,14 @@ EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
                BIO_printf(err,"no keyfile specified\n");
                goto end;
                }
+       if (format == FORMAT_ENGINE)
+               {
+               if (!e)
+                       BIO_printf(bio_err,"no engine specified\n");
+               else
+                       pkey = ENGINE_load_private_key(e, file, pass);
+               goto end;
+               }
        key=BIO_new(BIO_s_file());
        if (key == NULL)
                {
@@ -602,7 +614,7 @@ EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
        return(pkey);
        }
 
-EVP_PKEY *load_pubkey(BIO *err, char *file, int format)
+EVP_PKEY *load_pubkey(BIO *err, char *file, int format, ENGINE *e)
        {
        BIO *key=NULL;
        EVP_PKEY *pkey=NULL;
@@ -612,6 +624,14 @@ EVP_PKEY *load_pubkey(BIO *err, char *file, int format)
                BIO_printf(err,"no keyfile specified\n");
                goto end;
                }
+       if (format == FORMAT_ENGINE)
+               {
+               if (!e)
+                       BIO_printf(bio_err,"no engine specified\n");
+               else
+                       pkey = ENGINE_load_public_key(e, file, NULL);
+               goto end;
+               }
        key=BIO_new(BIO_s_file());
        if (key == NULL)
                {