1/*
2 * WARNING: do not edit!
3 * Generated by Makefile from ../include/openssl/x509_vfy.h.in
4 *
5 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
6 *
7 * Licensed under the Apache License 2.0 (the "License"). You may not use
8 * this file except in compliance with the License. You can obtain a copy
9 * in the file LICENSE in the source distribution or at
10 * https://www.openssl.org/source/license.html
11 */
12
13
14
15#ifndef OPENSSL_X509_VFY_H
16# define OPENSSL_X509_VFY_H
17# pragma once
18
19# include <openssl/macros.h>
20# ifndef OPENSSL_NO_DEPRECATED_3_0
21# define HEADER_X509_VFY_H
22# endif
23
24/*
25 * Protect against recursion, x509.h and x509_vfy.h each include the other.
26 */
27# ifndef OPENSSL_X509_H
28# include <openssl/x509.h>
29# endif
30
31# include <openssl/opensslconf.h>
32# include <openssl/lhash.h>
33# include <openssl/bio.h>
34# include <openssl/crypto.h>
35# include <openssl/symhacks.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*-
42SSL_CTX -> X509_STORE
43 -> X509_LOOKUP
44 ->X509_LOOKUP_METHOD
45 -> X509_LOOKUP
46 ->X509_LOOKUP_METHOD
47
48SSL -> X509_STORE_CTX
49 ->X509_STORE
50
51The X509_STORE holds the tables etc for verification stuff.
52A X509_STORE_CTX is used while validating a single certificate.
53The X509_STORE has X509_LOOKUPs for looking up certs.
54The X509_STORE then calls a function to actually verify the
55certificate chain.
56*/
57
58typedef enum {
59 X509_LU_NONE = 0,
60 X509_LU_X509, X509_LU_CRL
61} X509_LOOKUP_TYPE;
62
63#ifndef OPENSSL_NO_DEPRECATED_1_1_0
64#define X509_LU_RETRY -1
65#define X509_LU_FAIL 0
66#endif
67
68SKM_DEFINE_STACK_OF_INTERNAL(X509_LOOKUP, X509_LOOKUP, X509_LOOKUP)
69#define sk_X509_LOOKUP_num(sk) OPENSSL_sk_num(ossl_check_const_X509_LOOKUP_sk_type(sk))
70#define sk_X509_LOOKUP_value(sk, idx) ((X509_LOOKUP *)OPENSSL_sk_value(ossl_check_const_X509_LOOKUP_sk_type(sk), (idx)))
71#define sk_X509_LOOKUP_new(cmp) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new(ossl_check_X509_LOOKUP_compfunc_type(cmp)))
72#define sk_X509_LOOKUP_new_null() ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_null())
73#define sk_X509_LOOKUP_new_reserve(cmp, n) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_reserve(ossl_check_X509_LOOKUP_compfunc_type(cmp), (n)))
74#define sk_X509_LOOKUP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_LOOKUP_sk_type(sk), (n))
75#define sk_X509_LOOKUP_free(sk) OPENSSL_sk_free(ossl_check_X509_LOOKUP_sk_type(sk))
76#define sk_X509_LOOKUP_zero(sk) OPENSSL_sk_zero(ossl_check_X509_LOOKUP_sk_type(sk))
77#define sk_X509_LOOKUP_delete(sk, i) ((X509_LOOKUP *)OPENSSL_sk_delete(ossl_check_X509_LOOKUP_sk_type(sk), (i)))
78#define sk_X509_LOOKUP_delete_ptr(sk, ptr) ((X509_LOOKUP *)OPENSSL_sk_delete_ptr(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)))
79#define sk_X509_LOOKUP_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
80#define sk_X509_LOOKUP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
81#define sk_X509_LOOKUP_pop(sk) ((X509_LOOKUP *)OPENSSL_sk_pop(ossl_check_X509_LOOKUP_sk_type(sk)))
82#define sk_X509_LOOKUP_shift(sk) ((X509_LOOKUP *)OPENSSL_sk_shift(ossl_check_X509_LOOKUP_sk_type(sk)))
83#define sk_X509_LOOKUP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_LOOKUP_sk_type(sk),ossl_check_X509_LOOKUP_freefunc_type(freefunc))
84#define sk_X509_LOOKUP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), (idx))
85#define sk_X509_LOOKUP_set(sk, idx, ptr) ((X509_LOOKUP *)OPENSSL_sk_set(ossl_check_X509_LOOKUP_sk_type(sk), (idx), ossl_check_X509_LOOKUP_type(ptr)))
86#define sk_X509_LOOKUP_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
87#define sk_X509_LOOKUP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
88#define sk_X509_LOOKUP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), pnum)
89#define sk_X509_LOOKUP_sort(sk) OPENSSL_sk_sort(ossl_check_X509_LOOKUP_sk_type(sk))
90#define sk_X509_LOOKUP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_LOOKUP_sk_type(sk))
91#define sk_X509_LOOKUP_dup(sk) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_dup(ossl_check_const_X509_LOOKUP_sk_type(sk)))
92#define sk_X509_LOOKUP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_copyfunc_type(copyfunc), ossl_check_X509_LOOKUP_freefunc_type(freefunc)))
93#define sk_X509_LOOKUP_set_cmp_func(sk, cmp) ((sk_X509_LOOKUP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_compfunc_type(cmp)))
94SKM_DEFINE_STACK_OF_INTERNAL(X509_OBJECT, X509_OBJECT, X509_OBJECT)
95#define sk_X509_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_X509_OBJECT_sk_type(sk))
96#define sk_X509_OBJECT_value(sk, idx) ((X509_OBJECT *)OPENSSL_sk_value(ossl_check_const_X509_OBJECT_sk_type(sk), (idx)))
97#define sk_X509_OBJECT_new(cmp) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new(ossl_check_X509_OBJECT_compfunc_type(cmp)))
98#define sk_X509_OBJECT_new_null() ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_null())
99#define sk_X509_OBJECT_new_reserve(cmp, n) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_X509_OBJECT_compfunc_type(cmp), (n)))
100#define sk_X509_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_OBJECT_sk_type(sk), (n))
101#define sk_X509_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_X509_OBJECT_sk_type(sk))
102#define sk_X509_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_X509_OBJECT_sk_type(sk))
103#define sk_X509_OBJECT_delete(sk, i) ((X509_OBJECT *)OPENSSL_sk_delete(ossl_check_X509_OBJECT_sk_type(sk), (i)))
104#define sk_X509_OBJECT_delete_ptr(sk, ptr) ((X509_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)))
105#define sk_X509_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr))
106#define sk_X509_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr))
107#define sk_X509_OBJECT_pop(sk) ((X509_OBJECT *)OPENSSL_sk_pop(ossl_check_X509_OBJECT_sk_type(sk)))
108#define sk_X509_OBJECT_shift(sk) ((X509_OBJECT *)OPENSSL_sk_shift(ossl_check_X509_OBJECT_sk_type(sk)))
109#define sk_X509_OBJECT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_OBJECT_sk_type(sk),ossl_check_X509_OBJECT_freefunc_type(freefunc))
110#define sk_X509_OBJECT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), (idx))
111#define sk_X509_OBJECT_set(sk, idx, ptr) ((X509_OBJECT *)OPENSSL_sk_set(ossl_check_X509_OBJECT_sk_type(sk), (idx), ossl_check_X509_OBJECT_type(ptr)))
112#define sk_X509_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr))
113#define sk_X509_OBJECT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr))
114#define sk_X509_OBJECT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), pnum)
115#define sk_X509_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_X509_OBJECT_sk_type(sk))
116#define sk_X509_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_OBJECT_sk_type(sk))
117#define sk_X509_OBJECT_dup(sk) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_X509_OBJECT_sk_type(sk)))
118#define sk_X509_OBJECT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_copyfunc_type(copyfunc), ossl_check_X509_OBJECT_freefunc_type(freefunc)))
119#define sk_X509_OBJECT_set_cmp_func(sk, cmp) ((sk_X509_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_compfunc_type(cmp)))
120SKM_DEFINE_STACK_OF_INTERNAL(X509_VERIFY_PARAM, X509_VERIFY_PARAM, X509_VERIFY_PARAM)
121#define sk_X509_VERIFY_PARAM_num(sk) OPENSSL_sk_num(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk))
122#define sk_X509_VERIFY_PARAM_value(sk, idx) ((X509_VERIFY_PARAM *)OPENSSL_sk_value(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), (idx)))
123#define sk_X509_VERIFY_PARAM_new(cmp) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new(ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp)))
124#define sk_X509_VERIFY_PARAM_new_null() ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_null())
125#define sk_X509_VERIFY_PARAM_new_reserve(cmp, n) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_reserve(ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp), (n)))
126#define sk_X509_VERIFY_PARAM_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (n))
127#define sk_X509_VERIFY_PARAM_free(sk) OPENSSL_sk_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk))
128#define sk_X509_VERIFY_PARAM_zero(sk) OPENSSL_sk_zero(ossl_check_X509_VERIFY_PARAM_sk_type(sk))
129#define sk_X509_VERIFY_PARAM_delete(sk, i) ((X509_VERIFY_PARAM *)OPENSSL_sk_delete(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (i)))
130#define sk_X509_VERIFY_PARAM_delete_ptr(sk, ptr) ((X509_VERIFY_PARAM *)OPENSSL_sk_delete_ptr(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr)))
131#define sk_X509_VERIFY_PARAM_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr))
132#define sk_X509_VERIFY_PARAM_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr))
133#define sk_X509_VERIFY_PARAM_pop(sk) ((X509_VERIFY_PARAM *)OPENSSL_sk_pop(ossl_check_X509_VERIFY_PARAM_sk_type(sk)))
134#define sk_X509_VERIFY_PARAM_shift(sk) ((X509_VERIFY_PARAM *)OPENSSL_sk_shift(ossl_check_X509_VERIFY_PARAM_sk_type(sk)))
135#define sk_X509_VERIFY_PARAM_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk),ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc))
136#define sk_X509_VERIFY_PARAM_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr), (idx))
137#define sk_X509_VERIFY_PARAM_set(sk, idx, ptr) ((X509_VERIFY_PARAM *)OPENSSL_sk_set(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (idx), ossl_check_X509_VERIFY_PARAM_type(ptr)))
138#define sk_X509_VERIFY_PARAM_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr))
139#define sk_X509_VERIFY_PARAM_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr))
140#define sk_X509_VERIFY_PARAM_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_type(ptr), pnum)
141#define sk_X509_VERIFY_PARAM_sort(sk) OPENSSL_sk_sort(ossl_check_X509_VERIFY_PARAM_sk_type(sk))
142#define sk_X509_VERIFY_PARAM_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk))
143#define sk_X509_VERIFY_PARAM_dup(sk) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_dup(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)))
144#define sk_X509_VERIFY_PARAM_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_copyfunc_type(copyfunc), ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc)))
145#define sk_X509_VERIFY_PARAM_set_cmp_func(sk, cmp) ((sk_X509_VERIFY_PARAM_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_VERIFY_PARAM_sk_type(sk), ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp)))
146
147
148/* This is used for a table of trust checking functions */
149typedef struct x509_trust_st {
150 int trust;
151 int flags;
152 int (*check_trust) (struct x509_trust_st *, X509 *, int);
153 char *name;
154 int arg1;
155 void *arg2;
156} X509_TRUST;
157SKM_DEFINE_STACK_OF_INTERNAL(X509_TRUST, X509_TRUST, X509_TRUST)
158#define sk_X509_TRUST_num(sk) OPENSSL_sk_num(ossl_check_const_X509_TRUST_sk_type(sk))
159#define sk_X509_TRUST_value(sk, idx) ((X509_TRUST *)OPENSSL_sk_value(ossl_check_const_X509_TRUST_sk_type(sk), (idx)))
160#define sk_X509_TRUST_new(cmp) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new(ossl_check_X509_TRUST_compfunc_type(cmp)))
161#define sk_X509_TRUST_new_null() ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_null())
162#define sk_X509_TRUST_new_reserve(cmp, n) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_reserve(ossl_check_X509_TRUST_compfunc_type(cmp), (n)))
163#define sk_X509_TRUST_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_TRUST_sk_type(sk), (n))
164#define sk_X509_TRUST_free(sk) OPENSSL_sk_free(ossl_check_X509_TRUST_sk_type(sk))
165#define sk_X509_TRUST_zero(sk) OPENSSL_sk_zero(ossl_check_X509_TRUST_sk_type(sk))
166#define sk_X509_TRUST_delete(sk, i) ((X509_TRUST *)OPENSSL_sk_delete(ossl_check_X509_TRUST_sk_type(sk), (i)))
167#define sk_X509_TRUST_delete_ptr(sk, ptr) ((X509_TRUST *)OPENSSL_sk_delete_ptr(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)))
168#define sk_X509_TRUST_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr))
169#define sk_X509_TRUST_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr))
170#define sk_X509_TRUST_pop(sk) ((X509_TRUST *)OPENSSL_sk_pop(ossl_check_X509_TRUST_sk_type(sk)))
171#define sk_X509_TRUST_shift(sk) ((X509_TRUST *)OPENSSL_sk_shift(ossl_check_X509_TRUST_sk_type(sk)))
172#define sk_X509_TRUST_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_TRUST_sk_type(sk),ossl_check_X509_TRUST_freefunc_type(freefunc))
173#define sk_X509_TRUST_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), (idx))
174#define sk_X509_TRUST_set(sk, idx, ptr) ((X509_TRUST *)OPENSSL_sk_set(ossl_check_X509_TRUST_sk_type(sk), (idx), ossl_check_X509_TRUST_type(ptr)))
175#define sk_X509_TRUST_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr))
176#define sk_X509_TRUST_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr))
177#define sk_X509_TRUST_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), pnum)
178#define sk_X509_TRUST_sort(sk) OPENSSL_sk_sort(ossl_check_X509_TRUST_sk_type(sk))
179#define sk_X509_TRUST_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_TRUST_sk_type(sk))
180#define sk_X509_TRUST_dup(sk) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_dup(ossl_check_const_X509_TRUST_sk_type(sk)))
181#define sk_X509_TRUST_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_TRUST) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_copyfunc_type(copyfunc), ossl_check_X509_TRUST_freefunc_type(freefunc)))
182#define sk_X509_TRUST_set_cmp_func(sk, cmp) ((sk_X509_TRUST_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_compfunc_type(cmp)))
183
184
185/* standard trust ids */
186# define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */
187# define X509_TRUST_COMPAT 1
188# define X509_TRUST_SSL_CLIENT 2
189# define X509_TRUST_SSL_SERVER 3
190# define X509_TRUST_EMAIL 4
191# define X509_TRUST_OBJECT_SIGN 5
192# define X509_TRUST_OCSP_SIGN 6
193# define X509_TRUST_OCSP_REQUEST 7
194# define X509_TRUST_TSA 8
195/* Keep these up to date! */
196# define X509_TRUST_MIN 1
197# define X509_TRUST_MAX 8
198
199/* trust_flags values */
200# define X509_TRUST_DYNAMIC (1U << 0)
201# define X509_TRUST_DYNAMIC_NAME (1U << 1)
202/* No compat trust if self-signed, preempts "DO_SS" */
203# define X509_TRUST_NO_SS_COMPAT (1U << 2)
204/* Compat trust if no explicit accepted trust EKUs */
205# define X509_TRUST_DO_SS_COMPAT (1U << 3)
206/* Accept "anyEKU" as a wildcard rejection OID and as a wildcard trust OID */
207# define X509_TRUST_OK_ANY_EKU (1U << 4)
208
209/* check_trust return codes */
210# define X509_TRUST_TRUSTED 1
211# define X509_TRUST_REJECTED 2
212# define X509_TRUST_UNTRUSTED 3
213
214int X509_TRUST_set(int *t, int trust);
215int X509_TRUST_get_count(void);
216X509_TRUST *X509_TRUST_get0(int idx);
217int X509_TRUST_get_by_id(int id);
218int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
219 const char *name, int arg1, void *arg2);
220void X509_TRUST_cleanup(void);
221int X509_TRUST_get_flags(const X509_TRUST *xp);
222char *X509_TRUST_get0_name(const X509_TRUST *xp);
223int X509_TRUST_get_trust(const X509_TRUST *xp);
224
225int X509_trusted(const X509 *x);
226int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
227int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);
228void X509_trust_clear(X509 *x);
229void X509_reject_clear(X509 *x);
230STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x);
231STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x);
232
233int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,
234 int);
235int X509_check_trust(X509 *x, int id, int flags);
236
237int X509_verify_cert(X509_STORE_CTX *ctx);
238int X509_STORE_CTX_verify(X509_STORE_CTX *ctx);
239STACK_OF(X509) *X509_build_chain(X509 *target, STACK_OF(X509) *certs,
240 X509_STORE *store, int with_self_signed,
241 OSSL_LIB_CTX *libctx, const char *propq);
242
243int X509_STORE_set_depth(X509_STORE *store, int depth);
244
245typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *);
246int X509_STORE_CTX_print_verify_cb(int ok, X509_STORE_CTX *ctx);
247typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
248typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,
249 X509_STORE_CTX *ctx, X509 *x);
250typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,
251 X509 *x, X509 *issuer);
252typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
253typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,
254 X509_CRL **crl, X509 *x);
255typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);
256typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,
257 X509_CRL *crl, X509 *x);
258typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);
259typedef STACK_OF(X509)
260 *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,
261 const X509_NAME *nm);
262typedef STACK_OF(X509_CRL)
263 *(*X509_STORE_CTX_lookup_crls_fn)(const X509_STORE_CTX *ctx,
264 const X509_NAME *nm);
265typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);
266
267void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
268
269# define X509_STORE_CTX_set_app_data(ctx,data) \
270 X509_STORE_CTX_set_ex_data(ctx,0,data)
271# define X509_STORE_CTX_get_app_data(ctx) \
272 X509_STORE_CTX_get_ex_data(ctx,0)
273
274# define X509_L_FILE_LOAD 1
275# define X509_L_ADD_DIR 2
276# define X509_L_ADD_STORE 3
277# define X509_L_LOAD_STORE 4
278
279# define X509_LOOKUP_load_file(x,name,type) \
280 X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)
281
282# define X509_LOOKUP_add_dir(x,name,type) \
283 X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
284
285# define X509_LOOKUP_add_store(x,name) \
286 X509_LOOKUP_ctrl((x),X509_L_ADD_STORE,(name),0,NULL)
287
288# define X509_LOOKUP_load_store(x,name) \
289 X509_LOOKUP_ctrl((x),X509_L_LOAD_STORE,(name),0,NULL)
290
291# define X509_LOOKUP_load_file_ex(x, name, type, libctx, propq) \
292X509_LOOKUP_ctrl_ex((x), X509_L_FILE_LOAD, (name), (long)(type), NULL,\
293 (libctx), (propq))
294
295# define X509_LOOKUP_load_store_ex(x, name, libctx, propq) \
296X509_LOOKUP_ctrl_ex((x), X509_L_LOAD_STORE, (name), 0, NULL, \
297 (libctx), (propq))
298
299# define X509_LOOKUP_add_store_ex(x, name, libctx, propq) \
300X509_LOOKUP_ctrl_ex((x), X509_L_ADD_STORE, (name), 0, NULL, \
301 (libctx), (propq))
302
303# define X509_V_OK 0
304# define X509_V_ERR_UNSPECIFIED 1
305# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2
306# define X509_V_ERR_UNABLE_TO_GET_CRL 3
307# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4
308# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5
309# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6
310# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7
311# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8
312# define X509_V_ERR_CERT_NOT_YET_VALID 9
313# define X509_V_ERR_CERT_HAS_EXPIRED 10
314# define X509_V_ERR_CRL_NOT_YET_VALID 11
315# define X509_V_ERR_CRL_HAS_EXPIRED 12
316# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13
317# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14
318# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15
319# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16
320# define X509_V_ERR_OUT_OF_MEM 17
321# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18
322# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19
323# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20
324# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
325# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22
326# define X509_V_ERR_CERT_REVOKED 23
327# define X509_V_ERR_NO_ISSUER_PUBLIC_KEY 24
328# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25
329# define X509_V_ERR_INVALID_PURPOSE 26
330# define X509_V_ERR_CERT_UNTRUSTED 27
331# define X509_V_ERR_CERT_REJECTED 28
332
333/* These are 'informational' when looking for issuer cert */
334# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29
335# define X509_V_ERR_AKID_SKID_MISMATCH 30
336# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31
337# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32
338# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33
339# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34
340# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35
341# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36
342# define X509_V_ERR_INVALID_NON_CA 37
343# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38
344# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39
345# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40
346# define X509_V_ERR_INVALID_EXTENSION 41
347# define X509_V_ERR_INVALID_POLICY_EXTENSION 42
348# define X509_V_ERR_NO_EXPLICIT_POLICY 43
349# define X509_V_ERR_DIFFERENT_CRL_SCOPE 44
350# define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45
351# define X509_V_ERR_UNNESTED_RESOURCE 46
352# define X509_V_ERR_PERMITTED_VIOLATION 47
353# define X509_V_ERR_EXCLUDED_VIOLATION 48
354# define X509_V_ERR_SUBTREE_MINMAX 49
355/* The application is not happy */
356# define X509_V_ERR_APPLICATION_VERIFICATION 50
357# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51
358# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52
359# define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53
360# define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54
361/* Another issuer check debug option */
362# define X509_V_ERR_PATH_LOOP 55
363/* Suite B mode algorithm violation */
364# define X509_V_ERR_SUITE_B_INVALID_VERSION 56
365# define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57
366# define X509_V_ERR_SUITE_B_INVALID_CURVE 58
367# define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59
368# define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60
369# define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61
370/* Host, email and IP check errors */
371# define X509_V_ERR_HOSTNAME_MISMATCH 62
372# define X509_V_ERR_EMAIL_MISMATCH 63
373# define X509_V_ERR_IP_ADDRESS_MISMATCH 64
374/* DANE TLSA errors */
375# define X509_V_ERR_DANE_NO_MATCH 65
376/* security level errors */
377# define X509_V_ERR_EE_KEY_TOO_SMALL 66
378# define X509_V_ERR_CA_KEY_TOO_SMALL 67
379# define X509_V_ERR_CA_MD_TOO_WEAK 68
380/* Caller error */
381# define X509_V_ERR_INVALID_CALL 69
382/* Issuer lookup error */
383# define X509_V_ERR_STORE_LOOKUP 70
384/* Certificate transparency */
385# define X509_V_ERR_NO_VALID_SCTS 71
386
387# define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72
388/* OCSP status errors */
389# define X509_V_ERR_OCSP_VERIFY_NEEDED 73 /* Need OCSP verification */
390# define X509_V_ERR_OCSP_VERIFY_FAILED 74 /* Couldn't verify cert through OCSP */
391# define X509_V_ERR_OCSP_CERT_UNKNOWN 75 /* Certificate wasn't recognized by the OCSP responder */
392
393# define X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM 76
394# define X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH 77
395
396/* Errors in case a check in X509_V_FLAG_X509_STRICT mode fails */
397# define X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCY 78
398# define X509_V_ERR_INVALID_CA 79
399# define X509_V_ERR_PATHLEN_INVALID_FOR_NON_CA 80
400# define X509_V_ERR_PATHLEN_WITHOUT_KU_KEY_CERT_SIGN 81
401# define X509_V_ERR_KU_KEY_CERT_SIGN_INVALID_FOR_NON_CA 82
402# define X509_V_ERR_ISSUER_NAME_EMPTY 83
403# define X509_V_ERR_SUBJECT_NAME_EMPTY 84
404# define X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIER 85
405# define X509_V_ERR_MISSING_SUBJECT_KEY_IDENTIFIER 86
406# define X509_V_ERR_EMPTY_SUBJECT_ALT_NAME 87
407# define X509_V_ERR_EMPTY_SUBJECT_SAN_NOT_CRITICAL 88
408# define X509_V_ERR_CA_BCONS_NOT_CRITICAL 89
409# define X509_V_ERR_AUTHORITY_KEY_IDENTIFIER_CRITICAL 90
410# define X509_V_ERR_SUBJECT_KEY_IDENTIFIER_CRITICAL 91
411# define X509_V_ERR_CA_CERT_MISSING_KEY_USAGE 92
412# define X509_V_ERR_EXTENSIONS_REQUIRE_VERSION_3 93
413# define X509_V_ERR_EC_KEY_EXPLICIT_PARAMS 94
414
415/* Certificate verify flags */
416# ifndef OPENSSL_NO_DEPRECATED_1_1_0
417# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */
418# endif
419/* Use check time instead of current time */
420# define X509_V_FLAG_USE_CHECK_TIME 0x2
421/* Lookup CRLs */
422# define X509_V_FLAG_CRL_CHECK 0x4
423/* Lookup CRLs for whole chain */
424# define X509_V_FLAG_CRL_CHECK_ALL 0x8
425/* Ignore unhandled critical extensions */
426# define X509_V_FLAG_IGNORE_CRITICAL 0x10
427/* Disable workarounds for broken certificates */
428# define X509_V_FLAG_X509_STRICT 0x20
429/* Enable proxy certificate validation */
430# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40
431/* Enable policy checking */
432# define X509_V_FLAG_POLICY_CHECK 0x80
433/* Policy variable require-explicit-policy */
434# define X509_V_FLAG_EXPLICIT_POLICY 0x100
435/* Policy variable inhibit-any-policy */
436# define X509_V_FLAG_INHIBIT_ANY 0x200
437/* Policy variable inhibit-policy-mapping */
438# define X509_V_FLAG_INHIBIT_MAP 0x400
439/* Notify callback that policy is OK */
440# define X509_V_FLAG_NOTIFY_POLICY 0x800
441/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
442# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000
443/* Delta CRL support */
444# define X509_V_FLAG_USE_DELTAS 0x2000
445/* Check self-signed CA signature */
446# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000
447/* Use trusted store first */
448# define X509_V_FLAG_TRUSTED_FIRST 0x8000
449/* Suite B 128 bit only mode: not normally used */
450# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000
451/* Suite B 192 bit only mode */
452# define X509_V_FLAG_SUITEB_192_LOS 0x20000
453/* Suite B 128 bit mode allowing 192 bit algorithms */
454# define X509_V_FLAG_SUITEB_128_LOS 0x30000
455/* Allow partial chains if at least one certificate is in trusted store */
456# define X509_V_FLAG_PARTIAL_CHAIN 0x80000
457/*
458 * If the initial chain is not trusted, do not attempt to build an alternative
459 * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag
460 * will force the behaviour to match that of previous versions.
461 */
462# define X509_V_FLAG_NO_ALT_CHAINS 0x100000
463/* Do not check certificate/CRL validity against current time */
464# define X509_V_FLAG_NO_CHECK_TIME 0x200000
465
466# define X509_VP_FLAG_DEFAULT 0x1
467# define X509_VP_FLAG_OVERWRITE 0x2
468# define X509_VP_FLAG_RESET_FLAGS 0x4
469# define X509_VP_FLAG_LOCKED 0x8
470# define X509_VP_FLAG_ONCE 0x10
471
472/* Internal use: mask of policy related options */
473# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
474 | X509_V_FLAG_EXPLICIT_POLICY \
475 | X509_V_FLAG_INHIBIT_ANY \
476 | X509_V_FLAG_INHIBIT_MAP)
477
478int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
479 const X509_NAME *name);
480X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
481 X509_LOOKUP_TYPE type,
482 const X509_NAME *name);
483X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
484 X509_OBJECT *x);
485int X509_OBJECT_up_ref_count(X509_OBJECT *a);
486X509_OBJECT *X509_OBJECT_new(void);
487void X509_OBJECT_free(X509_OBJECT *a);
488X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);
489X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);
490int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);
491X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a);
492int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
493X509_STORE *X509_STORE_new(void);
494void X509_STORE_free(X509_STORE *v);
495int X509_STORE_lock(X509_STORE *ctx);
496int X509_STORE_unlock(X509_STORE *ctx);
497int X509_STORE_up_ref(X509_STORE *v);
498STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v);
499STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *st);
500STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st,
501 const X509_NAME *nm);
502STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st,
503 const X509_NAME *nm);
504int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
505int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
506int X509_STORE_set_trust(X509_STORE *ctx, int trust);
507int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *pm);
508X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx);
509
510void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify);
511#define X509_STORE_set_verify_func(ctx, func) \
512 X509_STORE_set_verify((ctx),(func))
513void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
514 X509_STORE_CTX_verify_fn verify);
515X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx);
516void X509_STORE_set_verify_cb(X509_STORE *ctx,
517 X509_STORE_CTX_verify_cb verify_cb);
518# define X509_STORE_set_verify_cb_func(ctx,func) \
519 X509_STORE_set_verify_cb((ctx),(func))
520X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx);
521void X509_STORE_set_get_issuer(X509_STORE *ctx,
522 X509_STORE_CTX_get_issuer_fn get_issuer);
523X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx);
524void X509_STORE_set_check_issued(X509_STORE *ctx,
525 X509_STORE_CTX_check_issued_fn check_issued);
526X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx);
527void X509_STORE_set_check_revocation(X509_STORE *ctx,
528 X509_STORE_CTX_check_revocation_fn check_revocation);
529X509_STORE_CTX_check_revocation_fn
530 X509_STORE_get_check_revocation(const X509_STORE *ctx);
531void X509_STORE_set_get_crl(X509_STORE *ctx,
532 X509_STORE_CTX_get_crl_fn get_crl);
533X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx);
534void X509_STORE_set_check_crl(X509_STORE *ctx,
535 X509_STORE_CTX_check_crl_fn check_crl);
536X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx);
537void X509_STORE_set_cert_crl(X509_STORE *ctx,
538 X509_STORE_CTX_cert_crl_fn cert_crl);
539X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx);
540void X509_STORE_set_check_policy(X509_STORE *ctx,
541 X509_STORE_CTX_check_policy_fn check_policy);
542X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx);
543void X509_STORE_set_lookup_certs(X509_STORE *ctx,
544 X509_STORE_CTX_lookup_certs_fn lookup_certs);
545X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx);
546void X509_STORE_set_lookup_crls(X509_STORE *ctx,
547 X509_STORE_CTX_lookup_crls_fn lookup_crls);
548#define X509_STORE_set_lookup_crls_cb(ctx, func) \
549 X509_STORE_set_lookup_crls((ctx), (func))
550X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx);
551void X509_STORE_set_cleanup(X509_STORE *ctx,
552 X509_STORE_CTX_cleanup_fn cleanup);
553X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *ctx);
554
555#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
556 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef)
557int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data);
558void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx);
559
560X509_STORE_CTX *X509_STORE_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
561X509_STORE_CTX *X509_STORE_CTX_new(void);
562
563int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
564
565void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
566int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store,
567 X509 *target, STACK_OF(X509) *untrusted);
568void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
569void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
570
571X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx);
572X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx);
573STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx);
574void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
575void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
576 X509_STORE_CTX_verify_cb verify);
577X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx);
578X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx);
579X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx);
580X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx);
581X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx);
582X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx);
583X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx);
584X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx);
585X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx);
586X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx);
587X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx);
588X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(const X509_STORE_CTX *ctx);
589
590#ifndef OPENSSL_NO_DEPRECATED_1_1_0
591# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain
592# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted
593# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack
594# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject
595# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs
596# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls
597/* the following macro is misspelled; use X509_STORE_get1_certs instead */
598# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs
599/* the following macro is misspelled; use X509_STORE_get1_crls instead */
600# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls
601#endif
602
603X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
604X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
605X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
606X509_LOOKUP_METHOD *X509_LOOKUP_store(void);
607
608typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,
609 long argl, char **ret);
610typedef int (*X509_LOOKUP_ctrl_ex_fn)(
611 X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret,
612 OSSL_LIB_CTX *libctx, const char *propq);
613
614typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,
615 X509_LOOKUP_TYPE type,
616 const X509_NAME *name,
617 X509_OBJECT *ret);
618typedef int (*X509_LOOKUP_get_by_subject_ex_fn)(X509_LOOKUP *ctx,
619 X509_LOOKUP_TYPE type,
620 const X509_NAME *name,
621 X509_OBJECT *ret,
622 OSSL_LIB_CTX *libctx,
623 const char *propq);
624typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,
625 X509_LOOKUP_TYPE type,
626 const X509_NAME *name,
627 const ASN1_INTEGER *serial,
628 X509_OBJECT *ret);
629typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,
630 X509_LOOKUP_TYPE type,
631 const unsigned char* bytes,
632 int len,
633 X509_OBJECT *ret);
634typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,
635 X509_LOOKUP_TYPE type,
636 const char *str,
637 int len,
638 X509_OBJECT *ret);
639
640X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);
641void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);
642
643int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
644 int (*new_item) (X509_LOOKUP *ctx));
645int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
646 (X509_LOOKUP *ctx);
647
648int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,
649 void (*free_fn) (X509_LOOKUP *ctx));
650void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
651 (X509_LOOKUP *ctx);
652
653int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
654 int (*init) (X509_LOOKUP *ctx));
655int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))
656 (X509_LOOKUP *ctx);
657
658int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,
659 int (*shutdown) (X509_LOOKUP *ctx));
660int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))
661 (X509_LOOKUP *ctx);
662
663int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,
664 X509_LOOKUP_ctrl_fn ctrl_fn);
665X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);
666
667int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
668 X509_LOOKUP_get_by_subject_fn fn);
669X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
670 const X509_LOOKUP_METHOD *method);
671
672int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,
673 X509_LOOKUP_get_by_issuer_serial_fn fn);
674X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(
675 const X509_LOOKUP_METHOD *method);
676
677int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
678 X509_LOOKUP_get_by_fingerprint_fn fn);
679X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
680 const X509_LOOKUP_METHOD *method);
681
682int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
683 X509_LOOKUP_get_by_alias_fn fn);
684X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
685 const X509_LOOKUP_METHOD *method);
686
687
688int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
689int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
690
691int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs,
692 X509_LOOKUP_TYPE type,
693 const X509_NAME *name, X509_OBJECT *ret);
694X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
695 X509_LOOKUP_TYPE type,
696 const X509_NAME *name);
697
698int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
699 long argl, char **ret);
700int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
701 char **ret, OSSL_LIB_CTX *libctx, const char *propq);
702
703int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
704int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type,
705 OSSL_LIB_CTX *libctx, const char *propq);
706int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
707int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
708int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type,
709 OSSL_LIB_CTX *libctx, const char *propq);
710
711X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
712void X509_LOOKUP_free(X509_LOOKUP *ctx);
713int X509_LOOKUP_init(X509_LOOKUP *ctx);
714int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
715 const X509_NAME *name, X509_OBJECT *ret);
716int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
717 const X509_NAME *name, X509_OBJECT *ret,
718 OSSL_LIB_CTX *libctx, const char *propq);
719int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
720 const X509_NAME *name,
721 const ASN1_INTEGER *serial,
722 X509_OBJECT *ret);
723int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
724 const unsigned char *bytes, int len,
725 X509_OBJECT *ret);
726int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
727 const char *str, int len, X509_OBJECT *ret);
728int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
729void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
730X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
731int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
732
733int X509_STORE_load_file(X509_STORE *ctx, const char *file);
734int X509_STORE_load_path(X509_STORE *ctx, const char *path);
735int X509_STORE_load_store(X509_STORE *ctx, const char *store);
736int X509_STORE_load_locations(X509_STORE *ctx,
737 const char *file,
738 const char *dir);
739int X509_STORE_set_default_paths(X509_STORE *ctx);
740
741int X509_STORE_load_file_ex(X509_STORE *ctx, const char *file,
742 OSSL_LIB_CTX *libctx, const char *propq);
743int X509_STORE_load_store_ex(X509_STORE *ctx, const char *store,
744 OSSL_LIB_CTX *libctx, const char *propq);
745int X509_STORE_load_locations_ex(X509_STORE *ctx, const char *file,
746 const char *dir, OSSL_LIB_CTX *libctx,
747 const char *propq);
748int X509_STORE_set_default_paths_ex(X509_STORE *ctx, OSSL_LIB_CTX *libctx,
749 const char *propq);
750
751#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \
752 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef)
753int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);
754void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx);
755int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx);
756void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);
757int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx);
758void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);
759X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx);
760void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);
761X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx);
762X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx);
763X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(const X509_STORE_CTX *ctx);
764STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx);
765STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx);
766void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *target);
767void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);
768void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
769int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
770int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
771int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
772 int purpose, int trust);
773void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
774void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
775 time_t t);
776
777X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx);
778int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx);
779int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx);
780
781X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx);
782void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
783int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
784
785/*
786 * Bridge opacity barrier between libcrypt and libssl, also needed to support
787 * offline testing in test/danetest.c
788 */
789void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane);
790#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0)
791
792/* X509_VERIFY_PARAM functions */
793
794X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
795void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
796int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
797 const X509_VERIFY_PARAM *from);
798int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
799 const X509_VERIFY_PARAM *from);
800int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
801int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,
802 unsigned long flags);
803int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
804 unsigned long flags);
805unsigned long X509_VERIFY_PARAM_get_flags(const X509_VERIFY_PARAM *param);
806int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
807int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
808void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
809void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level);
810time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param);
811void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
812int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
813 ASN1_OBJECT *policy);
814int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
815 STACK_OF(ASN1_OBJECT) *policies);
816
817int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param,
818 uint32_t flags);
819uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param);
820
821char *X509_VERIFY_PARAM_get0_host(X509_VERIFY_PARAM *param, int idx);
822int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,
823 const char *name, size_t namelen);
824int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,
825 const char *name, size_t namelen);
826void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,
827 unsigned int flags);
828unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param);
829char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param);
830void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *);
831char *X509_VERIFY_PARAM_get0_email(X509_VERIFY_PARAM *param);
832int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,
833 const char *email, size_t emaillen);
834char *X509_VERIFY_PARAM_get1_ip_asc(X509_VERIFY_PARAM *param);
835int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,
836 const unsigned char *ip, size_t iplen);
837int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,
838 const char *ipasc);
839
840int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
841int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param);
842const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);
843
844int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
845int X509_VERIFY_PARAM_get_count(void);
846const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);
847const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
848void X509_VERIFY_PARAM_table_cleanup(void);
849
850/* Non positive return values are errors */
851#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */
852#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */
853#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */
854
855/*
856 * Positive return values form a bit mask, all but the first are internal to
857 * the library and don't appear in results from X509_policy_check().
858 */
859#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */
860#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */
861#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */
862
863int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
864 STACK_OF(X509) *certs,
865 STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);
866
867void X509_policy_tree_free(X509_POLICY_TREE *tree);
868
869int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
870X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,
871 int i);
872
873STACK_OF(X509_POLICY_NODE)
874 *X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
875
876STACK_OF(X509_POLICY_NODE)
877 *X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
878
879int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
880
881X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level,
882 int i);
883
884const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
885
886STACK_OF(POLICYQUALINFO)
887 *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
888const X509_POLICY_NODE
889 *X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
890
891#ifdef __cplusplus
892}
893#endif
894#endif
895

source code of include/openssl/x509_vfy.h