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