1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/tsrc/topenssl/inc/apps.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,354 @@
1.4 +/* apps/apps.h */
1.5 +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
1.6 + * All rights reserved.
1.7 + *
1.8 + * This package is an SSL implementation written
1.9 + * by Eric Young (eay@cryptsoft.com).
1.10 + * The implementation was written so as to conform with Netscapes SSL.
1.11 + *
1.12 + * This library is free for commercial and non-commercial use as long as
1.13 + * the following conditions are aheared to. The following conditions
1.14 + * apply to all code found in this distribution, be it the RC4, RSA,
1.15 + * lhash, DES, etc., code; not just the SSL code. The SSL documentation
1.16 + * included with this distribution is covered by the same copyright terms
1.17 + * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1.18 + *
1.19 + * Copyright remains Eric Young's, and as such any Copyright notices in
1.20 + * the code are not to be removed.
1.21 + * If this package is used in a product, Eric Young should be given attribution
1.22 + * as the author of the parts of the library used.
1.23 + * This can be in the form of a textual message at program startup or
1.24 + * in documentation (online or textual) provided with the package.
1.25 + *
1.26 + * Redistribution and use in source and binary forms, with or without
1.27 + * modification, are permitted provided that the following conditions
1.28 + * are met:
1.29 + * 1. Redistributions of source code must retain the copyright
1.30 + * notice, this list of conditions and the following disclaimer.
1.31 + * 2. Redistributions in binary form must reproduce the above copyright
1.32 + * notice, this list of conditions and the following disclaimer in the
1.33 + * documentation and/or other materials provided with the distribution.
1.34 + * 3. All advertising materials mentioning features or use of this software
1.35 + * must display the following acknowledgement:
1.36 + * "This product includes cryptographic software written by
1.37 + * Eric Young (eay@cryptsoft.com)"
1.38 + * The word 'cryptographic' can be left out if the rouines from the library
1.39 + * being used are not cryptographic related :-).
1.40 + * 4. If you include any Windows specific code (or a derivative thereof) from
1.41 + * the apps directory (application code) you must include an acknowledgement:
1.42 + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
1.43 + *
1.44 + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
1.45 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.46 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.47 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1.48 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.49 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.50 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.51 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.52 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.53 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.54 + * SUCH DAMAGE.
1.55 + *
1.56 + * The licence and distribution terms for any publically available version or
1.57 + * derivative of this code cannot be changed. i.e. this code cannot simply be
1.58 + * copied and put under another distribution licence
1.59 + * [including the GNU Public Licence.]
1.60 + */
1.61 +/* ====================================================================
1.62 + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
1.63 + *
1.64 + * Redistribution and use in source and binary forms, with or without
1.65 + * modification, are permitted provided that the following conditions
1.66 + * are met:
1.67 + *
1.68 + * 1. Redistributions of source code must retain the above copyright
1.69 + * notice, this list of conditions and the following disclaimer.
1.70 + *
1.71 + * 2. Redistributions in binary form must reproduce the above copyright
1.72 + * notice, this list of conditions and the following disclaimer in
1.73 + * the documentation and/or other materials provided with the
1.74 + * distribution.
1.75 + *
1.76 + * 3. All advertising materials mentioning features or use of this
1.77 + * software must display the following acknowledgment:
1.78 + * "This product includes software developed by the OpenSSL Project
1.79 + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
1.80 + *
1.81 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.82 + * endorse or promote products derived from this software without
1.83 + * prior written permission. For written permission, please contact
1.84 + * openssl-core@openssl.org.
1.85 + *
1.86 + * 5. Products derived from this software may not be called "OpenSSL"
1.87 + * nor may "OpenSSL" appear in their names without prior written
1.88 + * permission of the OpenSSL Project.
1.89 + *
1.90 + * 6. Redistributions of any form whatsoever must retain the following
1.91 + * acknowledgment:
1.92 + * "This product includes software developed by the OpenSSL Project
1.93 + * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
1.94 + *
1.95 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.96 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.97 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.98 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.99 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.100 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.101 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.102 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.103 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.104 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.105 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.106 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.107 + * ====================================================================
1.108 + *
1.109 + * This product includes cryptographic software written by Eric Young
1.110 + * (eay@cryptsoft.com). This product includes software written by Tim
1.111 + * Hudson (tjh@cryptsoft.com).
1.112 + *
1.113 + */
1.114 +
1.115 +#ifndef HEADER_APPS_H
1.116 +#define HEADER_APPS_H
1.117 +#ifndef SYMBIAN
1.118 +#include "../e_os.h"
1.119 +#else
1.120 +#include "e_os.h"
1.121 +#endif
1.122 +
1.123 +
1.124 +#include <openssl/bio.h>
1.125 +#include <openssl/x509.h>
1.126 +#include <openssl/lhash.h>
1.127 +#include <openssl/conf.h>
1.128 +#include <openssl/txt_db.h>
1.129 +#ifndef OPENSSL_NO_ENGINE
1.130 +#include <openssl/engine.h>
1.131 +#endif
1.132 +#include <openssl/ossl_typ.h>
1.133 +
1.134 +int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
1.135 +int app_RAND_write_file(const char *file, BIO *bio_e);
1.136 +/* When `file' is NULL, use defaults.
1.137 + * `bio_e' is for error messages. */
1.138 +void app_RAND_allow_write_file(void);
1.139 +long app_RAND_load_files(char *file); /* `file' is a list of files to read,
1.140 + * separated by LIST_SEPARATOR_CHAR
1.141 + * (see e_os.h). The string is
1.142 + * destroyed! */
1.143 +
1.144 +#ifdef OPENSSL_SYS_WIN32
1.145 +#define rename(from,to) WIN32_rename((from),(to))
1.146 +int WIN32_rename(const char *oldname,const char *newname);
1.147 +#endif
1.148 +
1.149 +#ifndef MONOLITH
1.150 +
1.151 +#define MAIN(a,v) main(a,v)
1.152 +
1.153 +#ifndef NON_MAIN
1.154 +CONF *config=NULL;
1.155 +BIO *bio_err=NULL;
1.156 +#else
1.157 +extern CONF *config;
1.158 +extern BIO *bio_err;
1.159 +#endif
1.160 +
1.161 +#else
1.162 +
1.163 +#define MAIN(a,v) PROG(a,v)
1.164 +extern CONF *config;
1.165 +extern char *default_config_file;
1.166 +extern BIO *bio_err;
1.167 +
1.168 +#endif
1.169 +
1.170 +#ifndef SYMBIAN
1.171 +#ifndef OPENSSL_SYS_NETWARE
1.172 +#include <signal.h>
1.173 +#endif
1.174 +#endif
1.175 +
1.176 +#ifndef SYMBIAN
1.177 +#ifdef SIGPIPE
1.178 +#define do_pipe_sig() signal(SIGPIPE,SIG_IGN)
1.179 +#else
1.180 +#define do_pipe_sig()
1.181 +#endif
1.182 +#else
1.183 +#define do_pipe_sig()
1.184 +#endif
1.185 +#if defined(MONOLITH) && !defined(OPENSSL_C)
1.186 +# define apps_startup() \
1.187 + do_pipe_sig()
1.188 +# define apps_shutdown()
1.189 +#else
1.190 +# ifndef OPENSSL_NO_ENGINE
1.191 +# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
1.192 + defined(OPENSSL_SYS_WIN32)
1.193 +# ifdef _O_BINARY
1.194 +# define apps_startup() \
1.195 + do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
1.196 + ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
1.197 + ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
1.198 +# else
1.199 +# define apps_startup() \
1.200 + do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
1.201 + ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
1.202 + ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
1.203 +# endif
1.204 +# else
1.205 +# define apps_startup() \
1.206 + do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \
1.207 + ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); \
1.208 + setup_ui_method(); } while(0)
1.209 +# endif
1.210 +# define apps_shutdown() \
1.211 + do { CONF_modules_unload(1); destroy_ui_method(); \
1.212 + EVP_cleanup(); ENGINE_cleanup(); \
1.213 + CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
1.214 + ERR_free_strings(); } while(0)
1.215 +# else
1.216 +# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
1.217 + defined(OPENSSL_SYS_WIN32)
1.218 +# ifdef _O_BINARY
1.219 +# define apps_startup() \
1.220 + do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
1.221 + ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
1.222 + setup_ui_method(); } while(0)
1.223 +# else
1.224 +# define apps_startup() \
1.225 + do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
1.226 + ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
1.227 + setup_ui_method(); } while(0)
1.228 +# endif
1.229 +# else
1.230 +# define apps_startup() \
1.231 + do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \
1.232 + ERR_load_crypto_strings(); \
1.233 + setup_ui_method(); } while(0)
1.234 +# endif
1.235 +# define apps_shutdown() \
1.236 + do { CONF_modules_unload(1); destroy_ui_method(); \
1.237 + EVP_cleanup(); \
1.238 + CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
1.239 + ERR_free_strings(); } while(0)
1.240 +# endif
1.241 +#endif
1.242 +
1.243 +typedef struct args_st
1.244 + {
1.245 + char **data;
1.246 + int count;
1.247 + } ARGS;
1.248 +
1.249 +#define PW_MIN_LENGTH 4
1.250 +typedef struct pw_cb_data
1.251 + {
1.252 + const void *password;
1.253 + const char *prompt_info;
1.254 + } PW_CB_DATA;
1.255 +
1.256 +int password_callback(char *buf, int bufsiz, int verify,
1.257 + PW_CB_DATA *cb_data);
1.258 +
1.259 +int setup_ui_method(void);
1.260 +void destroy_ui_method(void);
1.261 +
1.262 +int should_retry(int i);
1.263 +int args_from_file(char *file, int *argc, char **argv[]);
1.264 +int str2fmt(char *s);
1.265 +void program_name(char *in,char *out,int size);
1.266 +int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
1.267 +#ifdef HEADER_X509_H
1.268 +int dump_cert_text(BIO *out, X509 *x);
1.269 +void print_name(BIO *out, const char *title, X509_NAME *nm, unsigned long lflags);
1.270 +#endif
1.271 +int set_cert_ex(unsigned long *flags, const char *arg);
1.272 +int set_name_ex(unsigned long *flags, const char *arg);
1.273 +int set_ext_copy(int *copy_type, const char *arg);
1.274 +int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
1.275 +int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
1.276 +int add_oid_section(BIO *err, CONF *conf);
1.277 +X509 *load_cert(BIO *err, const char *file, int format,
1.278 + const char *pass, ENGINE *e, const char *cert_descrip);
1.279 +EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
1.280 + const char *pass, ENGINE *e, const char *key_descrip);
1.281 +EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
1.282 + const char *pass, ENGINE *e, const char *key_descrip);
1.283 +STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
1.284 + const char *pass, ENGINE *e, const char *cert_descrip);
1.285 +X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
1.286 +#ifndef OPENSSL_NO_ENGINE
1.287 +ENGINE *setup_engine(BIO *err, const char *engine, int debug);
1.288 +#endif
1.289 +
1.290 +int load_config(BIO *err, CONF *cnf);
1.291 +char *make_config_name(void);
1.292 +
1.293 +/* Functions defined in ca.c and also used in ocsp.c */
1.294 +int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
1.295 + ASN1_GENERALIZEDTIME **pinvtm, const char *str);
1.296 +
1.297 +#define DB_type 0
1.298 +#define DB_exp_date 1
1.299 +#define DB_rev_date 2
1.300 +#define DB_serial 3 /* index - unique */
1.301 +#define DB_file 4
1.302 +#define DB_name 5 /* index - unique when active and not disabled */
1.303 +#define DB_NUMBER 6
1.304 +
1.305 +#define DB_TYPE_REV 'R'
1.306 +#define DB_TYPE_EXP 'E'
1.307 +#define DB_TYPE_VAL 'V'
1.308 +
1.309 +typedef struct db_attr_st
1.310 + {
1.311 + int unique_subject;
1.312 + } DB_ATTR;
1.313 +typedef struct ca_db_st
1.314 + {
1.315 + DB_ATTR attributes;
1.316 + TXT_DB *db;
1.317 + } CA_DB;
1.318 +
1.319 +BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai);
1.320 +int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **retai);
1.321 +int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix);
1.322 +int rand_serial(BIGNUM *b, ASN1_INTEGER *ai);
1.323 +CA_DB *load_index(char *dbfile, DB_ATTR *dbattr);
1.324 +int index_index(CA_DB *db);
1.325 +int save_index(const char *dbfile, const char *suffix, CA_DB *db);
1.326 +int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix);
1.327 +void free_index(CA_DB *db);
1.328 +int index_name_cmp(const char **a, const char **b);
1.329 +int parse_yesno(const char *str, int def);
1.330 +
1.331 +X509_NAME *parse_name(char *str, long chtype, int multirdn);
1.332 +int args_verify(char ***pargs, int *pargc,
1.333 + int *badarg, BIO *err, X509_VERIFY_PARAM **pm);
1.334 +void policies_print(BIO *out, X509_STORE_CTX *ctx);
1.335 +
1.336 +#define FORMAT_UNDEF 0
1.337 +#define FORMAT_ASN1 1
1.338 +#define FORMAT_TEXT 2
1.339 +#define FORMAT_PEM 3
1.340 +#define FORMAT_NETSCAPE 4
1.341 +#define FORMAT_PKCS12 5
1.342 +#define FORMAT_SMIME 6
1.343 +#define FORMAT_ENGINE 7
1.344 +#define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid
1.345 + * adding yet another param to load_*key() */
1.346 +
1.347 +#define EXT_COPY_NONE 0
1.348 +#define EXT_COPY_ADD 1
1.349 +#define EXT_COPY_ALL 2
1.350 +
1.351 +#define NETSCAPE_CERT_HDR "certificate"
1.352 +
1.353 +#define APP_PASS_LEN 1024
1.354 +
1.355 +#define SERIAL_RAND_BITS 64
1.356 +
1.357 +#endif