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