VMS below version 7 doesn't have strcasecmp, so let's roll our own on VMS.
[openssl.git] / apps / smime.c
index 7c4aac1ef2c5d16f8404ba5867c42eaaea0d3714..ef0e4774644542ffca00bd19158697b7bd69db62 100644 (file)
@@ -109,6 +109,15 @@ int MAIN(int argc, char **argv)
        args = argv + 1;
        ret = 1;
 
+       apps_startup();
+
+       if (bio_err == NULL)
+               if ((bio_err = BIO_new(BIO_s_file())) != NULL)
+                       BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
+
+       if (!load_config(bio_err, NULL))
+               goto end;
+
        while (!badarg && *args && *args[0] == '-') {
                if (!strcmp (*args, "-encrypt")) operation = SMIME_ENCRYPT;
                else if (!strcmp (*args, "-decrypt")) operation = SMIME_DECRYPT;
@@ -128,6 +137,14 @@ int MAIN(int argc, char **argv)
                                cipher = EVP_rc2_cbc();
                else if (!strcmp (*args, "-rc2-64")) 
                                cipher = EVP_rc2_64_cbc();
+#endif
+#ifndef OPENSSL_NO_AES
+               else if (!strcmp(*args,"-aes128"))
+                               cipher = EVP_aes_128_cbc();
+               else if (!strcmp(*args,"-aes192"))
+                               cipher = EVP_aes_192_cbc();
+               else if (!strcmp(*args,"-aes256"))
+                               cipher = EVP_aes_256_cbc();
 #endif
                else if (!strcmp (*args, "-text")) 
                                flags |= PKCS7_TEXT;
@@ -283,6 +300,10 @@ int MAIN(int argc, char **argv)
                BIO_printf (bio_err, "-rc2-40        encrypt with RC2-40 (default)\n");
                BIO_printf (bio_err, "-rc2-64        encrypt with RC2-64\n");
                BIO_printf (bio_err, "-rc2-128       encrypt with RC2-128\n");
+#endif
+#ifndef OPENSSL_NO_AES
+               BIO_printf (bio_err, "-aes128, -aes192, -aes256\n");
+               BIO_printf (bio_err, "               encrypt PEM output with cbc aes\n");
 #endif
                BIO_printf (bio_err, "-nointern      don't search certificates in message for signer\n");
                BIO_printf (bio_err, "-nosigs        don't verify message signature\n");
@@ -407,7 +428,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;
@@ -450,7 +471,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);
@@ -490,9 +514,9 @@ int MAIN(int argc, char **argv)
        } else if(operation == SMIME_VERIFY) {
                STACK_OF(X509) *signers;
                if(PKCS7_verify(p7, other, store, indata, out, flags)) {
-                       BIO_printf(bio_err, "Verification Successful\n");
+                       BIO_printf(bio_err, "Verification successful\n");
                } else {
-                       BIO_printf(bio_err, "Verification Failure\n");
+                       BIO_printf(bio_err, "Verification failure\n");
                        goto end;
                }
                signers = PKCS7_get0_signers(p7, other, flags);