2 * Copyright 1995-2017 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/lhash.h>
22 # include <openssl/conf.h>
23 # include <openssl/txt_db.h>
24 # include <openssl/engine.h>
25 # include <openssl/ocsp.h>
28 # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
29 # define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
31 # define openssl_fdset(a,b) FD_SET(a, b)
35 * quick macro when you need to pass an unsigned char instead of a char.
36 * this is true for some implementations of the is*() functions, for
39 #define _UC(c) ((unsigned char)(c))
41 void app_RAND_load_conf(CONF *c, const char *section);
42 void app_RAND_write(void);
44 extern char *default_config_file;
48 extern const unsigned char tls13_aes128gcmsha256_id[];
49 extern const unsigned char tls13_aes256gcmsha384_id[];
50 BIO *dup_bio_in(int format);
51 BIO *dup_bio_out(int format);
52 BIO *dup_bio_err(int format);
53 BIO *bio_open_owner(const char *filename, int format, int private);
54 BIO *bio_open_default(const char *filename, char mode, int format);
55 BIO *bio_open_default_quiet(const char *filename, char mode, int format);
56 CONF *app_load_config(const char *filename);
57 CONF *app_load_config_quiet(const char *filename);
58 int app_load_modules(const CONF *config);
59 void unbuffer(FILE *fp);
60 void wait_for_async(SSL *s);
61 # if defined(OPENSSL_SYS_MSDOS)
62 int has_stdin_waiting(void);
65 void corrupt_signature(const ASN1_STRING *signature);
66 int set_cert_times(X509 *x, const char *startdate, const char *enddate,
70 * Common verification options.
74 OPT_V_POLICY, OPT_V_PURPOSE, OPT_V_VERIFY_NAME, OPT_V_VERIFY_DEPTH, \
75 OPT_V_ATTIME, OPT_V_VERIFY_HOSTNAME, OPT_V_VERIFY_EMAIL, \
76 OPT_V_VERIFY_IP, OPT_V_IGNORE_CRITICAL, OPT_V_ISSUER_CHECKS, \
77 OPT_V_CRL_CHECK, OPT_V_CRL_CHECK_ALL, OPT_V_POLICY_CHECK, \
78 OPT_V_EXPLICIT_POLICY, OPT_V_INHIBIT_ANY, OPT_V_INHIBIT_MAP, \
79 OPT_V_X509_STRICT, OPT_V_EXTENDED_CRL, OPT_V_USE_DELTAS, \
80 OPT_V_POLICY_PRINT, OPT_V_CHECK_SS_SIG, OPT_V_TRUSTED_FIRST, \
81 OPT_V_SUITEB_128_ONLY, OPT_V_SUITEB_128, OPT_V_SUITEB_192, \
82 OPT_V_PARTIAL_CHAIN, OPT_V_NO_ALT_CHAINS, OPT_V_NO_CHECK_TIME, \
83 OPT_V_VERIFY_AUTH_LEVEL, OPT_V_ALLOW_PROXY_CERTS, \
86 # define OPT_V_OPTIONS \
87 { "policy", OPT_V_POLICY, 's', "adds policy to the acceptable policy set"}, \
88 { "purpose", OPT_V_PURPOSE, 's', \
89 "certificate chain purpose"}, \
90 { "verify_name", OPT_V_VERIFY_NAME, 's', "verification policy name"}, \
91 { "verify_depth", OPT_V_VERIFY_DEPTH, 'n', \
92 "chain depth limit" }, \
93 { "auth_level", OPT_V_VERIFY_AUTH_LEVEL, 'n', \
94 "chain authentication security level" }, \
95 { "attime", OPT_V_ATTIME, 'M', "verification epoch time" }, \
96 { "verify_hostname", OPT_V_VERIFY_HOSTNAME, 's', \
97 "expected peer hostname" }, \
98 { "verify_email", OPT_V_VERIFY_EMAIL, 's', \
99 "expected peer email" }, \
100 { "verify_ip", OPT_V_VERIFY_IP, 's', \
101 "expected peer IP address" }, \
102 { "ignore_critical", OPT_V_IGNORE_CRITICAL, '-', \
103 "permit unhandled critical extensions"}, \
104 { "issuer_checks", OPT_V_ISSUER_CHECKS, '-', "(deprecated)"}, \
105 { "crl_check", OPT_V_CRL_CHECK, '-', "check leaf certificate revocation" }, \
106 { "crl_check_all", OPT_V_CRL_CHECK_ALL, '-', "check full chain revocation" }, \
107 { "policy_check", OPT_V_POLICY_CHECK, '-', "perform rfc5280 policy checks"}, \
108 { "explicit_policy", OPT_V_EXPLICIT_POLICY, '-', \
109 "set policy variable require-explicit-policy"}, \
110 { "inhibit_any", OPT_V_INHIBIT_ANY, '-', \
111 "set policy variable inhibit-any-policy"}, \
112 { "inhibit_map", OPT_V_INHIBIT_MAP, '-', \
113 "set policy variable inhibit-policy-mapping"}, \
114 { "x509_strict", OPT_V_X509_STRICT, '-', \
115 "disable certificate compatibility work-arounds"}, \
116 { "extended_crl", OPT_V_EXTENDED_CRL, '-', \
117 "enable extended CRL features"}, \
118 { "use_deltas", OPT_V_USE_DELTAS, '-', \
120 { "policy_print", OPT_V_POLICY_PRINT, '-', \
121 "print policy processing diagnostics"}, \
122 { "check_ss_sig", OPT_V_CHECK_SS_SIG, '-', \
123 "check root CA self-signatures"}, \
124 { "trusted_first", OPT_V_TRUSTED_FIRST, '-', \
125 "search trust store first (default)" }, \
126 { "suiteB_128_only", OPT_V_SUITEB_128_ONLY, '-', "Suite B 128-bit-only mode"}, \
127 { "suiteB_128", OPT_V_SUITEB_128, '-', \
128 "Suite B 128-bit mode allowing 192-bit algorithms"}, \
129 { "suiteB_192", OPT_V_SUITEB_192, '-', "Suite B 192-bit-only mode" }, \
130 { "partial_chain", OPT_V_PARTIAL_CHAIN, '-', \
131 "accept chains anchored by intermediate trust-store CAs"}, \
132 { "no_alt_chains", OPT_V_NO_ALT_CHAINS, '-', "(deprecated)" }, \
133 { "no_check_time", OPT_V_NO_CHECK_TIME, '-', "ignore certificate validity time" }, \
134 { "allow_proxy_certs", OPT_V_ALLOW_PROXY_CERTS, '-', "allow the use of proxy certificates" }
136 # define OPT_V_CASES \
137 OPT_V__FIRST: case OPT_V__LAST: break; \
139 case OPT_V_PURPOSE: \
140 case OPT_V_VERIFY_NAME: \
141 case OPT_V_VERIFY_DEPTH: \
142 case OPT_V_VERIFY_AUTH_LEVEL: \
144 case OPT_V_VERIFY_HOSTNAME: \
145 case OPT_V_VERIFY_EMAIL: \
146 case OPT_V_VERIFY_IP: \
147 case OPT_V_IGNORE_CRITICAL: \
148 case OPT_V_ISSUER_CHECKS: \
149 case OPT_V_CRL_CHECK: \
150 case OPT_V_CRL_CHECK_ALL: \
151 case OPT_V_POLICY_CHECK: \
152 case OPT_V_EXPLICIT_POLICY: \
153 case OPT_V_INHIBIT_ANY: \
154 case OPT_V_INHIBIT_MAP: \
155 case OPT_V_X509_STRICT: \
156 case OPT_V_EXTENDED_CRL: \
157 case OPT_V_USE_DELTAS: \
158 case OPT_V_POLICY_PRINT: \
159 case OPT_V_CHECK_SS_SIG: \
160 case OPT_V_TRUSTED_FIRST: \
161 case OPT_V_SUITEB_128_ONLY: \
162 case OPT_V_SUITEB_128: \
163 case OPT_V_SUITEB_192: \
164 case OPT_V_PARTIAL_CHAIN: \
165 case OPT_V_NO_ALT_CHAINS: \
166 case OPT_V_NO_CHECK_TIME: \
167 case OPT_V_ALLOW_PROXY_CERTS
170 * Common "extended validation" options.
172 # define OPT_X_ENUM \
174 OPT_X_KEY, OPT_X_CERT, OPT_X_CHAIN, OPT_X_CHAIN_BUILD, \
175 OPT_X_CERTFORM, OPT_X_KEYFORM, \
178 # define OPT_X_OPTIONS \
179 { "xkey", OPT_X_KEY, '<', "key for Extended certificates"}, \
180 { "xcert", OPT_X_CERT, '<', "cert for Extended certificates"}, \
181 { "xchain", OPT_X_CHAIN, '<', "chain for Extended certificates"}, \
182 { "xchain_build", OPT_X_CHAIN_BUILD, '-', \
183 "build certificate chain for the extended certificates"}, \
184 { "xcertform", OPT_X_CERTFORM, 'F', \
185 "format of Extended certificate (PEM or DER) PEM default " }, \
186 { "xkeyform", OPT_X_KEYFORM, 'F', \
187 "format of Extended certificate's key (PEM or DER) PEM default"}
189 # define OPT_X_CASES \
190 OPT_X__FIRST: case OPT_X__LAST: break; \
194 case OPT_X_CHAIN_BUILD: \
195 case OPT_X_CERTFORM: \
199 * Common SSL options.
200 * Any changes here must be coordinated with ../ssl/ssl_conf.c
202 # define OPT_S_ENUM \
204 OPT_S_NOSSL3, OPT_S_NOTLS1, OPT_S_NOTLS1_1, OPT_S_NOTLS1_2, \
205 OPT_S_NOTLS1_3, OPT_S_BUGS, OPT_S_NO_COMP, OPT_S_NOTICKET, \
206 OPT_S_SERVERPREF, OPT_S_LEGACYRENEG, OPT_S_LEGACYCONN, \
207 OPT_S_ONRESUMP, OPT_S_NOLEGACYCONN, OPT_S_ALLOW_NO_DHE_KEX, \
208 OPT_S_STRICT, OPT_S_SIGALGS, OPT_S_CLIENTSIGALGS, OPT_S_GROUPS, \
209 OPT_S_CURVES, OPT_S_NAMEDCURVE, OPT_S_CIPHER, \
210 OPT_S_RECORD_PADDING, OPT_S_DEBUGBROKE, OPT_S_COMP, \
211 OPT_S_NO_RENEGOTIATION, OPT_S__LAST
213 # define OPT_S_OPTIONS \
214 {"no_ssl3", OPT_S_NOSSL3, '-',"Just disable SSLv3" }, \
215 {"no_tls1", OPT_S_NOTLS1, '-', "Just disable TLSv1"}, \
216 {"no_tls1_1", OPT_S_NOTLS1_1, '-', "Just disable TLSv1.1" }, \
217 {"no_tls1_2", OPT_S_NOTLS1_2, '-', "Just disable TLSv1.2"}, \
218 {"no_tls1_3", OPT_S_NOTLS1_3, '-', "Just disable TLSv1.3"}, \
219 {"bugs", OPT_S_BUGS, '-', "Turn on SSL bug compatibility"}, \
220 {"no_comp", OPT_S_NO_COMP, '-', "Disable SSL/TLS compression (default)" }, \
221 {"comp", OPT_S_COMP, '-', "Use SSL/TLS-level compression" }, \
222 {"no_ticket", OPT_S_NOTICKET, '-', \
223 "Disable use of TLS session tickets"}, \
224 {"serverpref", OPT_S_SERVERPREF, '-', "Use server's cipher preferences"}, \
225 {"legacy_renegotiation", OPT_S_LEGACYRENEG, '-', \
226 "Enable use of legacy renegotiation (dangerous)"}, \
227 {"no_renegotiation", OPT_S_NO_RENEGOTIATION, '-', \
228 "Disable all renegotiation."}, \
229 {"legacy_server_connect", OPT_S_LEGACYCONN, '-', \
230 "Allow initial connection to servers that don't support RI"}, \
231 {"no_resumption_on_reneg", OPT_S_ONRESUMP, '-', \
232 "Disallow session resumption on renegotiation"}, \
233 {"no_legacy_server_connect", OPT_S_NOLEGACYCONN, '-', \
234 "Disallow initial connection to servers that don't support RI"}, \
235 {"allow_no_dhe_kex", OPT_S_ALLOW_NO_DHE_KEX, '-', \
236 "In TLSv1.3 allow non-(ec)dhe based key exchange on resumption"}, \
237 {"strict", OPT_S_STRICT, '-', \
238 "Enforce strict certificate checks as per TLS standard"}, \
239 {"sigalgs", OPT_S_SIGALGS, 's', \
240 "Signature algorithms to support (colon-separated list)" }, \
241 {"client_sigalgs", OPT_S_CLIENTSIGALGS, 's', \
242 "Signature algorithms to support for client certificate" \
243 " authentication (colon-separated list)" }, \
244 {"groups", OPT_S_GROUPS, 's', \
245 "Groups to advertise (colon-separated list)" }, \
246 {"curves", OPT_S_CURVES, 's', \
247 "Groups to advertise (colon-separated list)" }, \
248 {"named_curve", OPT_S_NAMEDCURVE, 's', \
249 "Elliptic curve used for ECDHE (server-side only)" }, \
250 {"cipher", OPT_S_CIPHER, 's', "Specify cipher list to be used"}, \
251 {"record_padding", OPT_S_RECORD_PADDING, 's', \
252 "Block size to pad TLS 1.3 records to."}, \
253 {"debug_broken_protocol", OPT_S_DEBUGBROKE, '-', \
254 "Perform all sorts of protocol violations for testing purposes"}
257 # define OPT_S_CASES \
258 OPT_S__FIRST: case OPT_S__LAST: break; \
261 case OPT_S_NOTLS1_1: \
262 case OPT_S_NOTLS1_2: \
263 case OPT_S_NOTLS1_3: \
265 case OPT_S_NO_COMP: \
267 case OPT_S_NOTICKET: \
268 case OPT_S_SERVERPREF: \
269 case OPT_S_LEGACYRENEG: \
270 case OPT_S_LEGACYCONN: \
271 case OPT_S_ONRESUMP: \
272 case OPT_S_NOLEGACYCONN: \
273 case OPT_S_ALLOW_NO_DHE_KEX: \
275 case OPT_S_SIGALGS: \
276 case OPT_S_CLIENTSIGALGS: \
279 case OPT_S_NAMEDCURVE: \
281 case OPT_S_RECORD_PADDING: \
282 case OPT_S_NO_RENEGOTIATION: \
283 case OPT_S_DEBUGBROKE
285 #define IS_NO_PROT_FLAG(o) \
286 (o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \
287 || o == OPT_S_NOTLS1_2 || o == OPT_S_NOTLS1_3)
290 * Random state options.
292 # define OPT_R_ENUM \
293 OPT_R__FIRST=1500, OPT_R_RAND, OPT_R_WRITERAND, OPT_R__LAST
295 # define OPT_R_OPTIONS \
296 {"rand", OPT_R_RAND, 's', "Load the file(s) into the random number generator"}, \
297 {"writerand", OPT_R_WRITERAND, '>', "Write random data to the specified file"}
299 # define OPT_R_CASES \
300 OPT_R__FIRST: case OPT_R__LAST: break; \
301 case OPT_R_RAND: case OPT_R_WRITERAND
306 extern const char OPT_HELP_STR[];
307 extern const char OPT_MORE_STR[];
308 typedef struct options_st {
312 * value type: - no value (also the value zero), n number, p positive
313 * number, u unsigned, l long, s string, < input file, > output file,
314 * f any format, F der/pem format, E der/pem/engine format identifier.
315 * l, n and u include zero; p does not.
322 * A string/int pairing; widely use for option value lookup, hence the
323 * name OPT_PAIR. But that name is misleading in s_cb.c, so we also use
324 * the "generic" name STRINT_PAIR.
326 typedef struct string_int_pair_st {
329 } OPT_PAIR, STRINT_PAIR;
331 /* Flags to pass into opt_format; see FORMAT_xxx, below. */
332 # define OPT_FMT_PEMDER (1L << 1)
333 # define OPT_FMT_PKCS12 (1L << 2)
334 # define OPT_FMT_SMIME (1L << 3)
335 # define OPT_FMT_ENGINE (1L << 4)
336 # define OPT_FMT_MSBLOB (1L << 5)
337 # define OPT_FMT_NETSCAPE (1L << 6)
338 # define OPT_FMT_NSS (1L << 7)
339 # define OPT_FMT_TEXT (1L << 8)
340 # define OPT_FMT_HTTP (1L << 9)
341 # define OPT_FMT_PVK (1L << 10)
342 # define OPT_FMT_PDE (OPT_FMT_PEMDER | OPT_FMT_ENGINE)
343 # define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME)
344 # define OPT_FMT_ANY ( \
345 OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \
346 OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \
347 OPT_FMT_NSS | OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
349 char *opt_progname(const char *argv0);
350 char *opt_getprog(void);
351 char *opt_init(int ac, char **av, const OPTIONS * o);
353 int opt_format(const char *s, unsigned long flags, int *result);
354 int opt_int(const char *arg, int *result);
355 int opt_ulong(const char *arg, unsigned long *result);
356 int opt_long(const char *arg, long *result);
357 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
358 defined(INTMAX_MAX) && defined(UINTMAX_MAX)
359 int opt_imax(const char *arg, intmax_t *result);
360 int opt_umax(const char *arg, uintmax_t *result);
362 # define opt_imax opt_long
363 # define opt_umax opt_ulong
364 # define intmax_t long
365 # define uintmax_t unsigned long
367 int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
368 int opt_cipher(const char *name, const EVP_CIPHER **cipherp);
369 int opt_md(const char *name, const EVP_MD **mdp);
371 char *opt_flag(void);
372 char *opt_unknown(void);
373 char **opt_rest(void);
374 int opt_num_rest(void);
375 int opt_verify(int i, X509_VERIFY_PARAM *vpm);
377 void opt_help(const OPTIONS * list);
378 int opt_format_error(const char *s, unsigned long flags);
380 typedef struct args_st {
387 * VMS C only for now, implemented in vms_decc_init.c
388 * If other C compilers forget to terminate argv with NULL, this function
391 char **copy_argv(int *argc, char *argv[]);
393 * Win32-specific argv initialization that splits OS-supplied UNICODE
394 * command line string to array of UTF8-encoded strings.
396 void win32_utf8argv(int *argc, char **argv[]);
399 # define PW_MIN_LENGTH 4
400 typedef struct pw_cb_data {
401 const void *password;
402 const char *prompt_info;
405 int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_data);
407 int setup_ui_method(void);
408 void destroy_ui_method(void);
409 const UI_METHOD *get_ui_method(void);
411 int chopup_args(ARGS *arg, char *buf);
412 # ifdef HEADER_X509_H
413 int dump_cert_text(BIO *out, X509 *x);
414 void print_name(BIO *out, const char *title, X509_NAME *nm,
415 unsigned long lflags);
417 void print_bignum_var(BIO *, const BIGNUM *, const char*,
418 int, unsigned char *);
419 void print_array(BIO *, const char *, int, const unsigned char *);
420 int set_nameopt(const char *arg);
421 unsigned long get_nameopt(void);
422 int set_cert_ex(unsigned long *flags, const char *arg);
423 int set_name_ex(unsigned long *flags, const char *arg);
424 int set_ext_copy(int *copy_type, const char *arg);
425 int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
426 int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
427 int add_oid_section(CONF *conf);
428 X509 *load_cert(const char *file, int format, const char *cert_descrip);
429 X509_CRL *load_crl(const char *infile, int format);
430 EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
431 const char *pass, ENGINE *e, const char *key_descrip);
432 EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
433 const char *pass, ENGINE *e, const char *key_descrip);
434 int load_certs(const char *file, STACK_OF(X509) **certs, int format,
435 const char *pass, const char *cert_descrip);
436 int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
437 const char *pass, const char *cert_descrip);
438 X509_STORE *setup_verify(const char *CAfile, const char *CApath,
439 int noCAfile, int noCApath);
440 __owur int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
441 const char *CApath, int noCAfile,
444 #ifndef OPENSSL_NO_CT
447 * Sets the file to load the Certificate Transparency log list from.
448 * If path is NULL, loads from the default file path.
449 * Returns 1 on success, 0 otherwise.
451 __owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
455 ENGINE *setup_engine(const char *engine, int debug);
456 void release_engine(ENGINE *e);
458 # ifndef OPENSSL_NO_OCSP
459 OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
460 const char *host, const char *path,
461 const char *port, int use_ssl,
462 STACK_OF(CONF_VALUE) *headers,
466 /* Functions defined in ca.c and also used in ocsp.c */
467 int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
468 ASN1_GENERALIZEDTIME **pinvtm, const char *str);
471 # define DB_exp_date 1
472 # define DB_rev_date 2
473 # define DB_serial 3 /* index - unique */
475 # define DB_name 5 /* index - unique when active and not
479 # define DB_TYPE_REV 'R' /* Revoked */
480 # define DB_TYPE_EXP 'E' /* Expired */
481 # define DB_TYPE_VAL 'V' /* Valid ; inserted with: ca ... -valid */
482 # define DB_TYPE_SUSP 'S' /* Suspended */
484 typedef struct db_attr_st {
487 typedef struct ca_db_st {
492 void* app_malloc(int sz, const char *what);
493 BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai);
494 int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial,
495 ASN1_INTEGER **retai);
496 int rotate_serial(const char *serialfile, const char *new_suffix,
497 const char *old_suffix);
498 int rand_serial(BIGNUM *b, ASN1_INTEGER *ai);
499 CA_DB *load_index(const char *dbfile, DB_ATTR *dbattr);
500 int index_index(CA_DB *db);
501 int save_index(const char *dbfile, const char *suffix, CA_DB *db);
502 int rotate_index(const char *dbfile, const char *new_suffix,
503 const char *old_suffix);
504 void free_index(CA_DB *db);
505 # define index_name_cmp_noconst(a, b) \
506 index_name_cmp((const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, a), \
507 (const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, b))
508 int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b);
509 int parse_yesno(const char *str, int def);
511 X509_NAME *parse_name(const char *str, long chtype, int multirdn);
512 void policies_print(X509_STORE_CTX *ctx);
513 int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
514 int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
515 int init_gen_str(EVP_PKEY_CTX **pctx,
516 const char *algname, ENGINE *e, int do_param);
517 int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
518 STACK_OF(OPENSSL_STRING) *sigopts);
519 int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
520 STACK_OF(OPENSSL_STRING) *sigopts);
521 int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
522 STACK_OF(OPENSSL_STRING) *sigopts);
524 extern char *psk_key;
527 unsigned char *next_protos_parse(size_t *outlen, const char *in);
529 void print_cert_checks(BIO *bio, X509 *x,
530 const char *checkhost,
531 const char *checkemail, const char *checkip);
533 void store_setup_crl_download(X509_STORE *st);
535 /* See OPT_FMT_xxx, above. */
536 /* On some platforms, it's important to distinguish between text and binary
537 * files. On some, there might even be specific file formats for different
538 * contents. The FORMAT_xxx macros are meant to express an intent with the
539 * file being read or created.
541 # define B_FORMAT_TEXT 0x8000
542 # define FORMAT_UNDEF 0
543 # define FORMAT_TEXT (1 | B_FORMAT_TEXT) /* Generic text */
544 # define FORMAT_BINARY 2 /* Generic binary */
545 # define FORMAT_BASE64 (3 | B_FORMAT_TEXT) /* Base64 */
546 # define FORMAT_ASN1 4 /* ASN.1/DER */
547 # define FORMAT_PEM (5 | B_FORMAT_TEXT)
548 # define FORMAT_PKCS12 6
549 # define FORMAT_SMIME (7 | B_FORMAT_TEXT)
550 # define FORMAT_ENGINE 8 /* Not really a file format */
551 # define FORMAT_PEMRSA (9 | B_FORMAT_TEXT) /* PEM RSAPubicKey format */
552 # define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
553 # define FORMAT_MSBLOB 11 /* MS Key blob format */
554 # define FORMAT_PVK 12 /* MS PVK file format */
555 # define FORMAT_HTTP 13 /* Download using HTTP */
556 # define FORMAT_NSS 14 /* NSS keylog format */
558 # define EXT_COPY_NONE 0
559 # define EXT_COPY_ADD 1
560 # define EXT_COPY_ALL 2
562 # define NETSCAPE_CERT_HDR "certificate"
564 # define APP_PASS_LEN 1024
567 * IETF RFC 5280 says serial number must be <= 20 bytes. Use 159 bits
568 * so that the first bit will never be one, so that the DER encoding
569 * rules won't force a leading octet.
571 # define SERIAL_RAND_BITS 159
573 int app_isdir(const char *);
574 int app_access(const char *, int flag);
575 int fileno_stdin(void);
576 int fileno_stdout(void);
577 int raw_read_stdin(void *, int);
578 int raw_write_stdout(const void *, int);
582 double app_tminterval(int stop, int usertime);
584 void make_uppercase(char *string);
586 typedef struct verify_options_st {
593 extern VERIFY_CB_ARGS verify_args;