| OLD | NEW |
| 1 /* apps/apps.h */ | 1 /* apps/apps.h */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn); | 130 int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn); |
| 131 int app_RAND_write_file(const char *file, BIO *bio_e); | 131 int app_RAND_write_file(const char *file, BIO *bio_e); |
| 132 /* When `file' is NULL, use defaults. | 132 /* When `file' is NULL, use defaults. |
| 133 * `bio_e' is for error messages. */ | 133 * `bio_e' is for error messages. */ |
| 134 void app_RAND_allow_write_file(void); | 134 void app_RAND_allow_write_file(void); |
| 135 long app_RAND_load_files(char *file); /* `file' is a list of files to read, | 135 long app_RAND_load_files(char *file); /* `file' is a list of files to read, |
| 136 * separated by LIST_SEPARATOR_CHAR | 136 * separated by LIST_SEPARATOR_CHAR |
| 137 * (see e_os.h). The string is | 137 * (see e_os.h). The string is |
| 138 * destroyed! */ | 138 * destroyed! */ |
| 139 | 139 |
| 140 #ifdef OPENSSL_SYS_WIN32 | |
| 141 #define rename(from,to) WIN32_rename((from),(to)) | |
| 142 int WIN32_rename(const char *oldname,const char *newname); | |
| 143 #endif | |
| 144 | |
| 145 #ifndef MONOLITH | 140 #ifndef MONOLITH |
| 146 | 141 |
| 147 #define MAIN(a,v) main(a,v) | 142 #define MAIN(a,v) main(a,v) |
| 148 | 143 |
| 149 #ifndef NON_MAIN | 144 #ifndef NON_MAIN |
| 150 CONF *config=NULL; | 145 CONF *config=NULL; |
| 151 BIO *bio_err=NULL; | 146 BIO *bio_err=NULL; |
| 152 int in_FIPS_mode=0; | |
| 153 #else | 147 #else |
| 154 extern CONF *config; | 148 extern CONF *config; |
| 155 extern BIO *bio_err; | 149 extern BIO *bio_err; |
| 156 extern int in_FIPS_mode; | |
| 157 #endif | 150 #endif |
| 158 | 151 |
| 159 #else | 152 #else |
| 160 | 153 |
| 161 #define MAIN(a,v) PROG(a,v) | 154 #define MAIN(a,v) PROG(a,v) |
| 162 extern CONF *config; | 155 extern CONF *config; |
| 163 extern char *default_config_file; | 156 extern char *default_config_file; |
| 164 extern BIO *bio_err; | 157 extern BIO *bio_err; |
| 165 extern int in_FIPS_mode; | |
| 166 | 158 |
| 167 #endif | 159 #endif |
| 168 | 160 |
| 169 #ifndef OPENSSL_SYS_NETWARE | 161 #ifndef OPENSSL_SYS_NETWARE |
| 170 #include <signal.h> | 162 #include <signal.h> |
| 171 #endif | 163 #endif |
| 172 | 164 |
| 173 #ifdef SIGPIPE | 165 #ifdef SIGPIPE |
| 174 #define do_pipe_sig() signal(SIGPIPE,SIG_IGN) | 166 #define do_pipe_sig() signal(SIGPIPE,SIG_IGN) |
| 175 #else | 167 #else |
| 176 #define do_pipe_sig() | 168 #define do_pipe_sig() |
| 177 #endif | 169 #endif |
| 178 | 170 |
| 171 #ifdef OPENSSL_NO_COMP |
| 172 #define zlib_cleanup() |
| 173 #else |
| 174 #define zlib_cleanup() COMP_zlib_cleanup() |
| 175 #endif |
| 176 |
| 179 #if defined(MONOLITH) && !defined(OPENSSL_C) | 177 #if defined(MONOLITH) && !defined(OPENSSL_C) |
| 180 # define apps_startup() \ | 178 # define apps_startup() \ |
| 181 do_pipe_sig() | 179 do_pipe_sig() |
| 182 # define apps_shutdown() | 180 # define apps_shutdown() |
| 183 #else | 181 #else |
| 184 # ifndef OPENSSL_NO_ENGINE | 182 # ifndef OPENSSL_NO_ENGINE |
| 185 # if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \ | 183 # define apps_startup() \ |
| 186 defined(OPENSSL_SYS_WIN32) | 184 » » » do { do_pipe_sig(); CRYPTO_malloc_init(); \ |
| 187 # ifdef _O_BINARY | |
| 188 # define apps_startup() \ | |
| 189 » » » do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init
(); \ | |
| 190 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ | 185 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ |
| 191 ENGINE_load_builtin_engines(); setup_ui_method(); } whil
e(0) | 186 ENGINE_load_builtin_engines(); setup_ui_method(); } whil
e(0) |
| 192 # else | |
| 193 # define apps_startup() \ | |
| 194 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(
); \ | |
| 195 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ | |
| 196 ENGINE_load_builtin_engines(); setup_ui_method(); } whil
e(0) | |
| 197 # endif | |
| 198 # else | |
| 199 # define apps_startup() \ | |
| 200 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \ | |
| 201 ERR_load_crypto_strings(); ENGINE_load_builtin_engines()
; \ | |
| 202 setup_ui_method(); } while(0) | |
| 203 # endif | |
| 204 # define apps_shutdown() \ | 187 # define apps_shutdown() \ |
| 205 do { CONF_modules_unload(1); destroy_ui_method(); \ | 188 do { CONF_modules_unload(1); destroy_ui_method(); \ |
| 206 » » » EVP_cleanup(); ENGINE_cleanup(); \ | 189 » » » OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \ |
| 207 » » » CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \ | 190 » » » CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NU
LL); \ |
| 208 » » » ERR_free_strings(); } while(0) | 191 » » » ERR_free_strings(); zlib_cleanup();} while(0) |
| 209 # else | 192 # else |
| 210 # if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \ | 193 # define apps_startup() \ |
| 211 defined(OPENSSL_SYS_WIN32) | 194 » » » do { do_pipe_sig(); CRYPTO_malloc_init(); \ |
| 212 # ifdef _O_BINARY | |
| 213 # define apps_startup() \ | |
| 214 » » » do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init
(); \ | |
| 215 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ | 195 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ |
| 216 setup_ui_method(); } while(0) | 196 setup_ui_method(); } while(0) |
| 217 # else | |
| 218 # define apps_startup() \ | |
| 219 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(
); \ | |
| 220 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms();
\ | |
| 221 setup_ui_method(); } while(0) | |
| 222 # endif | |
| 223 # else | |
| 224 # define apps_startup() \ | |
| 225 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \ | |
| 226 ERR_load_crypto_strings(); \ | |
| 227 setup_ui_method(); } while(0) | |
| 228 # endif | |
| 229 # define apps_shutdown() \ | 197 # define apps_shutdown() \ |
| 230 do { CONF_modules_unload(1); destroy_ui_method(); \ | 198 do { CONF_modules_unload(1); destroy_ui_method(); \ |
| 231 » » » EVP_cleanup(); \ | 199 » » » OBJ_cleanup(); EVP_cleanup(); \ |
| 232 » » » CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \ | 200 » » » CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NU
LL); \ |
| 233 » » » ERR_free_strings(); } while(0) | 201 » » » ERR_free_strings(); zlib_cleanup(); } while(0) |
| 234 # endif | 202 # endif |
| 235 #endif | 203 #endif |
| 236 | 204 |
| 237 #ifdef OPENSSL_SYSNAME_WIN32 | 205 #ifdef OPENSSL_SYSNAME_WIN32 |
| 238 # define openssl_fdset(a,b) FD_SET((unsigned int)a, b) | 206 # define openssl_fdset(a,b) FD_SET((unsigned int)a, b) |
| 239 #else | 207 #else |
| 240 # define openssl_fdset(a,b) FD_SET(a, b) | 208 # define openssl_fdset(a,b) FD_SET(a, b) |
| 241 #endif | 209 #endif |
| 242 | 210 |
| 211 |
| 243 typedef struct args_st | 212 typedef struct args_st |
| 244 { | 213 { |
| 245 char **data; | 214 char **data; |
| 246 int count; | 215 int count; |
| 247 } ARGS; | 216 } ARGS; |
| 248 | 217 |
| 249 #define PW_MIN_LENGTH 4 | 218 #define PW_MIN_LENGTH 4 |
| 250 typedef struct pw_cb_data | 219 typedef struct pw_cb_data |
| 251 { | 220 { |
| 252 const void *password; | 221 const void *password; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 275 int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2); | 244 int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2); |
| 276 int add_oid_section(BIO *err, CONF *conf); | 245 int add_oid_section(BIO *err, CONF *conf); |
| 277 X509 *load_cert(BIO *err, const char *file, int format, | 246 X509 *load_cert(BIO *err, const char *file, int format, |
| 278 const char *pass, ENGINE *e, const char *cert_descrip); | 247 const char *pass, ENGINE *e, const char *cert_descrip); |
| 279 EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, | 248 EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, |
| 280 const char *pass, ENGINE *e, const char *key_descrip); | 249 const char *pass, ENGINE *e, const char *key_descrip); |
| 281 EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, | 250 EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, |
| 282 const char *pass, ENGINE *e, const char *key_descrip); | 251 const char *pass, ENGINE *e, const char *key_descrip); |
| 283 STACK_OF(X509) *load_certs(BIO *err, const char *file, int format, | 252 STACK_OF(X509) *load_certs(BIO *err, const char *file, int format, |
| 284 const char *pass, ENGINE *e, const char *cert_descrip); | 253 const char *pass, ENGINE *e, const char *cert_descrip); |
| 254 STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format, |
| 255 const char *pass, ENGINE *e, const char *cert_descrip); |
| 285 X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath); | 256 X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath); |
| 286 #ifndef OPENSSL_NO_ENGINE | 257 #ifndef OPENSSL_NO_ENGINE |
| 287 ENGINE *setup_engine(BIO *err, const char *engine, int debug); | 258 ENGINE *setup_engine(BIO *err, const char *engine, int debug); |
| 288 #endif | 259 #endif |
| 289 | 260 |
| 290 #ifndef OPENSSL_NO_OCSP | 261 #ifndef OPENSSL_NO_OCSP |
| 291 OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, | 262 OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, |
| 292 char *host, char *path, char *port, int use_ssl, | 263 char *host, char *path, char *port, int use_ssl, |
| 264 STACK_OF(CONF_VALUE) *headers, |
| 293 int req_timeout); | 265 int req_timeout); |
| 294 #endif | 266 #endif |
| 295 | 267 |
| 296 int load_config(BIO *err, CONF *cnf); | 268 int load_config(BIO *err, CONF *cnf); |
| 297 char *make_config_name(void); | 269 char *make_config_name(void); |
| 298 | 270 |
| 299 /* Functions defined in ca.c and also used in ocsp.c */ | 271 /* Functions defined in ca.c and also used in ocsp.c */ |
| 300 int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, | 272 int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, |
| 301 ASN1_GENERALIZEDTIME **pinvtm, const char *str); | 273 ASN1_GENERALIZEDTIME **pinvtm, const char *str); |
| 302 | 274 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 324 | 296 |
| 325 BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai); | 297 BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai); |
| 326 int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **r
etai); | 298 int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **r
etai); |
| 327 int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix); | 299 int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix); |
| 328 int rand_serial(BIGNUM *b, ASN1_INTEGER *ai); | 300 int rand_serial(BIGNUM *b, ASN1_INTEGER *ai); |
| 329 CA_DB *load_index(char *dbfile, DB_ATTR *dbattr); | 301 CA_DB *load_index(char *dbfile, DB_ATTR *dbattr); |
| 330 int index_index(CA_DB *db); | 302 int index_index(CA_DB *db); |
| 331 int save_index(const char *dbfile, const char *suffix, CA_DB *db); | 303 int save_index(const char *dbfile, const char *suffix, CA_DB *db); |
| 332 int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
fix); | 304 int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suf
fix); |
| 333 void free_index(CA_DB *db); | 305 void free_index(CA_DB *db); |
| 334 int index_name_cmp(const char **a, const char **b); | 306 #define index_name_cmp_noconst(a, b) \ |
| 307 » index_name_cmp((const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, a
), \ |
| 308 » (const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, b)) |
| 309 int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b); |
| 335 int parse_yesno(const char *str, int def); | 310 int parse_yesno(const char *str, int def); |
| 336 | 311 |
| 337 X509_NAME *parse_name(char *str, long chtype, int multirdn); | 312 X509_NAME *parse_name(char *str, long chtype, int multirdn); |
| 338 int args_verify(char ***pargs, int *pargc, | 313 int args_verify(char ***pargs, int *pargc, |
| 339 int *badarg, BIO *err, X509_VERIFY_PARAM **pm); | 314 int *badarg, BIO *err, X509_VERIFY_PARAM **pm); |
| 340 void policies_print(BIO *out, X509_STORE_CTX *ctx); | 315 void policies_print(BIO *out, X509_STORE_CTX *ctx); |
| 316 int bio_to_mem(unsigned char **out, int maxlen, BIO *in); |
| 317 int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value); |
| 318 int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, |
| 319 const char *algname, ENGINE *e, int do_param); |
| 320 #ifndef OPENSSL_NO_PSK |
| 321 extern char *psk_key; |
| 322 #endif |
| 341 #ifndef OPENSSL_NO_JPAKE | 323 #ifndef OPENSSL_NO_JPAKE |
| 342 void jpake_client_auth(BIO *out, BIO *conn, const char *secret); | 324 void jpake_client_auth(BIO *out, BIO *conn, const char *secret); |
| 343 void jpake_server_auth(BIO *out, BIO *conn, const char *secret); | 325 void jpake_server_auth(BIO *out, BIO *conn, const char *secret); |
| 344 #endif | 326 #endif |
| 345 | 327 |
| 346 #define FORMAT_UNDEF 0 | 328 #define FORMAT_UNDEF 0 |
| 347 #define FORMAT_ASN1 1 | 329 #define FORMAT_ASN1 1 |
| 348 #define FORMAT_TEXT 2 | 330 #define FORMAT_TEXT 2 |
| 349 #define FORMAT_PEM 3 | 331 #define FORMAT_PEM 3 |
| 350 #define FORMAT_NETSCAPE 4 | 332 #define FORMAT_NETSCAPE 4 |
| 351 #define FORMAT_PKCS12 5 | 333 #define FORMAT_PKCS12 5 |
| 352 #define FORMAT_SMIME 6 | 334 #define FORMAT_SMIME 6 |
| 353 #define FORMAT_ENGINE 7 | 335 #define FORMAT_ENGINE 7 |
| 354 #define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid | 336 #define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid |
| 355 * adding yet another param to load_*key() */ | 337 * adding yet another param to load_*key() */ |
| 338 #define FORMAT_PEMRSA 9 /* PEM RSAPubicKey format */ |
| 339 #define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */ |
| 340 #define FORMAT_MSBLOB 11 /* MS Key blob format */ |
| 341 #define FORMAT_PVK 12 /* MS PVK file format */ |
| 356 | 342 |
| 357 #define EXT_COPY_NONE 0 | 343 #define EXT_COPY_NONE 0 |
| 358 #define EXT_COPY_ADD 1 | 344 #define EXT_COPY_ADD 1 |
| 359 #define EXT_COPY_ALL 2 | 345 #define EXT_COPY_ALL 2 |
| 360 | 346 |
| 361 #define NETSCAPE_CERT_HDR "certificate" | 347 #define NETSCAPE_CERT_HDR "certificate" |
| 362 | 348 |
| 363 #define APP_PASS_LEN 1024 | 349 #define APP_PASS_LEN 1024 |
| 364 | 350 |
| 365 #define SERIAL_RAND_BITS 64 | 351 #define SERIAL_RAND_BITS 64 |
| 366 | 352 |
| 353 int app_isdir(const char *); |
| 354 int raw_read_stdin(void *,int); |
| 355 int raw_write_stdout(const void *,int); |
| 356 |
| 357 #define TM_START 0 |
| 358 #define TM_STOP 1 |
| 359 double app_tminterval (int stop,int usertime); |
| 367 #endif | 360 #endif |
| 361 |
| 362 #ifndef OPENSSL_NO_NEXTPROTONEG |
| 363 unsigned char *next_protos_parse(unsigned short *outlen, const char *in); |
| 364 #endif |
| OLD | NEW |