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 38 extern "C" { 39 #endif 40 41 /*- 42 SSL_CTX -> X509_STORE 43 -> X509_LOOKUP 44 ->X509_LOOKUP_METHOD 45 -> X509_LOOKUP 46 ->X509_LOOKUP_METHOD 47 48 SSL -> X509_STORE_CTX 49 ->X509_STORE 50 51 The X509_STORE holds the tables etc for verification stuff. 52 A X509_STORE_CTX is used while validating a single certificate. 53 The X509_STORE has X509_LOOKUPs for looking up certs. 54 The X509_STORE then calls a function to actually verify the 55 certificate chain. 56 */ 57 58 typedef 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 68 SKM_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))) 94 SKM_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))) 120 SKM_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 */ 149 typedef 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; 157 SKM_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 214 int X509_TRUST_set(int *t, int trust); 215 int X509_TRUST_get_count(void); 216 X509_TRUST *X509_TRUST_get0(int idx); 217 int X509_TRUST_get_by_id(int id); 218 int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int), 219 const char *name, int arg1, void *arg2); 220 void X509_TRUST_cleanup(void); 221 int X509_TRUST_get_flags(const X509_TRUST *xp); 222 char *X509_TRUST_get0_name(const X509_TRUST *xp); 223 int X509_TRUST_get_trust(const X509_TRUST *xp); 224 225 int X509_trusted(const X509 *x); 226 int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj); 227 int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj); 228 void X509_trust_clear(X509 *x); 229 void X509_reject_clear(X509 *x); 230 STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x); 231 STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x); 232 233 int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *, 234 int); 235 int X509_check_trust(X509 *x, int id, int flags); 236 237 int X509_verify_cert(X509_STORE_CTX *ctx); 238 int X509_STORE_CTX_verify(X509_STORE_CTX *ctx); 239 STACK_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 243 int X509_STORE_set_depth(X509_STORE *store, int depth); 244 245 typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *); 246 int X509_STORE_CTX_print_verify_cb(int ok, X509_STORE_CTX *ctx); 247 typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *); 248 typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, 249 X509_STORE_CTX *ctx, X509 *x); 250 typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, 251 X509 *x, X509 *issuer); 252 typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx); 253 typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, 254 X509_CRL **crl, X509 *x); 255 typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl); 256 typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, 257 X509_CRL *crl, X509 *x); 258 typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx); 259 typedef STACK_OF(X509) 260 *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, 261 const X509_NAME *nm); 262 typedef STACK_OF(X509_CRL) 263 *(*X509_STORE_CTX_lookup_crls_fn)(const X509_STORE_CTX *ctx, 264 const X509_NAME *nm); 265 typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx); 266 267 void 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) \ 292 X509_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) \ 296 X509_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) \ 300 X509_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 478 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, 479 const X509_NAME *name); 480 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, 481 X509_LOOKUP_TYPE type, 482 const X509_NAME *name); 483 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, 484 X509_OBJECT *x); 485 int X509_OBJECT_up_ref_count(X509_OBJECT *a); 486 X509_OBJECT *X509_OBJECT_new(void); 487 void X509_OBJECT_free(X509_OBJECT *a); 488 X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a); 489 X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a); 490 int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj); 491 X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a); 492 int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj); 493 X509_STORE *X509_STORE_new(void); 494 void X509_STORE_free(X509_STORE *v); 495 int X509_STORE_lock(X509_STORE *ctx); 496 int X509_STORE_unlock(X509_STORE *ctx); 497 int X509_STORE_up_ref(X509_STORE *v); 498 STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v); 499 STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *st); 500 STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, 501 const X509_NAME *nm); 502 STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st, 503 const X509_NAME *nm); 504 int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); 505 int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); 506 int X509_STORE_set_trust(X509_STORE *ctx, int trust); 507 int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *pm); 508 X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx); 509 510 void 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)) 513 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, 514 X509_STORE_CTX_verify_fn verify); 515 X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx); 516 void 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)) 520 X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx); 521 void X509_STORE_set_get_issuer(X509_STORE *ctx, 522 X509_STORE_CTX_get_issuer_fn get_issuer); 523 X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx); 524 void X509_STORE_set_check_issued(X509_STORE *ctx, 525 X509_STORE_CTX_check_issued_fn check_issued); 526 X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx); 527 void X509_STORE_set_check_revocation(X509_STORE *ctx, 528 X509_STORE_CTX_check_revocation_fn check_revocation); 529 X509_STORE_CTX_check_revocation_fn 530 X509_STORE_get_check_revocation(const X509_STORE *ctx); 531 void X509_STORE_set_get_crl(X509_STORE *ctx, 532 X509_STORE_CTX_get_crl_fn get_crl); 533 X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx); 534 void X509_STORE_set_check_crl(X509_STORE *ctx, 535 X509_STORE_CTX_check_crl_fn check_crl); 536 X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx); 537 void X509_STORE_set_cert_crl(X509_STORE *ctx, 538 X509_STORE_CTX_cert_crl_fn cert_crl); 539 X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx); 540 void X509_STORE_set_check_policy(X509_STORE *ctx, 541 X509_STORE_CTX_check_policy_fn check_policy); 542 X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx); 543 void X509_STORE_set_lookup_certs(X509_STORE *ctx, 544 X509_STORE_CTX_lookup_certs_fn lookup_certs); 545 X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx); 546 void 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)) 550 X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx); 551 void X509_STORE_set_cleanup(X509_STORE *ctx, 552 X509_STORE_CTX_cleanup_fn cleanup); 553 X509_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) 557 int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data); 558 void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx); 559 560 X509_STORE_CTX *X509_STORE_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq); 561 X509_STORE_CTX *X509_STORE_CTX_new(void); 562 563 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 564 565 void X509_STORE_CTX_free(X509_STORE_CTX *ctx); 566 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store, 567 X509 *target, STACK_OF(X509) *untrusted); 568 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); 569 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); 570 571 X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx); 572 X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx); 573 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx); 574 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); 575 void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, 576 X509_STORE_CTX_verify_cb verify); 577 X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx); 578 X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx); 579 X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx); 580 X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx); 581 X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx); 582 X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx); 583 X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx); 584 X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx); 585 X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx); 586 X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx); 587 X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx); 588 X509_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 603 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); 604 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); 605 X509_LOOKUP_METHOD *X509_LOOKUP_file(void); 606 X509_LOOKUP_METHOD *X509_LOOKUP_store(void); 607 608 typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, 609 long argl, char **ret); 610 typedef 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 614 typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx, 615 X509_LOOKUP_TYPE type, 616 const X509_NAME *name, 617 X509_OBJECT *ret); 618 typedef 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); 624 typedef 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); 629 typedef 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); 634 typedef 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 640 X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name); 641 void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method); 642 643 int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, 644 int (*new_item) (X509_LOOKUP *ctx)); 645 int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method)) 646 (X509_LOOKUP *ctx); 647 648 int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method, 649 void (*free_fn) (X509_LOOKUP *ctx)); 650 void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method)) 651 (X509_LOOKUP *ctx); 652 653 int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, 654 int (*init) (X509_LOOKUP *ctx)); 655 int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method)) 656 (X509_LOOKUP *ctx); 657 658 int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method, 659 int (*shutdown) (X509_LOOKUP *ctx)); 660 int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method)) 661 (X509_LOOKUP *ctx); 662 663 int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method, 664 X509_LOOKUP_ctrl_fn ctrl_fn); 665 X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method); 666 667 int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method, 668 X509_LOOKUP_get_by_subject_fn fn); 669 X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject( 670 const X509_LOOKUP_METHOD *method); 671 672 int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method, 673 X509_LOOKUP_get_by_issuer_serial_fn fn); 674 X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial( 675 const X509_LOOKUP_METHOD *method); 676 677 int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method, 678 X509_LOOKUP_get_by_fingerprint_fn fn); 679 X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint( 680 const X509_LOOKUP_METHOD *method); 681 682 int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, 683 X509_LOOKUP_get_by_alias_fn fn); 684 X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias( 685 const X509_LOOKUP_METHOD *method); 686 687 688 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); 689 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); 690 691 int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs, 692 X509_LOOKUP_TYPE type, 693 const X509_NAME *name, X509_OBJECT *ret); 694 X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, 695 X509_LOOKUP_TYPE type, 696 const X509_NAME *name); 697 698 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 699 long argl, char **ret); 700 int 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 703 int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); 704 int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type, 705 OSSL_LIB_CTX *libctx, const char *propq); 706 int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); 707 int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); 708 int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type, 709 OSSL_LIB_CTX *libctx, const char *propq); 710 711 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); 712 void X509_LOOKUP_free(X509_LOOKUP *ctx); 713 int X509_LOOKUP_init(X509_LOOKUP *ctx); 714 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 715 const X509_NAME *name, X509_OBJECT *ret); 716 int 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); 719 int 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); 723 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 724 const unsigned char *bytes, int len, 725 X509_OBJECT *ret); 726 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 727 const char *str, int len, X509_OBJECT *ret); 728 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data); 729 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx); 730 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx); 731 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); 732 733 int X509_STORE_load_file(X509_STORE *ctx, const char *file); 734 int X509_STORE_load_path(X509_STORE *ctx, const char *path); 735 int X509_STORE_load_store(X509_STORE *ctx, const char *store); 736 int X509_STORE_load_locations(X509_STORE *ctx, 737 const char *file, 738 const char *dir); 739 int X509_STORE_set_default_paths(X509_STORE *ctx); 740 741 int X509_STORE_load_file_ex(X509_STORE *ctx, const char *file, 742 OSSL_LIB_CTX *libctx, const char *propq); 743 int X509_STORE_load_store_ex(X509_STORE *ctx, const char *store, 744 OSSL_LIB_CTX *libctx, const char *propq); 745 int X509_STORE_load_locations_ex(X509_STORE *ctx, const char *file, 746 const char *dir, OSSL_LIB_CTX *libctx, 747 const char *propq); 748 int 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) 753 int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); 754 void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx); 755 int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx); 756 void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); 757 int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx); 758 void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth); 759 X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx); 760 void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x); 761 X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx); 762 X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx); 763 X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(const X509_STORE_CTX *ctx); 764 STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx); 765 STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx); 766 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *target); 767 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); 768 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk); 769 int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); 770 int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); 771 int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, 772 int purpose, int trust); 773 void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); 774 void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, 775 time_t t); 776 777 X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx); 778 int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx); 779 int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx); 780 781 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx); 782 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); 783 int 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 */ 789 void 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 794 X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); 795 void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); 796 int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, 797 const X509_VERIFY_PARAM *from); 798 int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, 799 const X509_VERIFY_PARAM *from); 800 int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); 801 int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, 802 unsigned long flags); 803 int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, 804 unsigned long flags); 805 unsigned long X509_VERIFY_PARAM_get_flags(const X509_VERIFY_PARAM *param); 806 int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); 807 int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); 808 void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); 809 void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level); 810 time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param); 811 void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); 812 int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, 813 ASN1_OBJECT *policy); 814 int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, 815 STACK_OF(ASN1_OBJECT) *policies); 816 817 int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param, 818 uint32_t flags); 819 uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param); 820 821 char *X509_VERIFY_PARAM_get0_host(X509_VERIFY_PARAM *param, int idx); 822 int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, 823 const char *name, size_t namelen); 824 int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, 825 const char *name, size_t namelen); 826 void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, 827 unsigned int flags); 828 unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param); 829 char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param); 830 void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *); 831 char *X509_VERIFY_PARAM_get0_email(X509_VERIFY_PARAM *param); 832 int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, 833 const char *email, size_t emaillen); 834 char *X509_VERIFY_PARAM_get1_ip_asc(X509_VERIFY_PARAM *param); 835 int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, 836 const unsigned char *ip, size_t iplen); 837 int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, 838 const char *ipasc); 839 840 int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); 841 int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param); 842 const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); 843 844 int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); 845 int X509_VERIFY_PARAM_get_count(void); 846 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); 847 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); 848 void 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 863 int 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 867 void X509_policy_tree_free(X509_POLICY_TREE *tree); 868 869 int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); 870 X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, 871 int i); 872 873 STACK_OF(X509_POLICY_NODE) 874 *X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); 875 876 STACK_OF(X509_POLICY_NODE) 877 *X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); 878 879 int X509_policy_level_node_count(X509_POLICY_LEVEL *level); 880 881 X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, 882 int i); 883 884 const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); 885 886 STACK_OF(POLICYQUALINFO) 887 *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); 888 const X509_POLICY_NODE 889 *X509_policy_node_get0_parent(const X509_POLICY_NODE *node); 890 891 #ifdef __cplusplus 892 } 893 #endif 894 #endif 895