apps.h 6.5 KB
Newer Older
1
/* apps/apps.h */
2
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * 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 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 the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
 * ANY EXPRESS 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 AUTHOR OR 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_APPS_H
#define HEADER_APPS_H

62
#include "e_os.h"
63

64 65 66
#include <openssl/buffer.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
D
 
Dr. Stephen Henson 已提交
67
#include <openssl/x509.h>
68
#include <openssl/lhash.h>
69
#include <openssl/conf.h>
70
#include <openssl/engine.h>
71

72 73 74 75 76 77 78 79 80 81
int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
int app_RAND_write_file(const char *file, BIO *bio_e);
/* When `file' is NULL, use defaults.
 * `bio_e' is for error messages. */
void app_RAND_allow_write_file(void);
long app_RAND_load_files(char *file); /* `file' is a list of files to read,
                                       * separated by LIST_SEPARATOR_CHAR
                                       * (see e_os.h).  The string is
                                       * destroyed! */

82
#ifdef OPENSSL_NO_STDIO
83 84 85
BIO_METHOD *BIO_s_file();
#endif

86
#ifdef OPENSSL_SYS_WIN32
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
#define rename(from,to) WIN32_rename((from),(to))
int WIN32_rename(char *oldname,char *newname);
#endif

#ifndef MONOLITH

#define MAIN(a,v)	main(a,v)

#ifndef NON_MAIN
BIO *bio_err=NULL;
#else
extern BIO *bio_err;
#endif

#else

#define MAIN(a,v)	PROG(a,v)
extern LHASH *config;
extern char *default_config_file;
extern BIO *bio_err;

#endif

#include <signal.h>

#ifdef SIGPIPE
#define do_pipe_sig()	signal(SIGPIPE,SIG_IGN)
#else
#define do_pipe_sig()
#endif

118
#if defined(MONOLITH) && !defined(OPENSSL_C)
119 120
#  define apps_startup()	do_pipe_sig()
#else
121 122
#  if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
   defined(OPENSSL_SYS_WIN32)
123 124 125
#    ifdef _O_BINARY
#      define apps_startup() \
		_fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
126
		OpenSSL_add_all_algorithms(); ENGINE_load_builtin_engines()
127 128 129
#    else
#      define apps_startup() \
		_fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
130
		OpenSSL_add_all_algorithms(); ENGINE_load_builtin_engines()
131 132
#    endif
#  else
133
#    define apps_startup() \
134
		do_pipe_sig(); OpenSSL_add_all_algorithms(); \
135
		ENGINE_load_builtin_engines()
136 137 138 139
#  endif
#endif

typedef struct args_st
140 141
	{
	char **data;
142
	int count;
143
	} ARGS;
144 145 146 147 148 149

int should_retry(int i);
int args_from_file(char *file, int *argc, char **argv[]);
int str2fmt(char *s);
void program_name(char *in,char *out,int size);
int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
D
 
Dr. Stephen Henson 已提交
150 151
#ifdef HEADER_X509_H
int dump_cert_text(BIO *out, X509 *x);
D
 
Dr. Stephen Henson 已提交
152
void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags);
D
 
Dr. Stephen Henson 已提交
153
#endif
154
int set_cert_ex(unsigned long *flags, const char *arg);
D
 
Dr. Stephen Henson 已提交
155
int set_name_ex(unsigned long *flags, const char *arg);
156 157
int set_ext_copy(int *copy_type, const char *arg);
int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
D
Dr. Stephen Henson 已提交
158
int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
159 160
int add_oid_section(BIO *err, LHASH *conf);
X509 *load_cert(BIO *err, char *file, int format);
161 162
EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass, ENGINE *e);
EVP_PKEY *load_pubkey(BIO *err, char *file, int format, ENGINE *e);
163
STACK_OF(X509) *load_certs(BIO *err, char *file, int format);
D
 
Dr. Stephen Henson 已提交
164
X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
165

166 167 168 169 170
#define FORMAT_UNDEF    0
#define FORMAT_ASN1     1
#define FORMAT_TEXT     2
#define FORMAT_PEM      3
#define FORMAT_NETSCAPE 4
171
#define FORMAT_PKCS12   5
172
#define FORMAT_SMIME    6
173
#define FORMAT_ENGINE   7
174

175 176 177 178
#define EXT_COPY_NONE	0
#define EXT_COPY_ADD	1
#define EXT_COPY_ALL	2

179
#define NETSCAPE_CERT_HDR	"certificate"
180

D
Dr. Stephen Henson 已提交
181 182
#define APP_PASS_LEN	1024

183
#endif