smime.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* smime.c */
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
* project 1999.
*/
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef SOLARIS_OPENSSL
#include <dlfcn.h>
#endif /* SOLARIS_OPENSSL */
#include <stdio.h>
#include <string.h>
#include "apps.h"
#define PROG smime_main
#define SMIME_OP 0x10
#define SMIME_DECRYPT 2
#define SMIME_VERIFY 4
#define SMIME_PK7OUT 5
int MAIN(int, char **);
{
int operation = 0;
int ret = 0;
char **args;
int badarg = 0;
int need_rand = 0;
int keyform = FORMAT_PEM;
#ifndef OPENSSL_NO_ENGINE
#endif
ret = 1;
apps_startup();
goto end;
#ifndef OPENSSL_NO_DES
cipher = EVP_des_ede3_cbc();
cipher = EVP_des_cbc();
#endif
#ifndef OPENSSL_NO_RC2
cipher = EVP_rc2_40_cbc();
cipher = EVP_rc2_cbc();
cipher = EVP_rc2_64_cbc();
#endif
#ifndef OPENSSL_NO_AES
cipher = EVP_aes_128_cbc();
#ifdef SOLARIS_OPENSSL
{
{
goto end;
}
}
{
{
goto end;
}
}
#else
cipher = EVP_aes_192_cbc();
cipher = EVP_aes_256_cbc();
#endif /* SOLARIS_OPENSSL */
#endif
flags |= PKCS7_TEXT;
flags |= PKCS7_NOINTERN;
flags |= PKCS7_NOVERIFY;
flags |= PKCS7_NOCHAIN;
flags |= PKCS7_NOCERTS;
flags |= PKCS7_NOATTR;
flags &= ~PKCS7_DETACHED;
flags |= PKCS7_BINARY;
flags |= PKCS7_NOSIGS;
flags |= PKCS7_CRLFEOL;
if (args[1]) {
args++;
} else badarg = 1;
need_rand = 1;
#ifndef OPENSSL_NO_ENGINE
if (args[1]) {
args++;
} else badarg = 1;
#endif
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
signerfile = *args;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
if (args[1]) {
args++;
} else badarg = 1;
} else badarg = 1;
args++;
}
if(operation == SMIME_SIGN) {
if(!signerfile) {
badarg = 1;
}
need_rand = 1;
} else if(operation == SMIME_DECRYPT) {
if(!recipfile) {
badarg = 1;
}
} else if(operation == SMIME_ENCRYPT) {
if(!*args) {
badarg = 1;
}
need_rand = 1;
if (badarg) {
#ifndef OPENSSL_NO_DES
#endif
#ifndef OPENSSL_NO_RC2
#endif
#ifndef OPENSSL_NO_AES
#endif
BIO_printf (bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
#ifndef OPENSSL_NO_ENGINE
#endif
goto end;
}
#ifndef OPENSSL_NO_ENGINE
#endif
goto end;
}
if (need_rand) {
}
ret = 2;
} else {
}
if(operation == SMIME_ENCRYPT) {
if (!cipher) {
#ifndef OPENSSL_NO_RC2
cipher = EVP_rc2_40_cbc();
#else
goto end;
#endif
}
encerts = sk_X509_new_null();
while (*args) {
NULL, e, "recipient certificate file"))) {
#if 0 /* An appropriate message is already printed */
#endif
goto end;
}
args++;
}
}
e, "signer certificate"))) {
#if 0 /* An appropri message has already been printed */
#endif
goto end;
}
}
if(certfile) {
e, "certificate file"))) {
#if 0 /* An appropriate message has already been printed */
#endif
goto end;
}
}
e, "recipient certificate file"))) {
#if 0 /* An appropriate message has alrady been printed */
#endif
goto end;
}
}
if(operation == SMIME_DECRYPT) {
} else if(operation == SMIME_SIGN) {
if(keyfile) {
"signing key file");
if (!key) {
goto end;
}
}
if (infile) {
"Can't open input file %s\n", infile);
goto end;
}
if (outfile) {
"Can't open output file %s\n", outfile);
goto end;
}
} else {
#ifdef OPENSSL_SYS_VMS
{
}
#endif
}
if(operation == SMIME_VERIFY) {
}
ret = 3;
if(operation == SMIME_ENCRYPT) {
} else if(operation == SMIME_SIGN) {
goto end;
}
} else {
if(informat == FORMAT_SMIME)
else if(informat == FORMAT_PEM)
else if(informat == FORMAT_ASN1)
else {
goto end;
}
if(!p7) {
goto end;
}
if(contfile) {
goto end;
}
}
}
if(!p7) {
goto end;
}
ret = 4;
if(operation == SMIME_DECRYPT) {
goto end;
}
} else if(operation == SMIME_VERIFY) {
} else {
goto end;
}
ret = 5;
goto end;
}
} else if(operation == SMIME_PK7OUT) {
} else {
if(outformat == FORMAT_SMIME)
else if(outformat == FORMAT_PEM)
else if(outformat == FORMAT_ASN1)
else {
goto end;
}
}
ret = 0;
end:
if (need_rand)
PKCS7_free(p7);
return (ret);
}
{
int i;
if(!signerfile) return 1;
if(!tmp) return 0;
for(i = 0; i < sk_X509_num(signers); i++)
return 1;
}