]> git.ipfire.org Git - thirdparty/openssl.git/blame - apps/apps.h
Avoid duplicated code.
[thirdparty/openssl.git] / apps / apps.h
CommitLineData
846e33c7
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
a661b653 3 *
846e33c7
RS
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
a661b653 8 */
d02b48c6
RE
9
10#ifndef HEADER_APPS_H
0f113f3e
MC
11# define HEADER_APPS_H
12
13# include "e_os.h"
c21c7830
AP
14# if defined(__unix) || defined(__unix__)
15# include <sys/time.h> /* struct timeval for DTLS */
16# endif
3b061a00 17# include <assert.h>
0f113f3e 18
568b8020 19# include <openssl/e_os2.h>
03f887ca 20# include <openssl/ossl_typ.h>
0f113f3e
MC
21# include <openssl/bio.h>
22# include <openssl/x509.h>
23# include <openssl/lhash.h>
24# include <openssl/conf.h>
25# include <openssl/txt_db.h>
3c27208f
RS
26# include <openssl/engine.h>
27# include <openssl/ocsp.h>
0f113f3e 28# include <openssl/ossl_typ.h>
1fbab1dc 29# include <signal.h>
d02b48c6 30
7e1b7485
RS
31# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
32# define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
33# else
34# define openssl_fdset(a,b) FD_SET(a, b)
35# endif
36
18295f0c
RL
37/*
38 * quick macro when you need to pass an unsigned char instead of a char.
39 * this is true for some implementations of the is*() functions, for
40 * example.
41 */
42#define _UC(c) ((unsigned char)(c))
43
7e1b7485
RS
44int app_RAND_load_file(const char *file, int dont_warn);
45int app_RAND_write_file(const char *file);
0f113f3e
MC
46/*
47 * When `file' is NULL, use defaults. `bio_e' is for error messages.
48 */
a31011e8
BM
49void app_RAND_allow_write_file(void);
50long app_RAND_load_files(char *file); /* `file' is a list of files to read,
51 * separated by LIST_SEPARATOR_CHAR
52 * (see e_os.h). The string is
53 * destroyed! */
54
d02b48c6 55extern char *default_config_file;
7e1b7485
RS
56extern BIO *bio_in;
57extern BIO *bio_out;
d02b48c6 58extern BIO *bio_err;
a60994df
RL
59BIO *dup_bio_in(int format);
60BIO *dup_bio_out(int format);
149bd5d6 61BIO *dup_bio_err(int format);
bdd58d98
RL
62BIO *bio_open_owner(const char *filename, int format, int private);
63BIO *bio_open_default(const char *filename, char mode, int format);
64BIO *bio_open_default_quiet(const char *filename, char mode, int format);
296f54ee
RL
65CONF *app_load_config(const char *filename);
66CONF *app_load_config_quiet(const char *filename);
67int app_load_modules(const CONF *config);
7e1b7485 68void unbuffer(FILE *fp);
e1b9840e 69void wait_for_async(SSL *s);
75dd6c1a
MC
70# if defined(OPENSSL_SYS_MSDOS)
71int has_stdin_waiting(void);
72# endif
d02b48c6 73
a0754084 74void corrupt_signature(const ASN1_STRING *signature);
17ebf85a 75
7e1b7485
RS
76/*
77 * Common verification options.
78 */
79# define OPT_V_ENUM \
80 OPT_V__FIRST=2000, \
81 OPT_V_POLICY, OPT_V_PURPOSE, OPT_V_VERIFY_NAME, OPT_V_VERIFY_DEPTH, \
82 OPT_V_ATTIME, OPT_V_VERIFY_HOSTNAME, OPT_V_VERIFY_EMAIL, \
83 OPT_V_VERIFY_IP, OPT_V_IGNORE_CRITICAL, OPT_V_ISSUER_CHECKS, \
84 OPT_V_CRL_CHECK, OPT_V_CRL_CHECK_ALL, OPT_V_POLICY_CHECK, \
85 OPT_V_EXPLICIT_POLICY, OPT_V_INHIBIT_ANY, OPT_V_INHIBIT_MAP, \
86 OPT_V_X509_STRICT, OPT_V_EXTENDED_CRL, OPT_V_USE_DELTAS, \
87 OPT_V_POLICY_PRINT, OPT_V_CHECK_SS_SIG, OPT_V_TRUSTED_FIRST, \
88 OPT_V_SUITEB_128_ONLY, OPT_V_SUITEB_128, OPT_V_SUITEB_192, \
d35ff2c0 89 OPT_V_PARTIAL_CHAIN, OPT_V_NO_ALT_CHAINS, OPT_V_NO_CHECK_TIME, \
a392ef20 90 OPT_V_VERIFY_AUTH_LEVEL, OPT_V_ALLOW_PROXY_CERTS, \
7e1b7485
RS
91 OPT_V__LAST
92
93# define OPT_V_OPTIONS \
32eabe34
MR
94 { "policy", OPT_V_POLICY, 's', "adds policy to the acceptable policy set"}, \
95 { "purpose", OPT_V_PURPOSE, 's', \
5e136d7a
VD
96 "certificate chain purpose"}, \
97 { "verify_name", OPT_V_VERIFY_NAME, 's', "verification policy name"}, \
fbb82a60
VD
98 { "verify_depth", OPT_V_VERIFY_DEPTH, 'n', \
99 "chain depth limit" }, \
100 { "auth_level", OPT_V_VERIFY_AUTH_LEVEL, 'n', \
101 "chain authentication security level" }, \
5e136d7a 102 { "attime", OPT_V_ATTIME, 'M', "verification epoch time" }, \
32eabe34 103 { "verify_hostname", OPT_V_VERIFY_HOSTNAME, 's', \
5e136d7a 104 "expected peer hostname" }, \
32eabe34 105 { "verify_email", OPT_V_VERIFY_EMAIL, 's', \
5e136d7a 106 "expected peer email" }, \
32eabe34 107 { "verify_ip", OPT_V_VERIFY_IP, 's', \
5e136d7a 108 "expected peer IP address" }, \
32eabe34 109 { "ignore_critical", OPT_V_IGNORE_CRITICAL, '-', \
5e136d7a 110 "permit unhandled critical extensions"}, \
d33def66 111 { "issuer_checks", OPT_V_ISSUER_CHECKS, '-', "(deprecated)"}, \
5e136d7a
VD
112 { "crl_check", OPT_V_CRL_CHECK, '-', "check leaf certificate revocation" }, \
113 { "crl_check_all", OPT_V_CRL_CHECK_ALL, '-', "check full chain revocation" }, \
114 { "policy_check", OPT_V_POLICY_CHECK, '-', "perform rfc5280 policy checks"}, \
115 { "explicit_policy", OPT_V_EXPLICIT_POLICY, '-', \
116 "set policy variable require-explicit-policy"}, \
117 { "inhibit_any", OPT_V_INHIBIT_ANY, '-', \
0ad69cd6 118 "set policy variable inhibit-any-policy"}, \
5e136d7a 119 { "inhibit_map", OPT_V_INHIBIT_MAP, '-', \
0ad69cd6 120 "set policy variable inhibit-policy-mapping"}, \
32eabe34 121 { "x509_strict", OPT_V_X509_STRICT, '-', \
5e136d7a 122 "disable certificate compatibility work-arounds"}, \
32eabe34 123 { "extended_crl", OPT_V_EXTENDED_CRL, '-', \
5e136d7a 124 "enable extended CRL features"}, \
32eabe34 125 { "use_deltas", OPT_V_USE_DELTAS, '-', \
5e136d7a
VD
126 "use delta CRLs"}, \
127 { "policy_print", OPT_V_POLICY_PRINT, '-', \
128 "print policy processing diagnostics"}, \
32eabe34 129 { "check_ss_sig", OPT_V_CHECK_SS_SIG, '-', \
5e136d7a 130 "check root CA self-signatures"}, \
32eabe34 131 { "trusted_first", OPT_V_TRUSTED_FIRST, '-', \
5e136d7a
VD
132 "search trust store first (default)" }, \
133 { "suiteB_128_only", OPT_V_SUITEB_128_ONLY, '-', "Suite B 128-bit-only mode"}, \
32eabe34 134 { "suiteB_128", OPT_V_SUITEB_128, '-', \
5e136d7a
VD
135 "Suite B 128-bit mode allowing 192-bit algorithms"}, \
136 { "suiteB_192", OPT_V_SUITEB_192, '-', "Suite B 192-bit-only mode" }, \
32eabe34 137 { "partial_chain", OPT_V_PARTIAL_CHAIN, '-', \
5e136d7a
VD
138 "accept chains anchored by intermediate trust-store CAs"}, \
139 { "no_alt_chains", OPT_V_NO_ALT_CHAINS, '-', "(deprecated)" }, \
a392ef20
RL
140 { "no_check_time", OPT_V_NO_CHECK_TIME, '-', "ignore certificate validity time" }, \
141 { "allow_proxy_certs", OPT_V_ALLOW_PROXY_CERTS, '-', "allow the use of proxy certificates" }
7e1b7485
RS
142
143# define OPT_V_CASES \
144 OPT_V__FIRST: case OPT_V__LAST: break; \
145 case OPT_V_POLICY: \
146 case OPT_V_PURPOSE: \
147 case OPT_V_VERIFY_NAME: \
148 case OPT_V_VERIFY_DEPTH: \
fbb82a60 149 case OPT_V_VERIFY_AUTH_LEVEL: \
7e1b7485
RS
150 case OPT_V_ATTIME: \
151 case OPT_V_VERIFY_HOSTNAME: \
152 case OPT_V_VERIFY_EMAIL: \
153 case OPT_V_VERIFY_IP: \
154 case OPT_V_IGNORE_CRITICAL: \
155 case OPT_V_ISSUER_CHECKS: \
156 case OPT_V_CRL_CHECK: \
157 case OPT_V_CRL_CHECK_ALL: \
158 case OPT_V_POLICY_CHECK: \
159 case OPT_V_EXPLICIT_POLICY: \
160 case OPT_V_INHIBIT_ANY: \
161 case OPT_V_INHIBIT_MAP: \
162 case OPT_V_X509_STRICT: \
163 case OPT_V_EXTENDED_CRL: \
164 case OPT_V_USE_DELTAS: \
165 case OPT_V_POLICY_PRINT: \
166 case OPT_V_CHECK_SS_SIG: \
167 case OPT_V_TRUSTED_FIRST: \
168 case OPT_V_SUITEB_128_ONLY: \
169 case OPT_V_SUITEB_128: \
170 case OPT_V_SUITEB_192: \
171 case OPT_V_PARTIAL_CHAIN: \
d35ff2c0 172 case OPT_V_NO_ALT_CHAINS: \
a392ef20
RL
173 case OPT_V_NO_CHECK_TIME: \
174 case OPT_V_ALLOW_PROXY_CERTS
d02b48c6 175
7e1b7485
RS
176/*
177 * Common "extended"? options.
178 */
179# define OPT_X_ENUM \
180 OPT_X__FIRST=1000, \
181 OPT_X_KEY, OPT_X_CERT, OPT_X_CHAIN, OPT_X_CHAIN_BUILD, \
182 OPT_X_CERTFORM, OPT_X_KEYFORM, \
183 OPT_X__LAST
184
185# define OPT_X_OPTIONS \
32eabe34
MR
186 { "xkey", OPT_X_KEY, '<', "key for Extended certificates"}, \
187 { "xcert", OPT_X_CERT, '<', "cert for Extended certificates"}, \
188 { "xchain", OPT_X_CHAIN, '<', "chain for Extended certificates"}, \
189 { "xchain_build", OPT_X_CHAIN_BUILD, '-', \
190 "build certificate chain for the extended certificates"}, \
191 { "xcertform", OPT_X_CERTFORM, 'F', \
192 "format of Extended certificate (PEM or DER) PEM default " }, \
193 { "xkeyform", OPT_X_KEYFORM, 'F', \
0ad69cd6 194 "format of Extended certificate's key (PEM or DER) PEM default"}
7e1b7485
RS
195
196# define OPT_X_CASES \
197 OPT_X__FIRST: case OPT_X__LAST: break; \
198 case OPT_X_KEY: \
199 case OPT_X_CERT: \
200 case OPT_X_CHAIN: \
201 case OPT_X_CHAIN_BUILD: \
202 case OPT_X_CERTFORM: \
203 case OPT_X_KEYFORM
f10f4447 204
7e1b7485
RS
205/*
206 * Common SSL options.
207 * Any changes here must be coordinated with ../ssl/ssl_conf.c
208 */
209# define OPT_S_ENUM \
210 OPT_S__FIRST=3000, \
211 OPT_S_NOSSL3, OPT_S_NOTLS1, OPT_S_NOTLS1_1, OPT_S_NOTLS1_2, \
32eabe34 212 OPT_S_BUGS, OPT_S_NO_COMP, OPT_S_NOTICKET, \
7e1b7485
RS
213 OPT_S_SERVERPREF, OPT_S_LEGACYRENEG, OPT_S_LEGACYCONN, \
214 OPT_S_ONRESUMP, OPT_S_NOLEGACYCONN, OPT_S_STRICT, OPT_S_SIGALGS, \
215 OPT_S_CLIENTSIGALGS, OPT_S_CURVES, OPT_S_NAMEDCURVE, OPT_S_CIPHER, \
cc5a9ba4 216 OPT_S_DHPARAM, OPT_S_DEBUGBROKE, OPT_S_COMP, \
7e1b7485
RS
217 OPT_S__LAST
218
219# define OPT_S_OPTIONS \
32eabe34
MR
220 {"no_ssl3", OPT_S_NOSSL3, '-',"Just disable SSLv3" }, \
221 {"no_tls1", OPT_S_NOTLS1, '-', "Just disable TLSv1"}, \
222 {"no_tls1_1", OPT_S_NOTLS1_1, '-', "Just disable TLSv1.1" }, \
223 {"no_tls1_2", OPT_S_NOTLS1_2, '-', "Just disable TLSv1.2"}, \
224 {"bugs", OPT_S_BUGS, '-', "Turn on SSL bug compatibility"}, \
cc5a9ba4 225 {"no_comp", OPT_S_NO_COMP, '-', "Disable SSL/TLS compression (default)" }, \
dc5744cb 226 {"comp", OPT_S_COMP, '-', "Use SSL/TLS-level compression" }, \
32eabe34
MR
227 {"no_ticket", OPT_S_NOTICKET, '-', \
228 "Disable use of TLS session tickets"}, \
229 {"serverpref", OPT_S_SERVERPREF, '-', "Use server's cipher preferences"}, \
230 {"legacy_renegotiation", OPT_S_LEGACYRENEG, '-', \
231 "Enable use of legacy renegotiation (dangerous)"}, \
232 {"legacy_server_connect", OPT_S_LEGACYCONN, '-', \
233 "Allow initial connection to servers that don't support RI"}, \
234 {"no_resumption_on_reneg", OPT_S_ONRESUMP, '-', \
235 "Disallow session resumption on renegotiation"}, \
236 {"no_legacy_server_connect", OPT_S_NOLEGACYCONN, '-', \
237 "Disallow initial connection to servers that don't support RI"}, \
238 {"strict", OPT_S_STRICT, '-', \
239 "Enforce strict certificate checks as per TLS standard"}, \
ad775e04
HK
240 {"sigalgs", OPT_S_SIGALGS, 's', \
241 "Signature algorithms to support (colon-separated list)" }, \
242 {"client_sigalgs", OPT_S_CLIENTSIGALGS, 's', \
243 "Signature algorithms to support for client certificate" \
244 " authentication (colon-separated list)" }, \
245 {"curves", OPT_S_CURVES, 's', \
246 "Elliptic curves to advertise (colon-separated list)" }, \
247 {"named_curve", OPT_S_NAMEDCURVE, 's', \
248 "Elliptic curve used for ECDHE (server-side only)" }, \
32eabe34
MR
249 {"cipher", OPT_S_CIPHER, 's', "Specify cipher list to be used"}, \
250 {"dhparam", OPT_S_DHPARAM, '<', \
251 "DH parameter file to use, in cert file if not specified"}, \
252 {"debug_broken_protocol", OPT_S_DEBUGBROKE, '-', \
253 "Perform all sorts of protocol violations for testing purposes"}
7e1b7485
RS
254
255# define OPT_S_CASES \
256 OPT_S__FIRST: case OPT_S__LAST: break; \
257 case OPT_S_NOSSL3: \
258 case OPT_S_NOTLS1: \
259 case OPT_S_NOTLS1_1: \
260 case OPT_S_NOTLS1_2: \
261 case OPT_S_BUGS: \
cc5a9ba4 262 case OPT_S_NO_COMP: \
dc5744cb 263 case OPT_S_COMP: \
7e1b7485
RS
264 case OPT_S_NOTICKET: \
265 case OPT_S_SERVERPREF: \
266 case OPT_S_LEGACYRENEG: \
267 case OPT_S_LEGACYCONN: \
268 case OPT_S_ONRESUMP: \
269 case OPT_S_NOLEGACYCONN: \
270 case OPT_S_STRICT: \
271 case OPT_S_SIGALGS: \
272 case OPT_S_CLIENTSIGALGS: \
273 case OPT_S_CURVES: \
274 case OPT_S_NAMEDCURVE: \
275 case OPT_S_CIPHER: \
276 case OPT_S_DHPARAM: \
277 case OPT_S_DEBUGBROKE
d02b48c6 278
4bbd4ba6
MC
279#define IS_NO_PROT_FLAG(o) \
280 (o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \
281 || o == OPT_S_NOTLS1_2)
282
7e1b7485
RS
283/*
284 * Option parsing.
285 */
286extern const char OPT_HELP_STR[];
287extern const char OPT_MORE_STR[];
288typedef struct options_st {
289 const char *name;
290 int retval;
291 /*
292 * value type: - no value (also the value zero), n number, p positive
6755ff11
MR
293 * number, u unsigned, l long, s string, < input file, > output file,
294 * f any format, F der/pem format , E der/pem/engine format identifier.
295 * l, n and u include zero; p does not.
7e1b7485
RS
296 */
297 int valtype;
298 const char *helpstr;
299} OPTIONS;
300
3e8e688f
RS
301/*
302 * A string/int pairing; widely use for option value lookup, hence the
303 * name OPT_PAIR. But that name is misleading in s_cb.c, so we also use
304 * the "generic" name STRINT_PAIR.
305 */
306typedef struct string_int_pair_st {
7e1b7485
RS
307 const char *name;
308 int retval;
3e8e688f 309} OPT_PAIR, STRINT_PAIR;
7e1b7485
RS
310
311/* Flags to pass into opt_format; see FORMAT_xxx, below. */
312# define OPT_FMT_PEMDER (1L << 1)
313# define OPT_FMT_PKCS12 (1L << 2)
314# define OPT_FMT_SMIME (1L << 3)
315# define OPT_FMT_ENGINE (1L << 4)
316# define OPT_FMT_MSBLOB (1L << 5)
317# define OPT_FMT_NETSCAPE (1L << 6)
318# define OPT_FMT_NSS (1L << 7)
319# define OPT_FMT_TEXT (1L << 8)
320# define OPT_FMT_HTTP (1L << 9)
321# define OPT_FMT_PVK (1L << 10)
0c20802c 322# define OPT_FMT_PDE (OPT_FMT_PEMDER | OPT_FMT_ENGINE)
f47e5647 323# define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME)
7e1b7485
RS
324# define OPT_FMT_ANY ( \
325 OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \
326 OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \
327 OPT_FMT_NSS | OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
328
329char *opt_progname(const char *argv0);
330char *opt_getprog(void);
331char *opt_init(int ac, char **av, const OPTIONS * o);
1bd8bc55 332int opt_next(void);
7e1b7485
RS
333int opt_format(const char *s, unsigned long flags, int *result);
334int opt_int(const char *arg, int *result);
335int opt_ulong(const char *arg, unsigned long *result);
336int opt_long(const char *arg, long *result);
d94a1a70
VD
337#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
338 defined(INTMAX_MAX) && defined(UINTMAX_MAX)
03f887ca
VD
339int opt_imax(const char *arg, intmax_t *result);
340int opt_umax(const char *arg, uintmax_t *result);
1bd8bc55
RP
341#else
342# define opt_imax opt_long
343# define opt_umax opt_ulong
344# define intmax_t long
345# define uintmax_t unsigned long
03f887ca 346#endif
7e1b7485
RS
347int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
348int opt_cipher(const char *name, const EVP_CIPHER **cipherp);
349int opt_md(const char *name, const EVP_MD **mdp);
350char *opt_arg(void);
351char *opt_flag(void);
352char *opt_unknown(void);
353char *opt_reset(void);
354char **opt_rest(void);
355int opt_num_rest(void);
356int opt_verify(int i, X509_VERIFY_PARAM *vpm);
357void opt_help(const OPTIONS * list);
358int opt_format_error(const char *s, unsigned long flags);
7bf7333d 359
0f113f3e 360typedef struct args_st {
7e1b7485
RS
361 int size;
362 int argc;
363 char **argv;
0f113f3e 364} ARGS;
7bf7333d 365
368058d0
RL
366/*
367 * VMS C only for now, implemented in vms_decc_init.c
368 * If other C compilers forget to terminate argv with NULL, this function
369 * can be re-used.
370 */
371char **copy_argv(int *argc, char *argv[]);
4e155ec4
AP
372/*
373 * Win32-specific argv initialization that splits OS-supplied UNICODE
374 * command line string to array of UTF8-encoded strings.
375 */
376void win32_utf8argv(int *argc, char **argv[]);
087ca80a
RL
377
378
0f113f3e
MC
379# define PW_MIN_LENGTH 4
380typedef struct pw_cb_data {
381 const void *password;
382 const char *prompt_info;
383} PW_CB_DATA;
d02b48c6 384
0f113f3e 385int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_data);
30b4c272 386
40889b9c
LJ
387int setup_ui_method(void);
388void destroy_ui_method(void);
2fe5adc3 389
7e1b7485 390int chopup_args(ARGS *arg, char *buf);
0f113f3e 391# ifdef HEADER_X509_H
954ef7ef 392int dump_cert_text(BIO *out, X509 *x);
0f113f3e
MC
393void print_name(BIO *out, const char *title, X509_NAME *nm,
394 unsigned long lflags);
395# endif
2ac6115d
RL
396void print_bignum_var(BIO *, const BIGNUM *, const char*,
397 int, unsigned char *);
7e1b7485 398void print_array(BIO *, const char *, int, const unsigned char *);
8ca533e3 399int set_cert_ex(unsigned long *flags, const char *arg);
a657546f 400int set_name_ex(unsigned long *flags, const char *arg);
791bd0cd
DSH
401int set_ext_copy(int *copy_type, const char *arg);
402int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
cc696296 403int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
7e1b7485 404int add_oid_section(CONF *conf);
a773b52a 405X509 *load_cert(const char *file, int format, const char *cert_descrip);
0090a686 406X509_CRL *load_crl(const char *infile, int format);
7e1b7485 407EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
0f113f3e 408 const char *pass, ENGINE *e, const char *key_descrip);
7e1b7485 409EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
0f113f3e 410 const char *pass, ENGINE *e, const char *key_descrip);
0996dc54 411int load_certs(const char *file, STACK_OF(X509) **certs, int format,
a773b52a 412 const char *pass, const char *cert_descrip);
0996dc54 413int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
a773b52a 414 const char *pass, const char *cert_descrip);
cc696296 415X509_STORE *setup_verify(const char *CAfile, const char *CApath,
2b6bcb70 416 int noCAfile, int noCApath);
5da65ef2
RP
417__owur int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
418 const char *CApath, int noCAfile,
419 int noCApath);
ca74c38d 420
b5369582
RP
421#ifndef OPENSSL_NO_CT
422
ca74c38d
RP
423/*
424 * Sets the file to load the Certificate Transparency log list from.
425 * If path is NULL, loads from the default file path.
426 * Returns 1 on success, 0 otherwise.
427 */
5da65ef2 428__owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
dd696a55 429
b5369582
RP
430#endif
431
333b070e
RS
432# ifdef OPENSSL_NO_ENGINE
433# define setup_engine(engine, debug) NULL
434# else
7e1b7485 435ENGINE *setup_engine(const char *engine, int debug);
0f113f3e 436# endif
0f113f3e 437# ifndef OPENSSL_NO_OCSP
7e1b7485 438OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
0f113f3e
MC
439 const char *host, const char *path,
440 const char *port, int use_ssl,
82c49427 441 STACK_OF(CONF_VALUE) *headers,
0f113f3e
MC
442 int req_timeout);
443# endif
67c8e7f4 444
ee306a13
DSH
445/* Functions defined in ca.c and also used in ocsp.c */
446int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
0f113f3e
MC
447 ASN1_GENERALIZEDTIME **pinvtm, const char *str);
448
449# define DB_type 0
450# define DB_exp_date 1
451# define DB_rev_date 2
452# define DB_serial 3 /* index - unique */
453# define DB_file 4
454# define DB_name 5 /* index - unique when active and not
455 * disabled */
456# define DB_NUMBER 6
457
458# define DB_TYPE_REV 'R'
459# define DB_TYPE_EXP 'E'
460# define DB_TYPE_VAL 'V'
461
462typedef struct db_attr_st {
463 int unique_subject;
464} DB_ATTR;
465typedef struct ca_db_st {
466 DB_ATTR attributes;
467 TXT_DB *db;
468} CA_DB;
f85b68cd 469
68dc6824 470void* app_malloc(int sz, const char *what);
cc696296
F
471BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai);
472int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial,
0f113f3e 473 ASN1_INTEGER **retai);
cc696296
F
474int rotate_serial(const char *serialfile, const char *new_suffix,
475 const char *old_suffix);
64674bcc 476int rand_serial(BIGNUM *b, ASN1_INTEGER *ai);
cc696296 477CA_DB *load_index(const char *dbfile, DB_ATTR *dbattr);
f85b68cd 478int index_index(CA_DB *db);
7d727231 479int save_index(const char *dbfile, const char *suffix, CA_DB *db);
0f113f3e
MC
480int rotate_index(const char *dbfile, const char *new_suffix,
481 const char *old_suffix);
f85b68cd 482void free_index(CA_DB *db);
0f113f3e
MC
483# define index_name_cmp_noconst(a, b) \
484 index_name_cmp((const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, a), \
485 (const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, b))
c869da88 486int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b);
ff990440 487int parse_yesno(const char *str, int def);
ee306a13 488
db4c08f0 489X509_NAME *parse_name(const char *str, long chtype, int multirdn);
c431798e 490int args_verify(char ***pargs, int *pargc,
7e1b7485 491 int *badarg, X509_VERIFY_PARAM **pm);
ecf3a1fb 492void policies_print(X509_STORE_CTX *ctx);
a9164153 493int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
0c20802c 494int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
7e1b7485 495int init_gen_str(EVP_PKEY_CTX **pctx,
0f113f3e 496 const char *algname, ENGINE *e, int do_param);
7e1b7485 497int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
0f113f3e 498 STACK_OF(OPENSSL_STRING) *sigopts);
7e1b7485 499int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
0f113f3e 500 STACK_OF(OPENSSL_STRING) *sigopts);
7e1b7485 501int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
0f113f3e
MC
502 STACK_OF(OPENSSL_STRING) *sigopts);
503# ifndef OPENSSL_NO_PSK
f3b7bdad 504extern char *psk_key;
0f113f3e 505# endif
eee6c81a 506
817cd0d5 507unsigned char *next_protos_parse(size_t *outlen, const char *in);
71fa4513 508
a70da5b3 509void print_cert_checks(BIO *bio, X509 *x,
0f113f3e
MC
510 const char *checkhost,
511 const char *checkemail, const char *checkip);
a70da5b3 512
0090a686
DSH
513void store_setup_crl_download(X509_STORE *st);
514
7e1b7485 515/* See OPT_FMT_xxx, above. */
bdd58d98
RL
516/* On some platforms, it's important to distinguish between text and binary
517 * files. On some, there might even be specific file formats for different
518 * contents. The FORMAT_xxx macros are meant to express an intent with the
519 * file being read or created.
520 */
d303b9d8 521# define B_FORMAT_TEXT 0x8000
0f113f3e 522# define FORMAT_UNDEF 0
bdd58d98
RL
523# define FORMAT_TEXT (1 | B_FORMAT_TEXT) /* Generic text */
524# define FORMAT_BINARY 2 /* Generic binary */
525# define FORMAT_BASE64 (3 | B_FORMAT_TEXT) /* Base64 */
526# define FORMAT_ASN1 4 /* ASN.1/DER */
527# define FORMAT_PEM (5 | B_FORMAT_TEXT)
528# define FORMAT_PKCS12 6
529# define FORMAT_SMIME (7 | B_FORMAT_TEXT)
530# define FORMAT_ENGINE 8 /* Not really a file format */
d303b9d8
RL
531# define FORMAT_PEMRSA (9 | B_FORMAT_TEXT) /* PEM RSAPubicKey format */
532# define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
533# define FORMAT_MSBLOB 11 /* MS Key blob format */
534# define FORMAT_PVK 12 /* MS PVK file format */
535# define FORMAT_HTTP 13 /* Download using HTTP */
536# define FORMAT_NSS 14 /* NSS keylog format */
0f113f3e
MC
537
538# define EXT_COPY_NONE 0
539# define EXT_COPY_ADD 1
540# define EXT_COPY_ALL 2
541
542# define NETSCAPE_CERT_HDR "certificate"
543
544# define APP_PASS_LEN 1024
545
546# define SERIAL_RAND_BITS 64
64674bcc 547
ffa10187 548int app_isdir(const char *);
7e1b7485 549int app_access(const char *, int flag);
0f113f3e
MC
550int raw_read_stdin(void *, int);
551int raw_write_stdout(const void *, int);
0a39d8f2 552
0f113f3e
MC
553# define TM_START 0
554# define TM_STOP 1
555double app_tminterval(int stop, int usertime);
ee2ffc27 556
acc00492
F
557typedef struct verify_options_st {
558 int depth;
559 int quiet;
560 int error;
561 int return_error;
562} VERIFY_CB_ARGS;
563
564extern VERIFY_CB_ARGS verify_args;
df2ee0e2 565
1e7e1c8d
VD
566# include "progs.h"
567
ee2ffc27 568#endif