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