2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 # define HEADER_APPS_H
13 # include "e_os.h" /* struct timeval for DTLS */
14 # include "internal/nelem.h"
17 # include <openssl/e_os2.h>
18 # include <openssl/ossl_typ.h>
19 # include <openssl/bio.h>
20 # include <openssl/x509.h>
21 # include <openssl/conf.h>
22 # include <openssl/txt_db.h>
23 # include <openssl/engine.h>
24 # include <openssl/ocsp.h>
27 # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
28 # define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
30 # define openssl_fdset(a,b) FD_SET(a, b)
34 * quick macro when you need to pass an unsigned char instead of a char.
35 * this is true for some implementations of the is*() functions, for
38 #define _UC(c) ((unsigned char)(c))
40 void app_RAND_load_conf(CONF *c, const char *section);
41 void app_RAND_write(void);
43 extern char *default_config_file;
47 extern const unsigned char tls13_aes128gcmsha256_id[];
48 extern const unsigned char tls13_aes256gcmsha384_id[];
49 extern BIO_ADDR *ourpeer;
51 BIO_METHOD *apps_bf_prefix(void);
53 * The control used to set the prefix with BIO_ctrl()
54 * We make it high enough so the chance of ever clashing with the BIO library
55 * remains unlikely for the foreseeable future and beyond.
57 #define PREFIX_CTRL_SET_PREFIX (1 << 15)
59 * apps_bf_prefix() returns a dynamically created BIO_METHOD, which we
60 * need to destroy at some point. When created internally, it's stored
61 * in an internal pointer which can be freed with the following function
63 void destroy_prefix_method(void);
65 BIO *dup_bio_in(int format);
66 BIO *dup_bio_out(int format);
67 BIO *dup_bio_err(int format);
68 BIO *bio_open_owner(const char *filename, int format, int private);
69 BIO *bio_open_default(const char *filename, char mode, int format);
70 BIO *bio_open_default_quiet(const char *filename, char mode, int format);
71 CONF *app_load_config_bio(BIO *in, const char *filename);
72 CONF *app_load_config(const char *filename);
73 CONF *app_load_config_quiet(const char *filename);
74 int app_load_modules(const CONF *config);
75 void unbuffer(FILE *fp);
76 void wait_for_async(SSL *s);
77 # if defined(OPENSSL_SYS_MSDOS)
78 int has_stdin_waiting(void);
81 void corrupt_signature(const ASN1_STRING *signature);
82 int set_cert_times(X509 *x, const char *startdate, const char *enddate,
86 * Common verification options.
90 OPT_V_POLICY, OPT_V_PURPOSE, OPT_V_VERIFY_NAME, OPT_V_VERIFY_DEPTH, \
91 OPT_V_ATTIME, OPT_V_VERIFY_HOSTNAME, OPT_V_VERIFY_EMAIL, \
92 OPT_V_VERIFY_IP, OPT_V_IGNORE_CRITICAL, OPT_V_ISSUER_CHECKS, \
93 OPT_V_CRL_CHECK, OPT_V_CRL_CHECK_ALL, OPT_V_POLICY_CHECK, \
94 OPT_V_EXPLICIT_POLICY, OPT_V_INHIBIT_ANY, OPT_V_INHIBIT_MAP, \
95 OPT_V_X509_STRICT, OPT_V_EXTENDED_CRL, OPT_V_USE_DELTAS, \
96 OPT_V_POLICY_PRINT, OPT_V_CHECK_SS_SIG, OPT_V_TRUSTED_FIRST, \
97 OPT_V_SUITEB_128_ONLY, OPT_V_SUITEB_128, OPT_V_SUITEB_192, \
98 OPT_V_PARTIAL_CHAIN, OPT_V_NO_ALT_CHAINS, OPT_V_NO_CHECK_TIME, \
99 OPT_V_VERIFY_AUTH_LEVEL, OPT_V_ALLOW_PROXY_CERTS, \
102 # define OPT_V_OPTIONS \
103 { "policy", OPT_V_POLICY, 's', "adds policy to the acceptable policy set"}, \
104 { "purpose", OPT_V_PURPOSE, 's', \
105 "certificate chain purpose"}, \
106 { "verify_name", OPT_V_VERIFY_NAME, 's', "verification policy name"}, \
107 { "verify_depth", OPT_V_VERIFY_DEPTH, 'n', \
108 "chain depth limit" }, \
109 { "auth_level", OPT_V_VERIFY_AUTH_LEVEL, 'n', \
110 "chain authentication security level" }, \
111 { "attime", OPT_V_ATTIME, 'M', "verification epoch time" }, \
112 { "verify_hostname", OPT_V_VERIFY_HOSTNAME, 's', \
113 "expected peer hostname" }, \
114 { "verify_email", OPT_V_VERIFY_EMAIL, 's', \
115 "expected peer email" }, \
116 { "verify_ip", OPT_V_VERIFY_IP, 's', \
117 "expected peer IP address" }, \
118 { "ignore_critical", OPT_V_IGNORE_CRITICAL, '-', \
119 "permit unhandled critical extensions"}, \
120 { "issuer_checks", OPT_V_ISSUER_CHECKS, '-', "(deprecated)"}, \
121 { "crl_check", OPT_V_CRL_CHECK, '-', "check leaf certificate revocation" }, \
122 { "crl_check_all", OPT_V_CRL_CHECK_ALL, '-', "check full chain revocation" }, \
123 { "policy_check", OPT_V_POLICY_CHECK, '-', "perform rfc5280 policy checks"}, \
124 { "explicit_policy", OPT_V_EXPLICIT_POLICY, '-', \
125 "set policy variable require-explicit-policy"}, \
126 { "inhibit_any", OPT_V_INHIBIT_ANY, '-', \
127 "set policy variable inhibit-any-policy"}, \
128 { "inhibit_map", OPT_V_INHIBIT_MAP, '-', \
129 "set policy variable inhibit-policy-mapping"}, \
130 { "x509_strict", OPT_V_X509_STRICT, '-', \
131 "disable certificate compatibility work-arounds"}, \
132 { "extended_crl", OPT_V_EXTENDED_CRL, '-', \
133 "enable extended CRL features"}, \
134 { "use_deltas", OPT_V_USE_DELTAS, '-', \
136 { "policy_print", OPT_V_POLICY_PRINT, '-', \
137 "print policy processing diagnostics"}, \
138 { "check_ss_sig", OPT_V_CHECK_SS_SIG, '-', \
139 "check root CA self-signatures"}, \
140 { "trusted_first", OPT_V_TRUSTED_FIRST, '-', \
141 "search trust store first (default)" }, \
142 { "suiteB_128_only", OPT_V_SUITEB_128_ONLY, '-', "Suite B 128-bit-only mode"}, \
143 { "suiteB_128", OPT_V_SUITEB_128, '-', \
144 "Suite B 128-bit mode allowing 192-bit algorithms"}, \
145 { "suiteB_192", OPT_V_SUITEB_192, '-', "Suite B 192-bit-only mode" }, \
146 { "partial_chain", OPT_V_PARTIAL_CHAIN, '-', \
147 "accept chains anchored by intermediate trust-store CAs"}, \
148 { "no_alt_chains", OPT_V_NO_ALT_CHAINS, '-', "(deprecated)" }, \
149 { "no_check_time", OPT_V_NO_CHECK_TIME, '-', "ignore certificate validity time" }, \
150 { "allow_proxy_certs", OPT_V_ALLOW_PROXY_CERTS, '-', "allow the use of proxy certificates" }
152 # define OPT_V_CASES \
153 OPT_V__FIRST: case OPT_V__LAST: break; \
155 case OPT_V_PURPOSE: \
156 case OPT_V_VERIFY_NAME: \
157 case OPT_V_VERIFY_DEPTH: \
158 case OPT_V_VERIFY_AUTH_LEVEL: \
160 case OPT_V_VERIFY_HOSTNAME: \
161 case OPT_V_VERIFY_EMAIL: \
162 case OPT_V_VERIFY_IP: \
163 case OPT_V_IGNORE_CRITICAL: \
164 case OPT_V_ISSUER_CHECKS: \
165 case OPT_V_CRL_CHECK: \
166 case OPT_V_CRL_CHECK_ALL: \
167 case OPT_V_POLICY_CHECK: \
168 case OPT_V_EXPLICIT_POLICY: \
169 case OPT_V_INHIBIT_ANY: \
170 case OPT_V_INHIBIT_MAP: \
171 case OPT_V_X509_STRICT: \
172 case OPT_V_EXTENDED_CRL: \
173 case OPT_V_USE_DELTAS: \
174 case OPT_V_POLICY_PRINT: \
175 case OPT_V_CHECK_SS_SIG: \
176 case OPT_V_TRUSTED_FIRST: \
177 case OPT_V_SUITEB_128_ONLY: \
178 case OPT_V_SUITEB_128: \
179 case OPT_V_SUITEB_192: \
180 case OPT_V_PARTIAL_CHAIN: \
181 case OPT_V_NO_ALT_CHAINS: \
182 case OPT_V_NO_CHECK_TIME: \
183 case OPT_V_ALLOW_PROXY_CERTS
186 * Common "extended validation" options.
188 # define OPT_X_ENUM \
190 OPT_X_KEY, OPT_X_CERT, OPT_X_CHAIN, OPT_X_CHAIN_BUILD, \
191 OPT_X_CERTFORM, OPT_X_KEYFORM, \
194 # define OPT_X_OPTIONS \
195 { "xkey", OPT_X_KEY, '<', "key for Extended certificates"}, \
196 { "xcert", OPT_X_CERT, '<', "cert for Extended certificates"}, \
197 { "xchain", OPT_X_CHAIN, '<', "chain for Extended certificates"}, \
198 { "xchain_build", OPT_X_CHAIN_BUILD, '-', \
199 "build certificate chain for the extended certificates"}, \
200 { "xcertform", OPT_X_CERTFORM, 'F', \
201 "format of Extended certificate (PEM or DER) PEM default " }, \
202 { "xkeyform", OPT_X_KEYFORM, 'F', \
203 "format of Extended certificate's key (PEM or DER) PEM default"}
205 # define OPT_X_CASES \
206 OPT_X__FIRST: case OPT_X__LAST: break; \
210 case OPT_X_CHAIN_BUILD: \
211 case OPT_X_CERTFORM: \
215 * Common SSL options.
216 * Any changes here must be coordinated with ../ssl/ssl_conf.c
218 # define OPT_S_ENUM \
220 OPT_S_NOSSL3, OPT_S_NOTLS1, OPT_S_NOTLS1_1, OPT_S_NOTLS1_2, \
221 OPT_S_NOTLS1_3, OPT_S_BUGS, OPT_S_NO_COMP, OPT_S_NOTICKET, \
222 OPT_S_SERVERPREF, OPT_S_LEGACYRENEG, OPT_S_LEGACYCONN, \
223 OPT_S_ONRESUMP, OPT_S_NOLEGACYCONN, OPT_S_ALLOW_NO_DHE_KEX, \
224 OPT_S_PRIORITIZE_CHACHA, \
225 OPT_S_STRICT, OPT_S_SIGALGS, OPT_S_CLIENTSIGALGS, OPT_S_GROUPS, \
226 OPT_S_CURVES, OPT_S_NAMEDCURVE, OPT_S_CIPHER, \
227 OPT_S_RECORD_PADDING, OPT_S_DEBUGBROKE, OPT_S_COMP, \
228 OPT_S_NO_RENEGOTIATION, OPT_S_NO_MIDDLEBOX, OPT_S__LAST
230 # define OPT_S_OPTIONS \
231 {"no_ssl3", OPT_S_NOSSL3, '-',"Just disable SSLv3" }, \
232 {"no_tls1", OPT_S_NOTLS1, '-', "Just disable TLSv1"}, \
233 {"no_tls1_1", OPT_S_NOTLS1_1, '-', "Just disable TLSv1.1" }, \
234 {"no_tls1_2", OPT_S_NOTLS1_2, '-', "Just disable TLSv1.2"}, \
235 {"no_tls1_3", OPT_S_NOTLS1_3, '-', "Just disable TLSv1.3"}, \
236 {"bugs", OPT_S_BUGS, '-', "Turn on SSL bug compatibility"}, \
237 {"no_comp", OPT_S_NO_COMP, '-', "Disable SSL/TLS compression (default)" }, \
238 {"comp", OPT_S_COMP, '-', "Use SSL/TLS-level compression" }, \
239 {"no_ticket", OPT_S_NOTICKET, '-', \
240 "Disable use of TLS session tickets"}, \
241 {"serverpref", OPT_S_SERVERPREF, '-', "Use server's cipher preferences"}, \
242 {"legacy_renegotiation", OPT_S_LEGACYRENEG, '-', \
243 "Enable use of legacy renegotiation (dangerous)"}, \
244 {"no_renegotiation", OPT_S_NO_RENEGOTIATION, '-', \
245 "Disable all renegotiation."}, \
246 {"legacy_server_connect", OPT_S_LEGACYCONN, '-', \
247 "Allow initial connection to servers that don't support RI"}, \
248 {"no_resumption_on_reneg", OPT_S_ONRESUMP, '-', \
249 "Disallow session resumption on renegotiation"}, \
250 {"no_legacy_server_connect", OPT_S_NOLEGACYCONN, '-', \
251 "Disallow initial connection to servers that don't support RI"}, \
252 {"allow_no_dhe_kex", OPT_S_ALLOW_NO_DHE_KEX, '-', \
253 "In TLSv1.3 allow non-(ec)dhe based key exchange on resumption"}, \
254 {"prioritize_chacha", OPT_S_PRIORITIZE_CHACHA, '-', \
255 "Prioritize ChaCha ciphers when preferred by clients"}, \
256 {"strict", OPT_S_STRICT, '-', \
257 "Enforce strict certificate checks as per TLS standard"}, \
258 {"sigalgs", OPT_S_SIGALGS, 's', \
259 "Signature algorithms to support (colon-separated list)" }, \
260 {"client_sigalgs", OPT_S_CLIENTSIGALGS, 's', \
261 "Signature algorithms to support for client certificate" \
262 " authentication (colon-separated list)" }, \
263 {"groups", OPT_S_GROUPS, 's', \
264 "Groups to advertise (colon-separated list)" }, \
265 {"curves", OPT_S_CURVES, 's', \
266 "Groups to advertise (colon-separated list)" }, \
267 {"named_curve", OPT_S_NAMEDCURVE, 's', \
268 "Elliptic curve used for ECDHE (server-side only)" }, \
269 {"cipher", OPT_S_CIPHER, 's', "Specify cipher list to be used"}, \
270 {"record_padding", OPT_S_RECORD_PADDING, 's', \
271 "Block size to pad TLS 1.3 records to."}, \
272 {"debug_broken_protocol", OPT_S_DEBUGBROKE, '-', \
273 "Perform all sorts of protocol violations for testing purposes"}, \
274 {"no_middlebox", OPT_S_NO_MIDDLEBOX, '-', "Disable TLSv1.3 middlebox compat mode" }
277 # define OPT_S_CASES \
278 OPT_S__FIRST: case OPT_S__LAST: break; \
281 case OPT_S_NOTLS1_1: \
282 case OPT_S_NOTLS1_2: \
283 case OPT_S_NOTLS1_3: \
285 case OPT_S_NO_COMP: \
287 case OPT_S_NOTICKET: \
288 case OPT_S_SERVERPREF: \
289 case OPT_S_LEGACYRENEG: \
290 case OPT_S_LEGACYCONN: \
291 case OPT_S_ONRESUMP: \
292 case OPT_S_NOLEGACYCONN: \
293 case OPT_S_ALLOW_NO_DHE_KEX: \
294 case OPT_S_PRIORITIZE_CHACHA: \
296 case OPT_S_SIGALGS: \
297 case OPT_S_CLIENTSIGALGS: \
300 case OPT_S_NAMEDCURVE: \
302 case OPT_S_RECORD_PADDING: \
303 case OPT_S_NO_RENEGOTIATION: \
304 case OPT_S_DEBUGBROKE: \
305 case OPT_S_NO_MIDDLEBOX
307 #define IS_NO_PROT_FLAG(o) \
308 (o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \
309 || o == OPT_S_NOTLS1_2 || o == OPT_S_NOTLS1_3)
312 * Random state options.
314 # define OPT_R_ENUM \
315 OPT_R__FIRST=1500, OPT_R_RAND, OPT_R_WRITERAND, OPT_R__LAST
317 # define OPT_R_OPTIONS \
318 {"rand", OPT_R_RAND, 's', "Load the file(s) into the random number generator"}, \
319 {"writerand", OPT_R_WRITERAND, '>', "Write random data to the specified file"}
321 # define OPT_R_CASES \
322 OPT_R__FIRST: case OPT_R__LAST: break; \
323 case OPT_R_RAND: case OPT_R_WRITERAND
328 extern const char OPT_HELP_STR[];
329 extern const char OPT_MORE_STR[];
330 typedef struct options_st {
334 * value type: - no value (also the value zero), n number, p positive
335 * number, u unsigned, l long, s string, < input file, > output file,
336 * f any format, F der/pem format, E der/pem/engine format identifier.
337 * l, n and u include zero; p does not.
344 * A string/int pairing; widely use for option value lookup, hence the
345 * name OPT_PAIR. But that name is misleading in s_cb.c, so we also use
346 * the "generic" name STRINT_PAIR.
348 typedef struct string_int_pair_st {
351 } OPT_PAIR, STRINT_PAIR;
353 /* Flags to pass into opt_format; see FORMAT_xxx, below. */
354 # define OPT_FMT_PEMDER (1L << 1)
355 # define OPT_FMT_PKCS12 (1L << 2)
356 # define OPT_FMT_SMIME (1L << 3)
357 # define OPT_FMT_ENGINE (1L << 4)
358 # define OPT_FMT_MSBLOB (1L << 5)
359 # define OPT_FMT_NETSCAPE (1L << 6)
360 # define OPT_FMT_NSS (1L << 7)
361 # define OPT_FMT_TEXT (1L << 8)
362 # define OPT_FMT_HTTP (1L << 9)
363 # define OPT_FMT_PVK (1L << 10)
364 # define OPT_FMT_PDE (OPT_FMT_PEMDER | OPT_FMT_ENGINE)
365 # define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME)
366 # define OPT_FMT_ANY ( \
367 OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \
368 OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \
369 OPT_FMT_NSS | OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
371 char *opt_progname(const char *argv0);
372 char *opt_getprog(void);
373 char *opt_init(int ac, char **av, const OPTIONS * o);
375 int opt_format(const char *s, unsigned long flags, int *result);
376 int opt_int(const char *arg, int *result);
377 int opt_ulong(const char *arg, unsigned long *result);
378 int opt_long(const char *arg, long *result);
379 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
380 defined(INTMAX_MAX) && defined(UINTMAX_MAX)
381 int opt_imax(const char *arg, intmax_t *result);
382 int opt_umax(const char *arg, uintmax_t *result);
384 # define opt_imax opt_long
385 # define opt_umax opt_ulong
386 # define intmax_t long
387 # define uintmax_t unsigned long
389 int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
390 int opt_cipher(const char *name, const EVP_CIPHER **cipherp);
391 int opt_md(const char *name, const EVP_MD **mdp);
393 char *opt_flag(void);
394 char *opt_unknown(void);
395 char **opt_rest(void);
396 int opt_num_rest(void);
397 int opt_verify(int i, X509_VERIFY_PARAM *vpm);
399 void opt_help(const OPTIONS * list);
400 int opt_format_error(const char *s, unsigned long flags);
402 typedef struct args_st {
409 * VMS C only for now, implemented in vms_decc_init.c
410 * If other C compilers forget to terminate argv with NULL, this function
413 char **copy_argv(int *argc, char *argv[]);
415 * Win32-specific argv initialization that splits OS-supplied UNICODE
416 * command line string to array of UTF8-encoded strings.
418 void win32_utf8argv(int *argc, char **argv[]);
421 # define PW_MIN_LENGTH 4
422 typedef struct pw_cb_data {
423 const void *password;
424 const char *prompt_info;
427 int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_data);
429 int setup_ui_method(void);
430 void destroy_ui_method(void);
431 const UI_METHOD *get_ui_method(void);
433 int chopup_args(ARGS *arg, char *buf);
434 # ifdef HEADER_X509_H
435 int dump_cert_text(BIO *out, X509 *x);
436 void print_name(BIO *out, const char *title, X509_NAME *nm,
437 unsigned long lflags);
439 void print_bignum_var(BIO *, const BIGNUM *, const char*,
440 int, unsigned char *);
441 void print_array(BIO *, const char *, int, const unsigned char *);
442 int set_nameopt(const char *arg);
443 unsigned long get_nameopt(void);
444 int set_cert_ex(unsigned long *flags, const char *arg);
445 int set_name_ex(unsigned long *flags, const char *arg);
446 int set_ext_copy(int *copy_type, const char *arg);
447 int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
448 int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
449 int add_oid_section(CONF *conf);
450 X509 *load_cert(const char *file, int format, const char *cert_descrip);
451 X509_CRL *load_crl(const char *infile, int format);
452 EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
453 const char *pass, ENGINE *e, const char *key_descrip);
454 EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
455 const char *pass, ENGINE *e, const char *key_descrip);
456 int load_certs(const char *file, STACK_OF(X509) **certs, int format,
457 const char *pass, const char *cert_descrip);
458 int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
459 const char *pass, const char *cert_descrip);
460 X509_STORE *setup_verify(const char *CAfile, const char *CApath,
461 int noCAfile, int noCApath);
462 __owur int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
463 const char *CApath, int noCAfile,
466 #ifndef OPENSSL_NO_CT
469 * Sets the file to load the Certificate Transparency log list from.
470 * If path is NULL, loads from the default file path.
471 * Returns 1 on success, 0 otherwise.
473 __owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
477 ENGINE *setup_engine(const char *engine, int debug);
478 void release_engine(ENGINE *e);
480 # ifndef OPENSSL_NO_OCSP
481 OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
482 const char *host, const char *path,
483 const char *port, int use_ssl,
484 STACK_OF(CONF_VALUE) *headers,
488 /* Functions defined in ca.c and also used in ocsp.c */
489 int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
490 ASN1_GENERALIZEDTIME **pinvtm, const char *str);
493 # define DB_exp_date 1
494 # define DB_rev_date 2
495 # define DB_serial 3 /* index - unique */
497 # define DB_name 5 /* index - unique when active and not
501 # define DB_TYPE_REV 'R' /* Revoked */
502 # define DB_TYPE_EXP 'E' /* Expired */
503 # define DB_TYPE_VAL 'V' /* Valid ; inserted with: ca ... -valid */
504 # define DB_TYPE_SUSP 'S' /* Suspended */
506 typedef struct db_attr_st {
509 typedef struct ca_db_st {
514 void* app_malloc(int sz, const char *what);
515 BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai);
516 int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial,
517 ASN1_INTEGER **retai);
518 int rotate_serial(const char *serialfile, const char *new_suffix,
519 const char *old_suffix);
520 int rand_serial(BIGNUM *b, ASN1_INTEGER *ai);
521 CA_DB *load_index(const char *dbfile, DB_ATTR *dbattr);
522 int index_index(CA_DB *db);
523 int save_index(const char *dbfile, const char *suffix, CA_DB *db);
524 int rotate_index(const char *dbfile, const char *new_suffix,
525 const char *old_suffix);
526 void free_index(CA_DB *db);
527 # define index_name_cmp_noconst(a, b) \
528 index_name_cmp((const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, a), \
529 (const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, b))
530 int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b);
531 int parse_yesno(const char *str, int def);
533 X509_NAME *parse_name(const char *str, long chtype, int multirdn);
534 void policies_print(X509_STORE_CTX *ctx);
535 int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
536 int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
537 int init_gen_str(EVP_PKEY_CTX **pctx,
538 const char *algname, ENGINE *e, int do_param);
539 int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
540 STACK_OF(OPENSSL_STRING) *sigopts);
541 int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
542 STACK_OF(OPENSSL_STRING) *sigopts);
543 int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
544 STACK_OF(OPENSSL_STRING) *sigopts);
546 extern char *psk_key;
549 unsigned char *next_protos_parse(size_t *outlen, const char *in);
551 void print_cert_checks(BIO *bio, X509 *x,
552 const char *checkhost,
553 const char *checkemail, const char *checkip);
555 void store_setup_crl_download(X509_STORE *st);
557 /* See OPT_FMT_xxx, above. */
558 /* On some platforms, it's important to distinguish between text and binary
559 * files. On some, there might even be specific file formats for different
560 * contents. The FORMAT_xxx macros are meant to express an intent with the
561 * file being read or created.
563 # define B_FORMAT_TEXT 0x8000
564 # define FORMAT_UNDEF 0
565 # define FORMAT_TEXT (1 | B_FORMAT_TEXT) /* Generic text */
566 # define FORMAT_BINARY 2 /* Generic binary */
567 # define FORMAT_BASE64 (3 | B_FORMAT_TEXT) /* Base64 */
568 # define FORMAT_ASN1 4 /* ASN.1/DER */
569 # define FORMAT_PEM (5 | B_FORMAT_TEXT)
570 # define FORMAT_PKCS12 6
571 # define FORMAT_SMIME (7 | B_FORMAT_TEXT)
572 # define FORMAT_ENGINE 8 /* Not really a file format */
573 # define FORMAT_PEMRSA (9 | B_FORMAT_TEXT) /* PEM RSAPubicKey format */
574 # define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
575 # define FORMAT_MSBLOB 11 /* MS Key blob format */
576 # define FORMAT_PVK 12 /* MS PVK file format */
577 # define FORMAT_HTTP 13 /* Download using HTTP */
578 # define FORMAT_NSS 14 /* NSS keylog format */
580 # define EXT_COPY_NONE 0
581 # define EXT_COPY_ADD 1
582 # define EXT_COPY_ALL 2
584 # define NETSCAPE_CERT_HDR "certificate"
586 # define APP_PASS_LEN 1024
589 * IETF RFC 5280 says serial number must be <= 20 bytes. Use 159 bits
590 * so that the first bit will never be one, so that the DER encoding
591 * rules won't force a leading octet.
593 # define SERIAL_RAND_BITS 159
595 int app_isdir(const char *);
596 int app_access(const char *, int flag);
597 int fileno_stdin(void);
598 int fileno_stdout(void);
599 int raw_read_stdin(void *, int);
600 int raw_write_stdout(const void *, int);
604 double app_tminterval(int stop, int usertime);
606 void make_uppercase(char *string);
608 typedef struct verify_options_st {
615 extern VERIFY_CB_ARGS verify_args;