Dont forget req.
[oweals/openssl.git] / apps / smime.c
index b05bd704e88715a825c5e1fc1e5a2895f51183c5..cc248d377bb4a39b6b76a82e8f4317753f47f138 100644 (file)
@@ -104,7 +104,9 @@ int MAIN(int argc, char **argv)
        int need_rand = 0;
        int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
         int keyform = FORMAT_PEM;
+#ifndef OPENSSL_NO_ENGINE
        char *engine=NULL;
+#endif
 
        args = argv + 1;
        ret = 1;
@@ -176,11 +178,13 @@ int MAIN(int argc, char **argv)
                                inrand = *args;
                        } else badarg = 1;
                        need_rand = 1;
+#ifndef OPENSSL_NO_ENGINE
                } else if (!strcmp(*args,"-engine")) {
                        if (args[1]) {
                                args++;
                                engine = *args;
                        } else badarg = 1;
+#endif
                } else if (!strcmp(*args,"-passin")) {
                        if (args[1]) {
                                args++;
@@ -330,7 +334,9 @@ int MAIN(int argc, char **argv)
                BIO_printf (bio_err, "-CAfile file   trusted certificates file\n");
                BIO_printf (bio_err, "-crl_check     check revocation status of signer's certificate using CRLs\n");
                BIO_printf (bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
+#ifndef OPENSSL_NO_ENGINE
                BIO_printf (bio_err, "-engine e      use engine e, possibly a hardware device.\n");
+#endif
                BIO_printf (bio_err, "-passin arg    input file pass phrase source\n");
                BIO_printf(bio_err,  "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
                BIO_printf(bio_err,  "               load the file (or the files in the directory) into\n");
@@ -339,7 +345,9 @@ int MAIN(int argc, char **argv)
                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");
@@ -428,7 +436,7 @@ int MAIN(int argc, char **argv)
        } else keyfile = NULL;
 
        if(keyfile) {
-               key = load_key(bio_err, keyfile, keyform, passin, e,
+               key = load_key(bio_err, keyfile, keyform, 0, passin, e,
                               "signing key file");
                if (!key) {
                        goto end;
@@ -471,7 +479,10 @@ int MAIN(int argc, char **argv)
                p7 = PKCS7_encrypt(encerts, in, cipher, flags);
        } else if(operation == SMIME_SIGN) {
                p7 = PKCS7_sign(signer, key, other, in, flags);
-               BIO_reset(in);
+               if (BIO_reset(in) != 0 && (flags & PKCS7_DETACHED)) {
+                 BIO_printf(bio_err, "Can't rewind input file\n");
+                 goto end;
+               }
        } else {
                if(informat == FORMAT_SMIME) 
                        p7 = SMIME_read_PKCS7(in, &indata);