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