• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * WARNING: do not edit!
3  * Generated by makefile from include/openssl/x509.h.in
4  *
5  * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
6  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
7  *
8  * Licensed under the Apache License 2.0 (the "License").  You may not use
9  * this file except in compliance with the License.  You can obtain a copy
10  * in the file LICENSE in the source distribution or at
11  * https://www.openssl.org/source/license.html
12  */
13 
14 
15 
16 #ifndef OPENSSL_X509_H
17 # define OPENSSL_X509_H
18 # pragma once
19 
20 # include <openssl/macros.h>
21 # ifndef OPENSSL_NO_DEPRECATED_3_0
22 #  define HEADER_X509_H
23 # endif
24 
25 # include <openssl/e_os2.h>
26 # include <openssl/types.h>
27 # include <openssl/symhacks.h>
28 # include <openssl/buffer.h>
29 # include <openssl/evp.h>
30 # include <openssl/bio.h>
31 # include <openssl/asn1.h>
32 # include <openssl/safestack.h>
33 # include <openssl/ec.h>
34 
35 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
36 #  include <openssl/rsa.h>
37 #  include <openssl/dsa.h>
38 #  include <openssl/dh.h>
39 # endif
40 
41 # include <openssl/sha.h>
42 # include <openssl/x509err.h>
43 
44 #ifdef  __cplusplus
45 extern "C" {
46 #endif
47 
48 /* Needed stacks for types defined in other headers */
49 SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME, X509_NAME, X509_NAME)
50 #define sk_X509_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_sk_type(sk))
51 #define sk_X509_NAME_value(sk, idx) ((X509_NAME *)OPENSSL_sk_value(ossl_check_const_X509_NAME_sk_type(sk), (idx)))
52 #define sk_X509_NAME_new(cmp) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new(ossl_check_X509_NAME_compfunc_type(cmp)))
53 #define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_null())
54 #define sk_X509_NAME_new_reserve(cmp, n) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_compfunc_type(cmp), (n)))
55 #define sk_X509_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_sk_type(sk), (n))
56 #define sk_X509_NAME_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_sk_type(sk))
57 #define sk_X509_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_sk_type(sk))
58 #define sk_X509_NAME_delete(sk, i) ((X509_NAME *)OPENSSL_sk_delete(ossl_check_X509_NAME_sk_type(sk), (i)))
59 #define sk_X509_NAME_delete_ptr(sk, ptr) ((X509_NAME *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)))
60 #define sk_X509_NAME_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
61 #define sk_X509_NAME_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
62 #define sk_X509_NAME_pop(sk) ((X509_NAME *)OPENSSL_sk_pop(ossl_check_X509_NAME_sk_type(sk)))
63 #define sk_X509_NAME_shift(sk) ((X509_NAME *)OPENSSL_sk_shift(ossl_check_X509_NAME_sk_type(sk)))
64 #define sk_X509_NAME_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_NAME_sk_type(sk),ossl_check_X509_NAME_freefunc_type(freefunc))
65 #define sk_X509_NAME_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), (idx))
66 #define sk_X509_NAME_set(sk, idx, ptr) ((X509_NAME *)OPENSSL_sk_set(ossl_check_X509_NAME_sk_type(sk), (idx), ossl_check_X509_NAME_type(ptr)))
67 #define sk_X509_NAME_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
68 #define sk_X509_NAME_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
69 #define sk_X509_NAME_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), pnum)
70 #define sk_X509_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_sk_type(sk))
71 #define sk_X509_NAME_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_sk_type(sk))
72 #define sk_X509_NAME_dup(sk) ((STACK_OF(X509_NAME) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_sk_type(sk)))
73 #define sk_X509_NAME_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_NAME) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_NAME_sk_type(sk), ossl_check_X509_NAME_copyfunc_type(copyfunc), ossl_check_X509_NAME_freefunc_type(freefunc)))
74 #define sk_X509_NAME_set_cmp_func(sk, cmp) ((sk_X509_NAME_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_compfunc_type(cmp)))
75 SKM_DEFINE_STACK_OF_INTERNAL(X509, X509, X509)
76 #define sk_X509_num(sk) OPENSSL_sk_num(ossl_check_const_X509_sk_type(sk))
77 #define sk_X509_value(sk, idx) ((X509 *)OPENSSL_sk_value(ossl_check_const_X509_sk_type(sk), (idx)))
78 #define sk_X509_new(cmp) ((STACK_OF(X509) *)OPENSSL_sk_new(ossl_check_X509_compfunc_type(cmp)))
79 #define sk_X509_new_null() ((STACK_OF(X509) *)OPENSSL_sk_new_null())
80 #define sk_X509_new_reserve(cmp, n) ((STACK_OF(X509) *)OPENSSL_sk_new_reserve(ossl_check_X509_compfunc_type(cmp), (n)))
81 #define sk_X509_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_sk_type(sk), (n))
82 #define sk_X509_free(sk) OPENSSL_sk_free(ossl_check_X509_sk_type(sk))
83 #define sk_X509_zero(sk) OPENSSL_sk_zero(ossl_check_X509_sk_type(sk))
84 #define sk_X509_delete(sk, i) ((X509 *)OPENSSL_sk_delete(ossl_check_X509_sk_type(sk), (i)))
85 #define sk_X509_delete_ptr(sk, ptr) ((X509 *)OPENSSL_sk_delete_ptr(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)))
86 #define sk_X509_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
87 #define sk_X509_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
88 #define sk_X509_pop(sk) ((X509 *)OPENSSL_sk_pop(ossl_check_X509_sk_type(sk)))
89 #define sk_X509_shift(sk) ((X509 *)OPENSSL_sk_shift(ossl_check_X509_sk_type(sk)))
90 #define sk_X509_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_sk_type(sk),ossl_check_X509_freefunc_type(freefunc))
91 #define sk_X509_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), (idx))
92 #define sk_X509_set(sk, idx, ptr) ((X509 *)OPENSSL_sk_set(ossl_check_X509_sk_type(sk), (idx), ossl_check_X509_type(ptr)))
93 #define sk_X509_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
94 #define sk_X509_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
95 #define sk_X509_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), pnum)
96 #define sk_X509_sort(sk) OPENSSL_sk_sort(ossl_check_X509_sk_type(sk))
97 #define sk_X509_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_sk_type(sk))
98 #define sk_X509_dup(sk) ((STACK_OF(X509) *)OPENSSL_sk_dup(ossl_check_const_X509_sk_type(sk)))
99 #define sk_X509_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_sk_type(sk), ossl_check_X509_copyfunc_type(copyfunc), ossl_check_X509_freefunc_type(freefunc)))
100 #define sk_X509_set_cmp_func(sk, cmp) ((sk_X509_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_sk_type(sk), ossl_check_X509_compfunc_type(cmp)))
101 SKM_DEFINE_STACK_OF_INTERNAL(X509_REVOKED, X509_REVOKED, X509_REVOKED)
102 #define sk_X509_REVOKED_num(sk) OPENSSL_sk_num(ossl_check_const_X509_REVOKED_sk_type(sk))
103 #define sk_X509_REVOKED_value(sk, idx) ((X509_REVOKED *)OPENSSL_sk_value(ossl_check_const_X509_REVOKED_sk_type(sk), (idx)))
104 #define sk_X509_REVOKED_new(cmp) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new(ossl_check_X509_REVOKED_compfunc_type(cmp)))
105 #define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_null())
106 #define sk_X509_REVOKED_new_reserve(cmp, n) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_reserve(ossl_check_X509_REVOKED_compfunc_type(cmp), (n)))
107 #define sk_X509_REVOKED_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_REVOKED_sk_type(sk), (n))
108 #define sk_X509_REVOKED_free(sk) OPENSSL_sk_free(ossl_check_X509_REVOKED_sk_type(sk))
109 #define sk_X509_REVOKED_zero(sk) OPENSSL_sk_zero(ossl_check_X509_REVOKED_sk_type(sk))
110 #define sk_X509_REVOKED_delete(sk, i) ((X509_REVOKED *)OPENSSL_sk_delete(ossl_check_X509_REVOKED_sk_type(sk), (i)))
111 #define sk_X509_REVOKED_delete_ptr(sk, ptr) ((X509_REVOKED *)OPENSSL_sk_delete_ptr(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)))
112 #define sk_X509_REVOKED_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
113 #define sk_X509_REVOKED_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
114 #define sk_X509_REVOKED_pop(sk) ((X509_REVOKED *)OPENSSL_sk_pop(ossl_check_X509_REVOKED_sk_type(sk)))
115 #define sk_X509_REVOKED_shift(sk) ((X509_REVOKED *)OPENSSL_sk_shift(ossl_check_X509_REVOKED_sk_type(sk)))
116 #define sk_X509_REVOKED_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_REVOKED_sk_type(sk),ossl_check_X509_REVOKED_freefunc_type(freefunc))
117 #define sk_X509_REVOKED_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), (idx))
118 #define sk_X509_REVOKED_set(sk, idx, ptr) ((X509_REVOKED *)OPENSSL_sk_set(ossl_check_X509_REVOKED_sk_type(sk), (idx), ossl_check_X509_REVOKED_type(ptr)))
119 #define sk_X509_REVOKED_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
120 #define sk_X509_REVOKED_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
121 #define sk_X509_REVOKED_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), pnum)
122 #define sk_X509_REVOKED_sort(sk) OPENSSL_sk_sort(ossl_check_X509_REVOKED_sk_type(sk))
123 #define sk_X509_REVOKED_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_REVOKED_sk_type(sk))
124 #define sk_X509_REVOKED_dup(sk) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_dup(ossl_check_const_X509_REVOKED_sk_type(sk)))
125 #define sk_X509_REVOKED_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_copyfunc_type(copyfunc), ossl_check_X509_REVOKED_freefunc_type(freefunc)))
126 #define sk_X509_REVOKED_set_cmp_func(sk, cmp) ((sk_X509_REVOKED_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_compfunc_type(cmp)))
127 SKM_DEFINE_STACK_OF_INTERNAL(X509_CRL, X509_CRL, X509_CRL)
128 #define sk_X509_CRL_num(sk) OPENSSL_sk_num(ossl_check_const_X509_CRL_sk_type(sk))
129 #define sk_X509_CRL_value(sk, idx) ((X509_CRL *)OPENSSL_sk_value(ossl_check_const_X509_CRL_sk_type(sk), (idx)))
130 #define sk_X509_CRL_new(cmp) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new(ossl_check_X509_CRL_compfunc_type(cmp)))
131 #define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_null())
132 #define sk_X509_CRL_new_reserve(cmp, n) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_reserve(ossl_check_X509_CRL_compfunc_type(cmp), (n)))
133 #define sk_X509_CRL_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_CRL_sk_type(sk), (n))
134 #define sk_X509_CRL_free(sk) OPENSSL_sk_free(ossl_check_X509_CRL_sk_type(sk))
135 #define sk_X509_CRL_zero(sk) OPENSSL_sk_zero(ossl_check_X509_CRL_sk_type(sk))
136 #define sk_X509_CRL_delete(sk, i) ((X509_CRL *)OPENSSL_sk_delete(ossl_check_X509_CRL_sk_type(sk), (i)))
137 #define sk_X509_CRL_delete_ptr(sk, ptr) ((X509_CRL *)OPENSSL_sk_delete_ptr(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)))
138 #define sk_X509_CRL_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
139 #define sk_X509_CRL_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
140 #define sk_X509_CRL_pop(sk) ((X509_CRL *)OPENSSL_sk_pop(ossl_check_X509_CRL_sk_type(sk)))
141 #define sk_X509_CRL_shift(sk) ((X509_CRL *)OPENSSL_sk_shift(ossl_check_X509_CRL_sk_type(sk)))
142 #define sk_X509_CRL_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_CRL_sk_type(sk),ossl_check_X509_CRL_freefunc_type(freefunc))
143 #define sk_X509_CRL_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), (idx))
144 #define sk_X509_CRL_set(sk, idx, ptr) ((X509_CRL *)OPENSSL_sk_set(ossl_check_X509_CRL_sk_type(sk), (idx), ossl_check_X509_CRL_type(ptr)))
145 #define sk_X509_CRL_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
146 #define sk_X509_CRL_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
147 #define sk_X509_CRL_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), pnum)
148 #define sk_X509_CRL_sort(sk) OPENSSL_sk_sort(ossl_check_X509_CRL_sk_type(sk))
149 #define sk_X509_CRL_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_CRL_sk_type(sk))
150 #define sk_X509_CRL_dup(sk) ((STACK_OF(X509_CRL) *)OPENSSL_sk_dup(ossl_check_const_X509_CRL_sk_type(sk)))
151 #define sk_X509_CRL_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_CRL) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_CRL_sk_type(sk), ossl_check_X509_CRL_copyfunc_type(copyfunc), ossl_check_X509_CRL_freefunc_type(freefunc)))
152 #define sk_X509_CRL_set_cmp_func(sk, cmp) ((sk_X509_CRL_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_compfunc_type(cmp)))
153 
154 
155 /* Flags for X509_get_signature_info() */
156 /* Signature info is valid */
157 # define X509_SIG_INFO_VALID     0x1
158 /* Signature is suitable for TLS use */
159 # define X509_SIG_INFO_TLS       0x2
160 
161 # define X509_FILETYPE_PEM       1
162 # define X509_FILETYPE_ASN1      2
163 # define X509_FILETYPE_DEFAULT   3
164 
165 # define X509v3_KU_DIGITAL_SIGNATURE     0x0080
166 # define X509v3_KU_NON_REPUDIATION       0x0040
167 # define X509v3_KU_KEY_ENCIPHERMENT      0x0020
168 # define X509v3_KU_DATA_ENCIPHERMENT     0x0010
169 # define X509v3_KU_KEY_AGREEMENT         0x0008
170 # define X509v3_KU_KEY_CERT_SIGN         0x0004
171 # define X509v3_KU_CRL_SIGN              0x0002
172 # define X509v3_KU_ENCIPHER_ONLY         0x0001
173 # define X509v3_KU_DECIPHER_ONLY         0x8000
174 # define X509v3_KU_UNDEF                 0xffff
175 
176 struct X509_algor_st {
177     ASN1_OBJECT *algorithm;
178     ASN1_TYPE *parameter;
179 } /* X509_ALGOR */ ;
180 
181 typedef STACK_OF(X509_ALGOR) X509_ALGORS;
182 
183 typedef struct X509_val_st {
184     ASN1_TIME *notBefore;
185     ASN1_TIME *notAfter;
186 } X509_VAL;
187 
188 typedef struct X509_sig_st X509_SIG;
189 
190 typedef struct X509_name_entry_st X509_NAME_ENTRY;
191 
192 SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME_ENTRY, X509_NAME_ENTRY, X509_NAME_ENTRY)
193 #define sk_X509_NAME_ENTRY_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))
194 #define sk_X509_NAME_ENTRY_value(sk, idx) ((X509_NAME_ENTRY *)OPENSSL_sk_value(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), (idx)))
195 #define sk_X509_NAME_ENTRY_new(cmp) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp)))
196 #define sk_X509_NAME_ENTRY_new_null() ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_null())
197 #define sk_X509_NAME_ENTRY_new_reserve(cmp, n) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp), (n)))
198 #define sk_X509_NAME_ENTRY_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_ENTRY_sk_type(sk), (n))
199 #define sk_X509_NAME_ENTRY_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_ENTRY_sk_type(sk))
200 #define sk_X509_NAME_ENTRY_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_ENTRY_sk_type(sk))
201 #define sk_X509_NAME_ENTRY_delete(sk, i) ((X509_NAME_ENTRY *)OPENSSL_sk_delete(ossl_check_X509_NAME_ENTRY_sk_type(sk), (i)))
202 #define sk_X509_NAME_ENTRY_delete_ptr(sk, ptr) ((X509_NAME_ENTRY *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)))
203 #define sk_X509_NAME_ENTRY_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr))
204 #define sk_X509_NAME_ENTRY_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr))
205 #define sk_X509_NAME_ENTRY_pop(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_pop(ossl_check_X509_NAME_ENTRY_sk_type(sk)))
206 #define sk_X509_NAME_ENTRY_shift(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_shift(ossl_check_X509_NAME_ENTRY_sk_type(sk)))
207 #define sk_X509_NAME_ENTRY_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_NAME_ENTRY_sk_type(sk),ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc))
208 #define sk_X509_NAME_ENTRY_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr), (idx))
209 #define sk_X509_NAME_ENTRY_set(sk, idx, ptr) ((X509_NAME_ENTRY *)OPENSSL_sk_set(ossl_check_X509_NAME_ENTRY_sk_type(sk), (idx), ossl_check_X509_NAME_ENTRY_type(ptr)))
210 #define sk_X509_NAME_ENTRY_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr))
211 #define sk_X509_NAME_ENTRY_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr))
212 #define sk_X509_NAME_ENTRY_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr), pnum)
213 #define sk_X509_NAME_ENTRY_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_ENTRY_sk_type(sk))
214 #define sk_X509_NAME_ENTRY_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))
215 #define sk_X509_NAME_ENTRY_dup(sk) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)))
216 #define sk_X509_NAME_ENTRY_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_copyfunc_type(copyfunc), ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc)))
217 #define sk_X509_NAME_ENTRY_set_cmp_func(sk, cmp) ((sk_X509_NAME_ENTRY_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_compfunc_type(cmp)))
218 
219 
220 # define X509_EX_V_NETSCAPE_HACK         0x8000
221 # define X509_EX_V_INIT                  0x0001
222 typedef struct X509_extension_st X509_EXTENSION;
223 SKM_DEFINE_STACK_OF_INTERNAL(X509_EXTENSION, X509_EXTENSION, X509_EXTENSION)
224 #define sk_X509_EXTENSION_num(sk) OPENSSL_sk_num(ossl_check_const_X509_EXTENSION_sk_type(sk))
225 #define sk_X509_EXTENSION_value(sk, idx) ((X509_EXTENSION *)OPENSSL_sk_value(ossl_check_const_X509_EXTENSION_sk_type(sk), (idx)))
226 #define sk_X509_EXTENSION_new(cmp) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new(ossl_check_X509_EXTENSION_compfunc_type(cmp)))
227 #define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_null())
228 #define sk_X509_EXTENSION_new_reserve(cmp, n) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_reserve(ossl_check_X509_EXTENSION_compfunc_type(cmp), (n)))
229 #define sk_X509_EXTENSION_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_EXTENSION_sk_type(sk), (n))
230 #define sk_X509_EXTENSION_free(sk) OPENSSL_sk_free(ossl_check_X509_EXTENSION_sk_type(sk))
231 #define sk_X509_EXTENSION_zero(sk) OPENSSL_sk_zero(ossl_check_X509_EXTENSION_sk_type(sk))
232 #define sk_X509_EXTENSION_delete(sk, i) ((X509_EXTENSION *)OPENSSL_sk_delete(ossl_check_X509_EXTENSION_sk_type(sk), (i)))
233 #define sk_X509_EXTENSION_delete_ptr(sk, ptr) ((X509_EXTENSION *)OPENSSL_sk_delete_ptr(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)))
234 #define sk_X509_EXTENSION_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
235 #define sk_X509_EXTENSION_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
236 #define sk_X509_EXTENSION_pop(sk) ((X509_EXTENSION *)OPENSSL_sk_pop(ossl_check_X509_EXTENSION_sk_type(sk)))
237 #define sk_X509_EXTENSION_shift(sk) ((X509_EXTENSION *)OPENSSL_sk_shift(ossl_check_X509_EXTENSION_sk_type(sk)))
238 #define sk_X509_EXTENSION_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_EXTENSION_sk_type(sk),ossl_check_X509_EXTENSION_freefunc_type(freefunc))
239 #define sk_X509_EXTENSION_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr), (idx))
240 #define sk_X509_EXTENSION_set(sk, idx, ptr) ((X509_EXTENSION *)OPENSSL_sk_set(ossl_check_X509_EXTENSION_sk_type(sk), (idx), ossl_check_X509_EXTENSION_type(ptr)))
241 #define sk_X509_EXTENSION_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
242 #define sk_X509_EXTENSION_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
243 #define sk_X509_EXTENSION_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr), pnum)
244 #define sk_X509_EXTENSION_sort(sk) OPENSSL_sk_sort(ossl_check_X509_EXTENSION_sk_type(sk))
245 #define sk_X509_EXTENSION_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_EXTENSION_sk_type(sk))
246 #define sk_X509_EXTENSION_dup(sk) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_dup(ossl_check_const_X509_EXTENSION_sk_type(sk)))
247 #define sk_X509_EXTENSION_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_copyfunc_type(copyfunc), ossl_check_X509_EXTENSION_freefunc_type(freefunc)))
248 #define sk_X509_EXTENSION_set_cmp_func(sk, cmp) ((sk_X509_EXTENSION_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_compfunc_type(cmp)))
249 
250 typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
251 typedef struct x509_attributes_st X509_ATTRIBUTE;
252 SKM_DEFINE_STACK_OF_INTERNAL(X509_ATTRIBUTE, X509_ATTRIBUTE, X509_ATTRIBUTE)
253 #define sk_X509_ATTRIBUTE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))
254 #define sk_X509_ATTRIBUTE_value(sk, idx) ((X509_ATTRIBUTE *)OPENSSL_sk_value(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), (idx)))
255 #define sk_X509_ATTRIBUTE_new(cmp) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp)))
256 #define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_null())
257 #define sk_X509_ATTRIBUTE_new_reserve(cmp, n) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_reserve(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp), (n)))
258 #define sk_X509_ATTRIBUTE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ATTRIBUTE_sk_type(sk), (n))
259 #define sk_X509_ATTRIBUTE_free(sk) OPENSSL_sk_free(ossl_check_X509_ATTRIBUTE_sk_type(sk))
260 #define sk_X509_ATTRIBUTE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ATTRIBUTE_sk_type(sk))
261 #define sk_X509_ATTRIBUTE_delete(sk, i) ((X509_ATTRIBUTE *)OPENSSL_sk_delete(ossl_check_X509_ATTRIBUTE_sk_type(sk), (i)))
262 #define sk_X509_ATTRIBUTE_delete_ptr(sk, ptr) ((X509_ATTRIBUTE *)OPENSSL_sk_delete_ptr(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)))
263 #define sk_X509_ATTRIBUTE_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
264 #define sk_X509_ATTRIBUTE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
265 #define sk_X509_ATTRIBUTE_pop(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_pop(ossl_check_X509_ATTRIBUTE_sk_type(sk)))
266 #define sk_X509_ATTRIBUTE_shift(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_shift(ossl_check_X509_ATTRIBUTE_sk_type(sk)))
267 #define sk_X509_ATTRIBUTE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_ATTRIBUTE_sk_type(sk),ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc))
268 #define sk_X509_ATTRIBUTE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr), (idx))
269 #define sk_X509_ATTRIBUTE_set(sk, idx, ptr) ((X509_ATTRIBUTE *)OPENSSL_sk_set(ossl_check_X509_ATTRIBUTE_sk_type(sk), (idx), ossl_check_X509_ATTRIBUTE_type(ptr)))
270 #define sk_X509_ATTRIBUTE_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
271 #define sk_X509_ATTRIBUTE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
272 #define sk_X509_ATTRIBUTE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr), pnum)
273 #define sk_X509_ATTRIBUTE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ATTRIBUTE_sk_type(sk))
274 #define sk_X509_ATTRIBUTE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))
275 #define sk_X509_ATTRIBUTE_dup(sk) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_dup(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)))
276 #define sk_X509_ATTRIBUTE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_copyfunc_type(copyfunc), ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc)))
277 #define sk_X509_ATTRIBUTE_set_cmp_func(sk, cmp) ((sk_X509_ATTRIBUTE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_compfunc_type(cmp)))
278 
279 typedef struct X509_req_info_st X509_REQ_INFO;
280 typedef struct X509_req_st X509_REQ;
281 typedef struct x509_cert_aux_st X509_CERT_AUX;
282 typedef struct x509_cinf_st X509_CINF;
283 
284 /* Flags for X509_print_ex() */
285 
286 # define X509_FLAG_COMPAT                0
287 # define X509_FLAG_NO_HEADER             1L
288 # define X509_FLAG_NO_VERSION            (1L << 1)
289 # define X509_FLAG_NO_SERIAL             (1L << 2)
290 # define X509_FLAG_NO_SIGNAME            (1L << 3)
291 # define X509_FLAG_NO_ISSUER             (1L << 4)
292 # define X509_FLAG_NO_VALIDITY           (1L << 5)
293 # define X509_FLAG_NO_SUBJECT            (1L << 6)
294 # define X509_FLAG_NO_PUBKEY             (1L << 7)
295 # define X509_FLAG_NO_EXTENSIONS         (1L << 8)
296 # define X509_FLAG_NO_SIGDUMP            (1L << 9)
297 # define X509_FLAG_NO_AUX                (1L << 10)
298 # define X509_FLAG_NO_ATTRIBUTES         (1L << 11)
299 # define X509_FLAG_NO_IDS                (1L << 12)
300 # define X509_FLAG_EXTENSIONS_ONLY_KID   (1L << 13)
301 
302 /* Flags specific to X509_NAME_print_ex() */
303 
304 /* The field separator information */
305 
306 # define XN_FLAG_SEP_MASK        (0xf << 16)
307 
308 # define XN_FLAG_COMPAT          0/* Traditional; use old X509_NAME_print */
309 # define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */
310 # define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */
311 # define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */
312 # define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */
313 
314 # define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */
315 
316 /* How the field name is shown */
317 
318 # define XN_FLAG_FN_MASK         (0x3 << 21)
319 
320 # define XN_FLAG_FN_SN           0/* Object short name */
321 # define XN_FLAG_FN_LN           (1 << 21)/* Object long name */
322 # define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */
323 # define XN_FLAG_FN_NONE         (3 << 21)/* No field names */
324 
325 # define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */
326 
327 /*
328  * This determines if we dump fields we don't recognise: RFC2253 requires
329  * this.
330  */
331 
332 # define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
333 
334 # define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20
335                                            * characters */
336 
337 /* Complete set of RFC2253 flags */
338 
339 # define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
340                         XN_FLAG_SEP_COMMA_PLUS | \
341                         XN_FLAG_DN_REV | \
342                         XN_FLAG_FN_SN | \
343                         XN_FLAG_DUMP_UNKNOWN_FIELDS)
344 
345 /* readable oneline form */
346 
347 # define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
348                         ASN1_STRFLGS_ESC_QUOTE | \
349                         XN_FLAG_SEP_CPLUS_SPC | \
350                         XN_FLAG_SPC_EQ | \
351                         XN_FLAG_FN_SN)
352 
353 /* readable multiline form */
354 
355 # define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
356                         ASN1_STRFLGS_ESC_MSB | \
357                         XN_FLAG_SEP_MULTILINE | \
358                         XN_FLAG_SPC_EQ | \
359                         XN_FLAG_FN_LN | \
360                         XN_FLAG_FN_ALIGN)
361 
362 typedef struct X509_crl_info_st X509_CRL_INFO;
363 
364 typedef struct private_key_st {
365     int version;
366     /* The PKCS#8 data types */
367     X509_ALGOR *enc_algor;
368     ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
369     /* When decrypted, the following will not be NULL */
370     EVP_PKEY *dec_pkey;
371     /* used to encrypt and decrypt */
372     int key_length;
373     char *key_data;
374     int key_free;               /* true if we should auto free key_data */
375     /* expanded version of 'enc_algor' */
376     EVP_CIPHER_INFO cipher;
377 } X509_PKEY;
378 
379 typedef struct X509_info_st {
380     X509 *x509;
381     X509_CRL *crl;
382     X509_PKEY *x_pkey;
383     EVP_CIPHER_INFO enc_cipher;
384     int enc_len;
385     char *enc_data;
386 } X509_INFO;
387 SKM_DEFINE_STACK_OF_INTERNAL(X509_INFO, X509_INFO, X509_INFO)
388 #define sk_X509_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_X509_INFO_sk_type(sk))
389 #define sk_X509_INFO_value(sk, idx) ((X509_INFO *)OPENSSL_sk_value(ossl_check_const_X509_INFO_sk_type(sk), (idx)))
390 #define sk_X509_INFO_new(cmp) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new(ossl_check_X509_INFO_compfunc_type(cmp)))
391 #define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_null())
392 #define sk_X509_INFO_new_reserve(cmp, n) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_reserve(ossl_check_X509_INFO_compfunc_type(cmp), (n)))
393 #define sk_X509_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_INFO_sk_type(sk), (n))
394 #define sk_X509_INFO_free(sk) OPENSSL_sk_free(ossl_check_X509_INFO_sk_type(sk))
395 #define sk_X509_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_X509_INFO_sk_type(sk))
396 #define sk_X509_INFO_delete(sk, i) ((X509_INFO *)OPENSSL_sk_delete(ossl_check_X509_INFO_sk_type(sk), (i)))
397 #define sk_X509_INFO_delete_ptr(sk, ptr) ((X509_INFO *)OPENSSL_sk_delete_ptr(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)))
398 #define sk_X509_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
399 #define sk_X509_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
400 #define sk_X509_INFO_pop(sk) ((X509_INFO *)OPENSSL_sk_pop(ossl_check_X509_INFO_sk_type(sk)))
401 #define sk_X509_INFO_shift(sk) ((X509_INFO *)OPENSSL_sk_shift(ossl_check_X509_INFO_sk_type(sk)))
402 #define sk_X509_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_INFO_sk_type(sk),ossl_check_X509_INFO_freefunc_type(freefunc))
403 #define sk_X509_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), (idx))
404 #define sk_X509_INFO_set(sk, idx, ptr) ((X509_INFO *)OPENSSL_sk_set(ossl_check_X509_INFO_sk_type(sk), (idx), ossl_check_X509_INFO_type(ptr)))
405 #define sk_X509_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
406 #define sk_X509_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
407 #define sk_X509_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), pnum)
408 #define sk_X509_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_X509_INFO_sk_type(sk))
409 #define sk_X509_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_INFO_sk_type(sk))
410 #define sk_X509_INFO_dup(sk) ((STACK_OF(X509_INFO) *)OPENSSL_sk_dup(ossl_check_const_X509_INFO_sk_type(sk)))
411 #define sk_X509_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_INFO_sk_type(sk), ossl_check_X509_INFO_copyfunc_type(copyfunc), ossl_check_X509_INFO_freefunc_type(freefunc)))
412 #define sk_X509_INFO_set_cmp_func(sk, cmp) ((sk_X509_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_compfunc_type(cmp)))
413 
414 
415 /*
416  * The next 2 structures and their 8 routines are used to manipulate Netscape's
417  * spki structures - useful if you are writing a CA web page
418  */
419 typedef struct Netscape_spkac_st {
420     X509_PUBKEY *pubkey;
421     ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */
422 } NETSCAPE_SPKAC;
423 
424 typedef struct Netscape_spki_st {
425     NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */
426     X509_ALGOR sig_algor;
427     ASN1_BIT_STRING *signature;
428 } NETSCAPE_SPKI;
429 
430 /* Netscape certificate sequence structure */
431 typedef struct Netscape_certificate_sequence {
432     ASN1_OBJECT *type;
433     STACK_OF(X509) *certs;
434 } NETSCAPE_CERT_SEQUENCE;
435 
436 /*- Unused (and iv length is wrong)
437 typedef struct CBCParameter_st
438         {
439         unsigned char iv[8];
440         } CBC_PARAM;
441 */
442 
443 /* Password based encryption structure */
444 
445 typedef struct PBEPARAM_st {
446     ASN1_OCTET_STRING *salt;
447     ASN1_INTEGER *iter;
448 } PBEPARAM;
449 
450 /* Password based encryption V2 structures */
451 
452 typedef struct PBE2PARAM_st {
453     X509_ALGOR *keyfunc;
454     X509_ALGOR *encryption;
455 } PBE2PARAM;
456 
457 typedef struct PBKDF2PARAM_st {
458 /* Usually OCTET STRING but could be anything */
459     ASN1_TYPE *salt;
460     ASN1_INTEGER *iter;
461     ASN1_INTEGER *keylength;
462     X509_ALGOR *prf;
463 } PBKDF2PARAM;
464 
465 #ifndef OPENSSL_NO_SCRYPT
466 typedef struct SCRYPT_PARAMS_st {
467     ASN1_OCTET_STRING *salt;
468     ASN1_INTEGER *costParameter;
469     ASN1_INTEGER *blockSize;
470     ASN1_INTEGER *parallelizationParameter;
471     ASN1_INTEGER *keyLength;
472 } SCRYPT_PARAMS;
473 #endif
474 
475 #ifdef  __cplusplus
476 }
477 #endif
478 
479 # include <openssl/x509_vfy.h>
480 # include <openssl/pkcs7.h>
481 
482 #ifdef  __cplusplus
483 extern "C" {
484 #endif
485 
486 # define X509_EXT_PACK_UNKNOWN   1
487 # define X509_EXT_PACK_STRING    2
488 
489 # define         X509_extract_key(x)     X509_get_pubkey(x)/*****/
490 # define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
491 # define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))
492 
493 void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
494 X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
495                                      int (*crl_free) (X509_CRL *crl),
496                                      int (*crl_lookup) (X509_CRL *crl,
497                                                         X509_REVOKED **ret,
498                                                         const
499                                                         ASN1_INTEGER *serial,
500                                                         const
501                                                         X509_NAME *issuer),
502                                      int (*crl_verify) (X509_CRL *crl,
503                                                         EVP_PKEY *pk));
504 void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
505 
506 void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
507 void *X509_CRL_get_meth_data(X509_CRL *crl);
508 
509 const char *X509_verify_cert_error_string(long n);
510 
511 int X509_verify(X509 *a, EVP_PKEY *r);
512 int X509_self_signed(X509 *cert, int verify_signature);
513 
514 int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *r, OSSL_LIB_CTX *libctx,
515                        const char *propq);
516 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
517 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
518 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
519 
520 NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);
521 char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
522 EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
523 int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
524 
525 int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
526 
527 int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
528 int X509_signature_print(BIO *bp, const X509_ALGOR *alg,
529                          const ASN1_STRING *sig);
530 
531 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
532 int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
533 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
534 int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
535 int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
536 int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
537 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
538 
539 int X509_pubkey_digest(const X509 *data, const EVP_MD *type,
540                        unsigned char *md, unsigned int *len);
541 int X509_digest(const X509 *data, const EVP_MD *type,
542                 unsigned char *md, unsigned int *len);
543 ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert,
544                                    EVP_MD **md_used, int *md_is_fallback);
545 int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
546                     unsigned char *md, unsigned int *len);
547 int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,
548                     unsigned char *md, unsigned int *len);
549 int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,
550                      unsigned char *md, unsigned int *len);
551 
552 X509 *X509_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);
553 X509_CRL *X509_CRL_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);
554 # ifndef OPENSSL_NO_DEPRECATED_3_0
555 #  include <openssl/http.h> /* OSSL_HTTP_REQ_CTX_nbio_d2i */
556 #  define X509_http_nbio(rctx, pcert) \
557       OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcert, ASN1_ITEM_rptr(X509))
558 #  define X509_CRL_http_nbio(rctx, pcrl) \
559       OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcrl, ASN1_ITEM_rptr(X509_CRL))
560 # endif
561 
562 # ifndef OPENSSL_NO_STDIO
563 X509 *d2i_X509_fp(FILE *fp, X509 **x509);
564 int i2d_X509_fp(FILE *fp, const X509 *x509);
565 X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);
566 int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl);
567 X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);
568 int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req);
569 #  ifndef OPENSSL_NO_DEPRECATED_3_0
570 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);
571 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa);
572 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);
573 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa);
574 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);
575 OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa);
576 #  endif
577 #  ifndef OPENSSL_NO_DEPRECATED_3_0
578 #   ifndef OPENSSL_NO_DSA
579 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
580 OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa);
581 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
582 OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa);
583 #   endif
584 #  endif
585 #  ifndef OPENSSL_NO_DEPRECATED_3_0
586 #   ifndef OPENSSL_NO_EC
587 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
588 OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey);
589 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
590 OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey);
591 #   endif /* OPENSSL_NO_EC */
592 #  endif /* OPENSSL_NO_DEPRECATED_3_0 */
593 X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);
594 int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8);
595 X509_PUBKEY *d2i_X509_PUBKEY_fp(FILE *fp, X509_PUBKEY **xpk);
596 int i2d_X509_PUBKEY_fp(FILE *fp, const X509_PUBKEY *xpk);
597 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
598                                                 PKCS8_PRIV_KEY_INFO **p8inf);
599 int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf);
600 int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key);
601 int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey);
602 EVP_PKEY *d2i_PrivateKey_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
603                                const char *propq);
604 EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
605 int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey);
606 EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
607 # endif
608 
609 X509 *d2i_X509_bio(BIO *bp, X509 **x509);
610 int i2d_X509_bio(BIO *bp, const X509 *x509);
611 X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);
612 int i2d_X509_CRL_bio(BIO *bp, const X509_CRL *crl);
613 X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);
614 int i2d_X509_REQ_bio(BIO *bp, const X509_REQ *req);
615 #  ifndef OPENSSL_NO_DEPRECATED_3_0
616 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);
617 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_bio(BIO *bp, const RSA *rsa);
618 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);
619 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_bio(BIO *bp, const RSA *rsa);
620 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);
621 OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa);
622 #  endif
623 #  ifndef OPENSSL_NO_DEPRECATED_3_0
624 #   ifndef OPENSSL_NO_DSA
625 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
626 OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa);
627 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
628 OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa);
629 #   endif
630 #  endif
631 
632 #  ifndef OPENSSL_NO_DEPRECATED_3_0
633 #   ifndef OPENSSL_NO_EC
634 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
635 OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *eckey);
636 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
637 OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey);
638 #   endif /* OPENSSL_NO_EC */
639 #  endif /* OPENSSL_NO_DEPRECATED_3_0 */
640 
641 X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);
642 int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8);
643 X509_PUBKEY *d2i_X509_PUBKEY_bio(BIO *bp, X509_PUBKEY **xpk);
644 int i2d_X509_PUBKEY_bio(BIO *bp, const X509_PUBKEY *xpk);
645 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
646                                                  PKCS8_PRIV_KEY_INFO **p8inf);
647 int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf);
648 int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key);
649 int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey);
650 EVP_PKEY *d2i_PrivateKey_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
651                                 const char *propq);
652 EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
653 int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey);
654 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
655 
656 DECLARE_ASN1_DUP_FUNCTION(X509)
657 DECLARE_ASN1_DUP_FUNCTION(X509_ALGOR)
658 DECLARE_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
659 DECLARE_ASN1_DUP_FUNCTION(X509_CRL)
660 DECLARE_ASN1_DUP_FUNCTION(X509_EXTENSION)
661 DECLARE_ASN1_DUP_FUNCTION(X509_PUBKEY)
662 DECLARE_ASN1_DUP_FUNCTION(X509_REQ)
663 DECLARE_ASN1_DUP_FUNCTION(X509_REVOKED)
664 int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,
665                     void *pval);
666 void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
667                      const void **ppval, const X509_ALGOR *algor);
668 void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
669 int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
670 int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);
671 
672 DECLARE_ASN1_DUP_FUNCTION(X509_NAME)
673 DECLARE_ASN1_DUP_FUNCTION(X509_NAME_ENTRY)
674 
675 int X509_cmp_time(const ASN1_TIME *s, time_t *t);
676 int X509_cmp_current_time(const ASN1_TIME *s);
677 int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm,
678                        const ASN1_TIME *start, const ASN1_TIME *end);
679 ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
680 ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
681                             int offset_day, long offset_sec, time_t *t);
682 ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
683 
684 const char *X509_get_default_cert_area(void);
685 const char *X509_get_default_cert_dir(void);
686 const char *X509_get_default_cert_file(void);
687 const char *X509_get_default_cert_dir_env(void);
688 const char *X509_get_default_cert_file_env(void);
689 const char *X509_get_default_private_dir(void);
690 
691 X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
692 X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
693 
694 DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
695 DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
696 DECLARE_ASN1_FUNCTIONS(X509_VAL)
697 
698 DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
699 
700 X509_PUBKEY *X509_PUBKEY_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
701 int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
702 EVP_PKEY *X509_PUBKEY_get0(const X509_PUBKEY *key);
703 EVP_PKEY *X509_PUBKEY_get(const X509_PUBKEY *key);
704 int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);
705 long X509_get_pathlen(X509 *x);
706 DECLARE_ASN1_ENCODE_FUNCTIONS_only(EVP_PKEY, PUBKEY)
707 EVP_PKEY *d2i_PUBKEY_ex(EVP_PKEY **a, const unsigned char **pp, long length,
708                         OSSL_LIB_CTX *libctx, const char *propq);
709 # ifndef OPENSSL_NO_DEPRECATED_3_0
710 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,RSA, RSA_PUBKEY)
711 # endif
712 # ifndef OPENSSL_NO_DEPRECATED_3_0
713 #  ifndef OPENSSL_NO_DSA
714 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,DSA, DSA_PUBKEY)
715 #  endif
716 # endif
717 # ifndef OPENSSL_NO_DEPRECATED_3_0
718 #  ifndef OPENSSL_NO_EC
719 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, EC_KEY, EC_PUBKEY)
720 #  endif
721 # endif
722 
723 DECLARE_ASN1_FUNCTIONS(X509_SIG)
724 void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,
725                    const ASN1_OCTET_STRING **pdigest);
726 void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,
727                    ASN1_OCTET_STRING **pdigest);
728 
729 DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
730 DECLARE_ASN1_FUNCTIONS(X509_REQ)
731 X509_REQ *X509_REQ_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
732 
733 DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
734 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
735 
736 DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
737 DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)
738 
739 DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
740 
741 DECLARE_ASN1_FUNCTIONS(X509_NAME)
742 
743 int X509_NAME_set(X509_NAME **xn, const X509_NAME *name);
744 
745 DECLARE_ASN1_FUNCTIONS(X509_CINF)
746 DECLARE_ASN1_FUNCTIONS(X509)
747 X509 *X509_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
748 DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
749 
750 #define X509_get_ex_new_index(l, p, newf, dupf, freef) \
751     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)
752 int X509_set_ex_data(X509 *r, int idx, void *arg);
753 void *X509_get_ex_data(const X509 *r, int idx);
754 DECLARE_ASN1_ENCODE_FUNCTIONS_only(X509,X509_AUX)
755 
756 int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
757 
758 int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,
759                       int *secbits, uint32_t *flags);
760 void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,
761                        int secbits, uint32_t flags);
762 
763 int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits,
764                             uint32_t *flags);
765 
766 void X509_get0_signature(const ASN1_BIT_STRING **psig,
767                          const X509_ALGOR **palg, const X509 *x);
768 int X509_get_signature_nid(const X509 *x);
769 
770 void X509_set0_distinguishing_id(X509 *x, ASN1_OCTET_STRING *d_id);
771 ASN1_OCTET_STRING *X509_get0_distinguishing_id(X509 *x);
772 void X509_REQ_set0_distinguishing_id(X509_REQ *x, ASN1_OCTET_STRING *d_id);
773 ASN1_OCTET_STRING *X509_REQ_get0_distinguishing_id(X509_REQ *x);
774 
775 int X509_alias_set1(X509 *x, const unsigned char *name, int len);
776 int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
777 unsigned char *X509_alias_get0(X509 *x, int *len);
778 unsigned char *X509_keyid_get0(X509 *x, int *len);
779 
780 DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
781 DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
782 DECLARE_ASN1_FUNCTIONS(X509_CRL)
783 X509_CRL *X509_CRL_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
784 
785 int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
786 int X509_CRL_get0_by_serial(X509_CRL *crl,
787                             X509_REVOKED **ret, const ASN1_INTEGER *serial);
788 int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
789 
790 X509_PKEY *X509_PKEY_new(void);
791 void X509_PKEY_free(X509_PKEY *a);
792 
793 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
794 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
795 DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
796 
797 X509_INFO *X509_INFO_new(void);
798 void X509_INFO_free(X509_INFO *a);
799 char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size);
800 
801 #ifndef OPENSSL_NO_DEPRECATED_3_0
802 OSSL_DEPRECATEDIN_3_0
803 int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
804                 ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);
805 OSSL_DEPRECATEDIN_3_0
806 int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
807                 unsigned char *md, unsigned int *len);
808 OSSL_DEPRECATEDIN_3_0
809 int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
810               ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey,
811               const EVP_MD *type);
812 #endif
813 int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,
814                      unsigned char *md, unsigned int *len);
815 int ASN1_item_verify(const ASN1_ITEM *it, const X509_ALGOR *alg,
816                      const ASN1_BIT_STRING *signature, const void *data,
817                      EVP_PKEY *pkey);
818 int ASN1_item_verify_ctx(const ASN1_ITEM *it, const X509_ALGOR *alg,
819                          const ASN1_BIT_STRING *signature, const void *data,
820                          EVP_MD_CTX *ctx);
821 int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
822                    ASN1_BIT_STRING *signature, const void *data,
823                    EVP_PKEY *pkey, const EVP_MD *md);
824 int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
825                        X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
826                        const void *data, EVP_MD_CTX *ctx);
827 
828 #define X509_VERSION_1 0
829 #define X509_VERSION_2 1
830 #define X509_VERSION_3 2
831 
832 long X509_get_version(const X509 *x);
833 int X509_set_version(X509 *x, long version);
834 int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
835 ASN1_INTEGER *X509_get_serialNumber(X509 *x);
836 const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);
837 int X509_set_issuer_name(X509 *x, const X509_NAME *name);
838 X509_NAME *X509_get_issuer_name(const X509 *a);
839 int X509_set_subject_name(X509 *x, const X509_NAME *name);
840 X509_NAME *X509_get_subject_name(const X509 *a);
841 const ASN1_TIME * X509_get0_notBefore(const X509 *x);
842 ASN1_TIME *X509_getm_notBefore(const X509 *x);
843 int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);
844 const ASN1_TIME *X509_get0_notAfter(const X509 *x);
845 ASN1_TIME *X509_getm_notAfter(const X509 *x);
846 int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);
847 int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
848 int X509_up_ref(X509 *x);
849 int X509_get_signature_type(const X509 *x);
850 
851 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
852 #  define X509_get_notBefore X509_getm_notBefore
853 #  define X509_get_notAfter X509_getm_notAfter
854 #  define X509_set_notBefore X509_set1_notBefore
855 #  define X509_set_notAfter X509_set1_notAfter
856 #endif
857 
858 
859 /*
860  * This one is only used so that a binary form can output, as in
861  * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf)
862  */
863 X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
864 const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
865 void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,
866                     const ASN1_BIT_STRING **psuid);
867 const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
868 
869 EVP_PKEY *X509_get0_pubkey(const X509 *x);
870 EVP_PKEY *X509_get_pubkey(X509 *x);
871 ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
872 
873 #define X509_REQ_VERSION_1 0
874 
875 long X509_REQ_get_version(const X509_REQ *req);
876 int X509_REQ_set_version(X509_REQ *x, long version);
877 X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
878 int X509_REQ_set_subject_name(X509_REQ *req, const X509_NAME *name);
879 void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
880                              const X509_ALGOR **palg);
881 void X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig);
882 int X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg);
883 int X509_REQ_get_signature_nid(const X509_REQ *req);
884 int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
885 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
886 EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
887 EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);
888 X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);
889 int X509_REQ_extension_nid(int nid);
890 int *X509_REQ_get_extension_nids(void);
891 void X509_REQ_set_extension_nids(int *nids);
892 STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
893 int X509_REQ_add_extensions_nid(X509_REQ *req,
894                                 const STACK_OF(X509_EXTENSION) *exts, int nid);
895 int X509_REQ_add_extensions(X509_REQ *req, const STACK_OF(X509_EXTENSION) *ext);
896 int X509_REQ_get_attr_count(const X509_REQ *req);
897 int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
898 int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
899                              int lastpos);
900 X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
901 X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
902 int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
903 int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
904                               const ASN1_OBJECT *obj, int type,
905                               const unsigned char *bytes, int len);
906 int X509_REQ_add1_attr_by_NID(X509_REQ *req,
907                               int nid, int type,
908                               const unsigned char *bytes, int len);
909 int X509_REQ_add1_attr_by_txt(X509_REQ *req,
910                               const char *attrname, int type,
911                               const unsigned char *bytes, int len);
912 
913 #define X509_CRL_VERSION_1 0
914 #define X509_CRL_VERSION_2 1
915 
916 int X509_CRL_set_version(X509_CRL *x, long version);
917 int X509_CRL_set_issuer_name(X509_CRL *x, const X509_NAME *name);
918 int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
919 int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
920 int X509_CRL_sort(X509_CRL *crl);
921 int X509_CRL_up_ref(X509_CRL *crl);
922 
923 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
924 #  define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate
925 #  define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate
926 #endif
927 
928 long X509_CRL_get_version(const X509_CRL *crl);
929 const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);
930 const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);
931 #ifndef OPENSSL_NO_DEPRECATED_1_1_0
932 OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl);
933 OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
934 #endif
935 X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
936 const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
937 STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
938 void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
939                              const X509_ALGOR **palg);
940 int X509_CRL_get_signature_nid(const X509_CRL *crl);
941 int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
942 
943 const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);
944 int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
945 const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);
946 int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
947 const STACK_OF(X509_EXTENSION) *
948 X509_REVOKED_get0_extensions(const X509_REVOKED *r);
949 
950 X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
951                         EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);
952 
953 int X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);
954 
955 int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);
956 int X509_chain_check_suiteb(int *perror_depth,
957                             X509 *x, STACK_OF(X509) *chain,
958                             unsigned long flags);
959 int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);
960 STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
961 
962 int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
963 unsigned long X509_issuer_and_serial_hash(X509 *a);
964 
965 int X509_issuer_name_cmp(const X509 *a, const X509 *b);
966 unsigned long X509_issuer_name_hash(X509 *a);
967 
968 int X509_subject_name_cmp(const X509 *a, const X509 *b);
969 unsigned long X509_subject_name_hash(X509 *x);
970 
971 # ifndef OPENSSL_NO_MD5
972 unsigned long X509_issuer_name_hash_old(X509 *a);
973 unsigned long X509_subject_name_hash_old(X509 *x);
974 # endif
975 
976 # define X509_ADD_FLAG_DEFAULT  0
977 # define X509_ADD_FLAG_UP_REF   0x1
978 # define X509_ADD_FLAG_PREPEND  0x2
979 # define X509_ADD_FLAG_NO_DUP   0x4
980 # define X509_ADD_FLAG_NO_SS    0x8
981 int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags);
982 int X509_add_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs, int flags);
983 
984 int X509_cmp(const X509 *a, const X509 *b);
985 int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
986 #ifndef OPENSSL_NO_DEPRECATED_3_0
987 # define X509_NAME_hash(x) X509_NAME_hash_ex(x, NULL, NULL, NULL)
988 OSSL_DEPRECATEDIN_3_0 int X509_certificate_type(const X509 *x,
989                                                 const EVP_PKEY *pubkey);
990 #endif
991 unsigned long X509_NAME_hash_ex(const X509_NAME *x, OSSL_LIB_CTX *libctx,
992                                 const char *propq, int *ok);
993 unsigned long X509_NAME_hash_old(const X509_NAME *x);
994 
995 int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
996 int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
997 int X509_aux_print(BIO *out, X509 *x, int indent);
998 # ifndef OPENSSL_NO_STDIO
999 int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,
1000                      unsigned long cflag);
1001 int X509_print_fp(FILE *bp, X509 *x);
1002 int X509_CRL_print_fp(FILE *bp, X509_CRL *x);
1003 int X509_REQ_print_fp(FILE *bp, X509_REQ *req);
1004 int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,
1005                           unsigned long flags);
1006 # endif
1007 
1008 int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);
1009 int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,
1010                        unsigned long flags);
1011 int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,
1012                   unsigned long cflag);
1013 int X509_print(BIO *bp, X509 *x);
1014 int X509_ocspid_print(BIO *bp, X509 *x);
1015 int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag);
1016 int X509_CRL_print(BIO *bp, X509_CRL *x);
1017 int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,
1018                       unsigned long cflag);
1019 int X509_REQ_print(BIO *bp, X509_REQ *req);
1020 
1021 int X509_NAME_entry_count(const X509_NAME *name);
1022 int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid,
1023                               char *buf, int len);
1024 int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
1025                               char *buf, int len);
1026 
1027 /*
1028  * NOTE: you should be passing -1, not 0 as lastpos. The functions that use
1029  * lastpos, search after that position on.
1030  */
1031 int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos);
1032 int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
1033                                int lastpos);
1034 X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
1035 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
1036 int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,
1037                         int loc, int set);
1038 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
1039                                const unsigned char *bytes, int len, int loc,
1040                                int set);
1041 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
1042                                const unsigned char *bytes, int len, int loc,
1043                                int set);
1044 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
1045                                                const char *field, int type,
1046                                                const unsigned char *bytes,
1047                                                int len);
1048 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
1049                                                int type,
1050                                                const unsigned char *bytes,
1051                                                int len);
1052 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
1053                                const unsigned char *bytes, int len, int loc,
1054                                int set);
1055 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
1056                                                const ASN1_OBJECT *obj, int type,
1057                                                const unsigned char *bytes,
1058                                                int len);
1059 int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj);
1060 int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
1061                              const unsigned char *bytes, int len);
1062 ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);
1063 ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);
1064 int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
1065 
1066 int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder,
1067                        size_t *pderlen);
1068 
1069 int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
1070 int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
1071                           int nid, int lastpos);
1072 int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
1073                           const ASN1_OBJECT *obj, int lastpos);
1074 int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
1075                                int crit, int lastpos);
1076 X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
1077 X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
1078 STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
1079                                          X509_EXTENSION *ex, int loc);
1080 
1081 int X509_get_ext_count(const X509 *x);
1082 int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);
1083 int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos);
1084 int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);
1085 X509_EXTENSION *X509_get_ext(const X509 *x, int loc);
1086 X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
1087 int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
1088 void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
1089 int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
1090                       unsigned long flags);
1091 
1092 int X509_CRL_get_ext_count(const X509_CRL *x);
1093 int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);
1094 int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
1095                             int lastpos);
1096 int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos);
1097 X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
1098 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
1099 int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
1100 void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);
1101 int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
1102                           unsigned long flags);
1103 
1104 int X509_REVOKED_get_ext_count(const X509_REVOKED *x);
1105 int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos);
1106 int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
1107                                 int lastpos);
1108 int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
1109                                      int lastpos);
1110 X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);
1111 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
1112 int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
1113 void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit,
1114                                int *idx);
1115 int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
1116                               unsigned long flags);
1117 
1118 X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
1119                                              int nid, int crit,
1120                                              ASN1_OCTET_STRING *data);
1121 X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
1122                                              const ASN1_OBJECT *obj, int crit,
1123                                              ASN1_OCTET_STRING *data);
1124 int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);
1125 int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
1126 int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);
1127 ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);
1128 ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
1129 int X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
1130 
1131 int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
1132 int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
1133                            int lastpos);
1134 int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
1135                            const ASN1_OBJECT *obj, int lastpos);
1136 X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
1137 X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1138 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1139                                            X509_ATTRIBUTE *attr);
1140 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
1141                                                   **x, const ASN1_OBJECT *obj,
1142                                                   int type,
1143                                                   const unsigned char *bytes,
1144                                                   int len);
1145 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)
1146                                                   **x, int nid, int type,
1147                                                   const unsigned char *bytes,
1148                                                   int len);
1149 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)
1150                                                   **x, const char *attrname,
1151                                                   int type,
1152                                                   const unsigned char *bytes,
1153                                                   int len);
1154 void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x,
1155                               const ASN1_OBJECT *obj, int lastpos, int type);
1156 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1157                                              int atrtype, const void *data,
1158                                              int len);
1159 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1160                                              const ASN1_OBJECT *obj,
1161                                              int atrtype, const void *data,
1162                                              int len);
1163 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1164                                              const char *atrname, int type,
1165                                              const unsigned char *bytes,
1166                                              int len);
1167 int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
1168 int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
1169                              const void *data, int len);
1170 void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,
1171                                void *data);
1172 int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
1173 ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1174 ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
1175 
1176 int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
1177 int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
1178 int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
1179                              int lastpos);
1180 X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
1181 X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
1182 int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
1183 int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
1184                               const ASN1_OBJECT *obj, int type,
1185                               const unsigned char *bytes, int len);
1186 int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
1187                               int nid, int type,
1188                               const unsigned char *bytes, int len);
1189 int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
1190                               const char *attrname, int type,
1191                               const unsigned char *bytes, int len);
1192 
1193 /* lookup a cert from a X509 STACK */
1194 X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, const X509_NAME *name,
1195                                      const ASN1_INTEGER *serial);
1196 X509 *X509_find_by_subject(STACK_OF(X509) *sk, const X509_NAME *name);
1197 
1198 DECLARE_ASN1_FUNCTIONS(PBEPARAM)
1199 DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
1200 DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
1201 #ifndef OPENSSL_NO_SCRYPT
1202 DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS)
1203 #endif
1204 
1205 int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
1206                          const unsigned char *salt, int saltlen);
1207 int PKCS5_pbe_set0_algor_ex(X509_ALGOR *algor, int alg, int iter,
1208                             const unsigned char *salt, int saltlen,
1209                             OSSL_LIB_CTX *libctx);
1210 
1211 X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
1212                           const unsigned char *salt, int saltlen);
1213 X509_ALGOR *PKCS5_pbe_set_ex(int alg, int iter,
1214                              const unsigned char *salt, int saltlen,
1215                              OSSL_LIB_CTX *libctx);
1216 
1217 X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
1218                            unsigned char *salt, int saltlen);
1219 X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
1220                               unsigned char *salt, int saltlen,
1221                               unsigned char *aiv, int prf_nid);
1222 X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter,
1223                                  unsigned char *salt, int saltlen,
1224                                  unsigned char *aiv, int prf_nid,
1225                                  OSSL_LIB_CTX *libctx);
1226 
1227 #ifndef OPENSSL_NO_SCRYPT
1228 X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,
1229                                   const unsigned char *salt, int saltlen,
1230                                   unsigned char *aiv, uint64_t N, uint64_t r,
1231                                   uint64_t p);
1232 #endif
1233 
1234 X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
1235                              int prf_nid, int keylen);
1236 X509_ALGOR *PKCS5_pbkdf2_set_ex(int iter, unsigned char *salt, int saltlen,
1237                                 int prf_nid, int keylen,
1238                                 OSSL_LIB_CTX *libctx);
1239 
1240 /* PKCS#8 utilities */
1241 
1242 DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
1243 
1244 EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);
1245 EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
1246                             const char *propq);
1247 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey);
1248 
1249 int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
1250                     int version, int ptype, void *pval,
1251                     unsigned char *penc, int penclen);
1252 int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,
1253                     const unsigned char **pk, int *ppklen,
1254                     const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);
1255 
1256 const STACK_OF(X509_ATTRIBUTE) *
1257 PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);
1258 int PKCS8_pkey_add1_attr(PKCS8_PRIV_KEY_INFO *p8, X509_ATTRIBUTE *attr);
1259 int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,
1260                                 const unsigned char *bytes, int len);
1261 int PKCS8_pkey_add1_attr_by_OBJ(PKCS8_PRIV_KEY_INFO *p8, const ASN1_OBJECT *obj,
1262                                 int type, const unsigned char *bytes, int len);
1263 
1264 
1265 int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
1266                            int ptype, void *pval,
1267                            unsigned char *penc, int penclen);
1268 int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
1269                            const unsigned char **pk, int *ppklen,
1270                            X509_ALGOR **pa, const X509_PUBKEY *pub);
1271 int X509_PUBKEY_eq(const X509_PUBKEY *a, const X509_PUBKEY *b);
1272 
1273 # ifdef  __cplusplus
1274 }
1275 # endif
1276 #endif
1277