1/*
2 * WARNING: do not edit!
3 * Generated by Makefile from include/openssl/x509_vfy.h.in
4 *
5 * Copyright 1995-2024 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# define X509_V_ERR_RPK_UNTRUSTED 95
415
416/* Certificate verify flags */
417# ifndef OPENSSL_NO_DEPRECATED_1_1_0
418# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */
419# endif
420/* Use check time instead of current time */
421# define X509_V_FLAG_USE_CHECK_TIME 0x2
422/* Lookup CRLs */
423# define X509_V_FLAG_CRL_CHECK 0x4
424/* Lookup CRLs for whole chain */
425# define X509_V_FLAG_CRL_CHECK_ALL 0x8
426/* Ignore unhandled critical extensions */
427# define X509_V_FLAG_IGNORE_CRITICAL 0x10
428/* Disable workarounds for broken certificates */
429# define X509_V_FLAG_X509_STRICT 0x20
430/* Enable proxy certificate validation */
431# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40
432/* Enable policy checking */
433# define X509_V_FLAG_POLICY_CHECK 0x80
434/* Policy variable require-explicit-policy */
435# define X509_V_FLAG_EXPLICIT_POLICY 0x100
436/* Policy variable inhibit-any-policy */
437# define X509_V_FLAG_INHIBIT_ANY 0x200
438/* Policy variable inhibit-policy-mapping */
439# define X509_V_FLAG_INHIBIT_MAP 0x400
440/* Notify callback that policy is OK */
441# define X509_V_FLAG_NOTIFY_POLICY 0x800
442/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
443# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000
444/* Delta CRL support */
445# define X509_V_FLAG_USE_DELTAS 0x2000
446/* Check self-signed CA signature */
447# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000
448/* Use trusted store first */
449# define X509_V_FLAG_TRUSTED_FIRST 0x8000
450/* Suite B 128 bit only mode: not normally used */
451# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000
452/* Suite B 192 bit only mode */
453# define X509_V_FLAG_SUITEB_192_LOS 0x20000
454/* Suite B 128 bit mode allowing 192 bit algorithms */
455# define X509_V_FLAG_SUITEB_128_LOS 0x30000
456/* Allow partial chains if at least one certificate is in trusted store */
457# define X509_V_FLAG_PARTIAL_CHAIN 0x80000
458/*
459 * If the initial chain is not trusted, do not attempt to build an alternative
460 * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag
461 * will force the behaviour to match that of previous versions.
462 */
463# define X509_V_FLAG_NO_ALT_CHAINS 0x100000
464/* Do not check certificate/CRL validity against current time */
465# define X509_V_FLAG_NO_CHECK_TIME 0x200000
466
467# define X509_VP_FLAG_DEFAULT 0x1
468# define X509_VP_FLAG_OVERWRITE 0x2
469# define X509_VP_FLAG_RESET_FLAGS 0x4
470# define X509_VP_FLAG_LOCKED 0x8
471# define X509_VP_FLAG_ONCE 0x10
472
473/* Internal use: mask of policy related options */
474# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
475 | X509_V_FLAG_EXPLICIT_POLICY \
476 | X509_V_FLAG_INHIBIT_ANY \
477 | X509_V_FLAG_INHIBIT_MAP)
478
479int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
480 const X509_NAME *name);
481X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
482 X509_LOOKUP_TYPE type,
483 const X509_NAME *name);
484X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
485 X509_OBJECT *x);
486int X509_OBJECT_up_ref_count(X509_OBJECT *a);
487X509_OBJECT *X509_OBJECT_new(void);
488void X509_OBJECT_free(X509_OBJECT *a);
489X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);
490X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);
491int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);
492X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a);
493int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
494X509_STORE *X509_STORE_new(void);
495void X509_STORE_free(X509_STORE *xs);
496int X509_STORE_lock(X509_STORE *xs);
497int X509_STORE_unlock(X509_STORE *xs);
498int X509_STORE_up_ref(X509_STORE *xs);
499STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *xs);
500STACK_OF(X509_OBJECT) *X509_STORE_get1_objects(X509_STORE *xs);
501STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *xs);
502STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *xs,
503 const X509_NAME *nm);
504STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st,
505 const X509_NAME *nm);
506int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags);
507int X509_STORE_set_purpose(X509_STORE *xs, int purpose);
508int X509_STORE_set_trust(X509_STORE *xs, int trust);
509int X509_STORE_set1_param(X509_STORE *xs, const X509_VERIFY_PARAM *pm);
510X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *xs);
511
512void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify);
513#define X509_STORE_set_verify_func(ctx, func) \
514 X509_STORE_set_verify((ctx),(func))
515void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
516 X509_STORE_CTX_verify_fn verify);
517X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *xs);
518void X509_STORE_set_verify_cb(X509_STORE *xs,
519 X509_STORE_CTX_verify_cb verify_cb);
520# define X509_STORE_set_verify_cb_func(ctx,func) \
521 X509_STORE_set_verify_cb((ctx),(func))
522X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *xs);
523void X509_STORE_set_get_issuer(X509_STORE *xs,
524 X509_STORE_CTX_get_issuer_fn get_issuer);
525X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *xs);
526void X509_STORE_set_check_issued(X509_STORE *xs,
527 X509_STORE_CTX_check_issued_fn check_issued);
528X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *s);
529void X509_STORE_set_check_revocation(X509_STORE *xs,
530 X509_STORE_CTX_check_revocation_fn check_revocation);
531X509_STORE_CTX_check_revocation_fn
532 X509_STORE_get_check_revocation(const X509_STORE *xs);
533void X509_STORE_set_get_crl(X509_STORE *xs,
534 X509_STORE_CTX_get_crl_fn get_crl);
535X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *xs);
536void X509_STORE_set_check_crl(X509_STORE *xs,
537 X509_STORE_CTX_check_crl_fn check_crl);
538X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *xs);
539void X509_STORE_set_cert_crl(X509_STORE *xs,
540 X509_STORE_CTX_cert_crl_fn cert_crl);
541X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *xs);
542void X509_STORE_set_check_policy(X509_STORE *xs,
543 X509_STORE_CTX_check_policy_fn check_policy);
544X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *s);
545void X509_STORE_set_lookup_certs(X509_STORE *xs,
546 X509_STORE_CTX_lookup_certs_fn lookup_certs);
547X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *s);
548void X509_STORE_set_lookup_crls(X509_STORE *xs,
549 X509_STORE_CTX_lookup_crls_fn lookup_crls);
550#define X509_STORE_set_lookup_crls_cb(ctx, func) \
551 X509_STORE_set_lookup_crls((ctx), (func))
552X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *xs);
553void X509_STORE_set_cleanup(X509_STORE *xs,
554 X509_STORE_CTX_cleanup_fn cleanup);
555X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *xs);
556
557#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
558 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef)
559int X509_STORE_set_ex_data(X509_STORE *xs, int idx, void *data);
560void *X509_STORE_get_ex_data(const X509_STORE *xs, int idx);
561
562X509_STORE_CTX *X509_STORE_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
563X509_STORE_CTX *X509_STORE_CTX_new(void);
564
565int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
566
567void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
568int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store,
569 X509 *target, STACK_OF(X509) *untrusted);
570int X509_STORE_CTX_init_rpk(X509_STORE_CTX *ctx, X509_STORE *trust_store,
571 EVP_PKEY* rpk);
572void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
573void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
574
575X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx);
576X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx);
577EVP_PKEY *X509_STORE_CTX_get0_rpk(const X509_STORE_CTX *ctx);
578STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx);
579void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
580void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
581 X509_STORE_CTX_verify_cb verify);
582X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx);
583X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx);
584X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx);
585X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx);
586X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx);
587void X509_STORE_CTX_set_get_crl(X509_STORE_CTX *ctx,
588 X509_STORE_CTX_get_crl_fn get_crl);
589X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx);
590X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx);
591X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx);
592X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx);
593X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx);
594X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx);
595X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(const X509_STORE_CTX *ctx);
596
597#ifndef OPENSSL_NO_DEPRECATED_1_1_0
598# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain
599# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted
600# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack
601# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject
602# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs
603# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls
604/* the following macro is misspelled; use X509_STORE_get1_certs instead */
605# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs
606/* the following macro is misspelled; use X509_STORE_get1_crls instead */
607# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls
608#endif
609
610X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *xs, X509_LOOKUP_METHOD *m);
611X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
612X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
613X509_LOOKUP_METHOD *X509_LOOKUP_store(void);
614
615typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,
616 long argl, char **ret);
617typedef int (*X509_LOOKUP_ctrl_ex_fn)(
618 X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret,
619 OSSL_LIB_CTX *libctx, const char *propq);
620
621typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,
622 X509_LOOKUP_TYPE type,
623 const X509_NAME *name,
624 X509_OBJECT *ret);
625typedef int (*X509_LOOKUP_get_by_subject_ex_fn)(X509_LOOKUP *ctx,
626 X509_LOOKUP_TYPE type,
627 const X509_NAME *name,
628 X509_OBJECT *ret,
629 OSSL_LIB_CTX *libctx,
630 const char *propq);
631typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,
632 X509_LOOKUP_TYPE type,
633 const X509_NAME *name,
634 const ASN1_INTEGER *serial,
635 X509_OBJECT *ret);
636typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,
637 X509_LOOKUP_TYPE type,
638 const unsigned char* bytes,
639 int len,
640 X509_OBJECT *ret);
641typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,
642 X509_LOOKUP_TYPE type,
643 const char *str,
644 int len,
645 X509_OBJECT *ret);
646
647X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);
648void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);
649
650int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
651 int (*new_item) (X509_LOOKUP *ctx));
652int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
653 (X509_LOOKUP *ctx);
654
655int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,
656 void (*free_fn) (X509_LOOKUP *ctx));
657void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
658 (X509_LOOKUP *ctx);
659
660int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
661 int (*init) (X509_LOOKUP *ctx));
662int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))
663 (X509_LOOKUP *ctx);
664
665int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,
666 int (*shutdown) (X509_LOOKUP *ctx));
667int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))
668 (X509_LOOKUP *ctx);
669
670int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,
671 X509_LOOKUP_ctrl_fn ctrl_fn);
672X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);
673
674int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
675 X509_LOOKUP_get_by_subject_fn fn);
676X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
677 const X509_LOOKUP_METHOD *method);
678
679int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,
680 X509_LOOKUP_get_by_issuer_serial_fn fn);
681X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(
682 const X509_LOOKUP_METHOD *method);
683
684int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
685 X509_LOOKUP_get_by_fingerprint_fn fn);
686X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
687 const X509_LOOKUP_METHOD *method);
688
689int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
690 X509_LOOKUP_get_by_alias_fn fn);
691X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
692 const X509_LOOKUP_METHOD *method);
693
694
695int X509_STORE_add_cert(X509_STORE *xs, X509 *x);
696int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x);
697
698int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs,
699 X509_LOOKUP_TYPE type,
700 const X509_NAME *name, X509_OBJECT *ret);
701X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
702 X509_LOOKUP_TYPE type,
703 const X509_NAME *name);
704
705int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
706 long argl, char **ret);
707int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
708 char **ret, OSSL_LIB_CTX *libctx, const char *propq);
709
710int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
711int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type,
712 OSSL_LIB_CTX *libctx, const char *propq);
713int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
714int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
715int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type,
716 OSSL_LIB_CTX *libctx, const char *propq);
717
718X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
719void X509_LOOKUP_free(X509_LOOKUP *ctx);
720int X509_LOOKUP_init(X509_LOOKUP *ctx);
721int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
722 const X509_NAME *name, X509_OBJECT *ret);
723int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
724 const X509_NAME *name, X509_OBJECT *ret,
725 OSSL_LIB_CTX *libctx, const char *propq);
726int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
727 const X509_NAME *name,
728 const ASN1_INTEGER *serial,
729 X509_OBJECT *ret);
730int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
731 const unsigned char *bytes, int len,
732 X509_OBJECT *ret);
733int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
734 const char *str, int len, X509_OBJECT *ret);
735int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
736void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
737X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
738int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
739
740int X509_STORE_load_file(X509_STORE *xs, const char *file);
741int X509_STORE_load_path(X509_STORE *xs, const char *path);
742int X509_STORE_load_store(X509_STORE *xs, const char *store);
743int X509_STORE_load_locations(X509_STORE *s, const char *file, const char *dir);
744int X509_STORE_set_default_paths(X509_STORE *xs);
745
746int X509_STORE_load_file_ex(X509_STORE *xs, const char *file,
747 OSSL_LIB_CTX *libctx, const char *propq);
748int X509_STORE_load_store_ex(X509_STORE *xs, const char *store,
749 OSSL_LIB_CTX *libctx, const char *propq);
750int X509_STORE_load_locations_ex(X509_STORE *xs,
751 const char *file, const char *dir,
752 OSSL_LIB_CTX *libctx, const char *propq);
753int X509_STORE_set_default_paths_ex(X509_STORE *xs,
754 OSSL_LIB_CTX *libctx, const char *propq);
755
756#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \
757 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef)
758int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);
759void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx);
760int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx);
761void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);
762int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx);
763void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);
764X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx);
765void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);
766X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx);
767X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx);
768X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(const X509_STORE_CTX *ctx);
769STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx);
770STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx);
771void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *target);
772void X509_STORE_CTX_set0_rpk(X509_STORE_CTX *ctx, EVP_PKEY *target);
773void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);
774void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
775int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
776int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
777int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
778 int purpose, int trust);
779void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
780void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
781 time_t t);
782void X509_STORE_CTX_set_current_reasons(X509_STORE_CTX *ctx,
783 unsigned int current_reasons);
784
785X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx);
786int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx);
787int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx);
788
789X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx);
790void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
791int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
792
793/*
794 * Bridge opacity barrier between libcrypt and libssl, also needed to support
795 * offline testing in test/danetest.c
796 */
797void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane);
798#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0)
799
800/* X509_VERIFY_PARAM functions */
801
802X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
803void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
804int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
805 const X509_VERIFY_PARAM *from);
806int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
807 const X509_VERIFY_PARAM *from);
808int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
809int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,
810 unsigned long flags);
811int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
812 unsigned long flags);
813unsigned long X509_VERIFY_PARAM_get_flags(const X509_VERIFY_PARAM *param);
814int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
815int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
816void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
817void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level);
818time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param);
819void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
820int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
821 ASN1_OBJECT *policy);
822int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
823 STACK_OF(ASN1_OBJECT) *policies);
824
825int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param,
826 uint32_t flags);
827uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param);
828
829char *X509_VERIFY_PARAM_get0_host(X509_VERIFY_PARAM *param, int idx);
830int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,
831 const char *name, size_t namelen);
832int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,
833 const char *name, size_t namelen);
834void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,
835 unsigned int flags);
836unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param);
837char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param);
838void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *);
839char *X509_VERIFY_PARAM_get0_email(X509_VERIFY_PARAM *param);
840int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,
841 const char *email, size_t emaillen);
842char *X509_VERIFY_PARAM_get1_ip_asc(X509_VERIFY_PARAM *param);
843int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,
844 const unsigned char *ip, size_t iplen);
845int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,
846 const char *ipasc);
847
848int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
849int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param);
850const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);
851
852int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
853int X509_VERIFY_PARAM_get_count(void);
854const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);
855const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
856void X509_VERIFY_PARAM_table_cleanup(void);
857
858/* Non positive return values are errors */
859#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */
860#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */
861#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */
862
863/*
864 * Positive return values form a bit mask, all but the first are internal to
865 * the library and don't appear in results from X509_policy_check().
866 */
867#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */
868#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */
869#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */
870
871int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
872 STACK_OF(X509) *certs,
873 STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);
874
875void X509_policy_tree_free(X509_POLICY_TREE *tree);
876
877int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
878X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,
879 int i);
880
881STACK_OF(X509_POLICY_NODE)
882 *X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
883
884STACK_OF(X509_POLICY_NODE)
885 *X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
886
887int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
888
889X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level,
890 int i);
891
892const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
893
894STACK_OF(POLICYQUALINFO)
895 *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
896const X509_POLICY_NODE
897 *X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
898
899#ifdef __cplusplus
900}
901#endif
902#endif
903