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;
cipher = EVP_rc2_64_cbc();
#endif
#ifndef OPENSSL_NO_AES
- else if (!strcmp(*argv,"-aes128") == 0)
+ else if (!strcmp(*args,"-aes128"))
cipher = EVP_aes_128_cbc();
- else if (!strcmp(*argv,"-aes192") == 0)
+ else if (!strcmp(*args,"-aes192"))
cipher = EVP_aes_192_cbc();
- else if (!strcmp(*argv,"-aes256") == 0)
+ else if (!strcmp(*args,"-aes256"))
cipher = EVP_aes_256_cbc();
#endif
else if (!strcmp (*args, "-text"))
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);
} 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);