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