Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:53

0001 /*
0002  * WARNING: do not edit!
0003  * Generated by Makefile from include/openssl/x509.h.in
0004  *
0005  * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
0006  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
0007  *
0008  * Licensed under the Apache License 2.0 (the "License").  You may not use
0009  * this file except in compliance with the License.  You can obtain a copy
0010  * in the file LICENSE in the source distribution or at
0011  * https://www.openssl.org/source/license.html
0012  */
0013 
0014 
0015 
0016 #ifndef OPENSSL_X509_H
0017 # define OPENSSL_X509_H
0018 # pragma once
0019 
0020 # include <openssl/macros.h>
0021 # ifndef OPENSSL_NO_DEPRECATED_3_0
0022 #  define HEADER_X509_H
0023 # endif
0024 
0025 # include <openssl/e_os2.h>
0026 # include <openssl/types.h>
0027 # include <openssl/symhacks.h>
0028 # include <openssl/buffer.h>
0029 # include <openssl/evp.h>
0030 # include <openssl/bio.h>
0031 # include <openssl/asn1.h>
0032 # include <openssl/safestack.h>
0033 # include <openssl/ec.h>
0034 
0035 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0036 #  include <openssl/rsa.h>
0037 #  include <openssl/dsa.h>
0038 #  include <openssl/dh.h>
0039 # endif
0040 
0041 # include <openssl/sha.h>
0042 # include <openssl/x509err.h>
0043 # ifndef OPENSSL_NO_STDIO
0044 #  include <stdio.h>
0045 # endif
0046 
0047 #ifdef  __cplusplus
0048 extern "C" {
0049 #endif
0050 
0051 /* Needed stacks for types defined in other headers */
0052 SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME, X509_NAME, X509_NAME)
0053 #define sk_X509_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_sk_type(sk))
0054 #define sk_X509_NAME_value(sk, idx) ((X509_NAME *)OPENSSL_sk_value(ossl_check_const_X509_NAME_sk_type(sk), (idx)))
0055 #define sk_X509_NAME_new(cmp) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new(ossl_check_X509_NAME_compfunc_type(cmp)))
0056 #define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_null())
0057 #define sk_X509_NAME_new_reserve(cmp, n) ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_compfunc_type(cmp), (n)))
0058 #define sk_X509_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_sk_type(sk), (n))
0059 #define sk_X509_NAME_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_sk_type(sk))
0060 #define sk_X509_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_sk_type(sk))
0061 #define sk_X509_NAME_delete(sk, i) ((X509_NAME *)OPENSSL_sk_delete(ossl_check_X509_NAME_sk_type(sk), (i)))
0062 #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)))
0063 #define sk_X509_NAME_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
0064 #define sk_X509_NAME_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
0065 #define sk_X509_NAME_pop(sk) ((X509_NAME *)OPENSSL_sk_pop(ossl_check_X509_NAME_sk_type(sk)))
0066 #define sk_X509_NAME_shift(sk) ((X509_NAME *)OPENSSL_sk_shift(ossl_check_X509_NAME_sk_type(sk)))
0067 #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))
0068 #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))
0069 #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)))
0070 #define sk_X509_NAME_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr))
0071 #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))
0072 #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)
0073 #define sk_X509_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_sk_type(sk))
0074 #define sk_X509_NAME_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_sk_type(sk))
0075 #define sk_X509_NAME_dup(sk) ((STACK_OF(X509_NAME) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_sk_type(sk)))
0076 #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)))
0077 #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)))
0078 SKM_DEFINE_STACK_OF_INTERNAL(X509, X509, X509)
0079 #define sk_X509_num(sk) OPENSSL_sk_num(ossl_check_const_X509_sk_type(sk))
0080 #define sk_X509_value(sk, idx) ((X509 *)OPENSSL_sk_value(ossl_check_const_X509_sk_type(sk), (idx)))
0081 #define sk_X509_new(cmp) ((STACK_OF(X509) *)OPENSSL_sk_new(ossl_check_X509_compfunc_type(cmp)))
0082 #define sk_X509_new_null() ((STACK_OF(X509) *)OPENSSL_sk_new_null())
0083 #define sk_X509_new_reserve(cmp, n) ((STACK_OF(X509) *)OPENSSL_sk_new_reserve(ossl_check_X509_compfunc_type(cmp), (n)))
0084 #define sk_X509_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_sk_type(sk), (n))
0085 #define sk_X509_free(sk) OPENSSL_sk_free(ossl_check_X509_sk_type(sk))
0086 #define sk_X509_zero(sk) OPENSSL_sk_zero(ossl_check_X509_sk_type(sk))
0087 #define sk_X509_delete(sk, i) ((X509 *)OPENSSL_sk_delete(ossl_check_X509_sk_type(sk), (i)))
0088 #define sk_X509_delete_ptr(sk, ptr) ((X509 *)OPENSSL_sk_delete_ptr(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)))
0089 #define sk_X509_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
0090 #define sk_X509_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
0091 #define sk_X509_pop(sk) ((X509 *)OPENSSL_sk_pop(ossl_check_X509_sk_type(sk)))
0092 #define sk_X509_shift(sk) ((X509 *)OPENSSL_sk_shift(ossl_check_X509_sk_type(sk)))
0093 #define sk_X509_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_sk_type(sk),ossl_check_X509_freefunc_type(freefunc))
0094 #define sk_X509_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), (idx))
0095 #define sk_X509_set(sk, idx, ptr) ((X509 *)OPENSSL_sk_set(ossl_check_X509_sk_type(sk), (idx), ossl_check_X509_type(ptr)))
0096 #define sk_X509_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
0097 #define sk_X509_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))
0098 #define sk_X509_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), pnum)
0099 #define sk_X509_sort(sk) OPENSSL_sk_sort(ossl_check_X509_sk_type(sk))
0100 #define sk_X509_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_sk_type(sk))
0101 #define sk_X509_dup(sk) ((STACK_OF(X509) *)OPENSSL_sk_dup(ossl_check_const_X509_sk_type(sk)))
0102 #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)))
0103 #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)))
0104 SKM_DEFINE_STACK_OF_INTERNAL(X509_REVOKED, X509_REVOKED, X509_REVOKED)
0105 #define sk_X509_REVOKED_num(sk) OPENSSL_sk_num(ossl_check_const_X509_REVOKED_sk_type(sk))
0106 #define sk_X509_REVOKED_value(sk, idx) ((X509_REVOKED *)OPENSSL_sk_value(ossl_check_const_X509_REVOKED_sk_type(sk), (idx)))
0107 #define sk_X509_REVOKED_new(cmp) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new(ossl_check_X509_REVOKED_compfunc_type(cmp)))
0108 #define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_null())
0109 #define sk_X509_REVOKED_new_reserve(cmp, n) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_reserve(ossl_check_X509_REVOKED_compfunc_type(cmp), (n)))
0110 #define sk_X509_REVOKED_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_REVOKED_sk_type(sk), (n))
0111 #define sk_X509_REVOKED_free(sk) OPENSSL_sk_free(ossl_check_X509_REVOKED_sk_type(sk))
0112 #define sk_X509_REVOKED_zero(sk) OPENSSL_sk_zero(ossl_check_X509_REVOKED_sk_type(sk))
0113 #define sk_X509_REVOKED_delete(sk, i) ((X509_REVOKED *)OPENSSL_sk_delete(ossl_check_X509_REVOKED_sk_type(sk), (i)))
0114 #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)))
0115 #define sk_X509_REVOKED_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
0116 #define sk_X509_REVOKED_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
0117 #define sk_X509_REVOKED_pop(sk) ((X509_REVOKED *)OPENSSL_sk_pop(ossl_check_X509_REVOKED_sk_type(sk)))
0118 #define sk_X509_REVOKED_shift(sk) ((X509_REVOKED *)OPENSSL_sk_shift(ossl_check_X509_REVOKED_sk_type(sk)))
0119 #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))
0120 #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))
0121 #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)))
0122 #define sk_X509_REVOKED_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr))
0123 #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))
0124 #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)
0125 #define sk_X509_REVOKED_sort(sk) OPENSSL_sk_sort(ossl_check_X509_REVOKED_sk_type(sk))
0126 #define sk_X509_REVOKED_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_REVOKED_sk_type(sk))
0127 #define sk_X509_REVOKED_dup(sk) ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_dup(ossl_check_const_X509_REVOKED_sk_type(sk)))
0128 #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)))
0129 #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)))
0130 SKM_DEFINE_STACK_OF_INTERNAL(X509_CRL, X509_CRL, X509_CRL)
0131 #define sk_X509_CRL_num(sk) OPENSSL_sk_num(ossl_check_const_X509_CRL_sk_type(sk))
0132 #define sk_X509_CRL_value(sk, idx) ((X509_CRL *)OPENSSL_sk_value(ossl_check_const_X509_CRL_sk_type(sk), (idx)))
0133 #define sk_X509_CRL_new(cmp) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new(ossl_check_X509_CRL_compfunc_type(cmp)))
0134 #define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_null())
0135 #define sk_X509_CRL_new_reserve(cmp, n) ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_reserve(ossl_check_X509_CRL_compfunc_type(cmp), (n)))
0136 #define sk_X509_CRL_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_CRL_sk_type(sk), (n))
0137 #define sk_X509_CRL_free(sk) OPENSSL_sk_free(ossl_check_X509_CRL_sk_type(sk))
0138 #define sk_X509_CRL_zero(sk) OPENSSL_sk_zero(ossl_check_X509_CRL_sk_type(sk))
0139 #define sk_X509_CRL_delete(sk, i) ((X509_CRL *)OPENSSL_sk_delete(ossl_check_X509_CRL_sk_type(sk), (i)))
0140 #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)))
0141 #define sk_X509_CRL_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
0142 #define sk_X509_CRL_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
0143 #define sk_X509_CRL_pop(sk) ((X509_CRL *)OPENSSL_sk_pop(ossl_check_X509_CRL_sk_type(sk)))
0144 #define sk_X509_CRL_shift(sk) ((X509_CRL *)OPENSSL_sk_shift(ossl_check_X509_CRL_sk_type(sk)))
0145 #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))
0146 #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))
0147 #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)))
0148 #define sk_X509_CRL_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr))
0149 #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))
0150 #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)
0151 #define sk_X509_CRL_sort(sk) OPENSSL_sk_sort(ossl_check_X509_CRL_sk_type(sk))
0152 #define sk_X509_CRL_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_CRL_sk_type(sk))
0153 #define sk_X509_CRL_dup(sk) ((STACK_OF(X509_CRL) *)OPENSSL_sk_dup(ossl_check_const_X509_CRL_sk_type(sk)))
0154 #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)))
0155 #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)))
0156 
0157 
0158 /* Flags for X509_get_signature_info() */
0159 /* Signature info is valid */
0160 # define X509_SIG_INFO_VALID     0x1
0161 /* Signature is suitable for TLS use */
0162 # define X509_SIG_INFO_TLS       0x2
0163 
0164 # define X509_FILETYPE_PEM       1
0165 # define X509_FILETYPE_ASN1      2
0166 # define X509_FILETYPE_DEFAULT   3
0167 
0168 /*-
0169  * <https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3>:
0170  * The KeyUsage BITSTRING is treated as a little-endian integer, hence bit `0`
0171  * is 0x80, while bit `7` is 0x01 (the LSB of the integer value), bit `8` is
0172  * then the MSB of the second octet, or 0x8000.
0173  */
0174 # define X509v3_KU_DIGITAL_SIGNATURE     0x0080     /* (0) */
0175 # define X509v3_KU_NON_REPUDIATION       0x0040     /* (1) */
0176 # define X509v3_KU_KEY_ENCIPHERMENT      0x0020     /* (2) */
0177 # define X509v3_KU_DATA_ENCIPHERMENT     0x0010     /* (3) */
0178 # define X509v3_KU_KEY_AGREEMENT         0x0008     /* (4) */
0179 # define X509v3_KU_KEY_CERT_SIGN         0x0004     /* (5) */
0180 # define X509v3_KU_CRL_SIGN              0x0002     /* (6) */
0181 # define X509v3_KU_ENCIPHER_ONLY         0x0001     /* (7) */
0182 # define X509v3_KU_DECIPHER_ONLY         0x8000     /* (8) */
0183 # ifndef OPENSSL_NO_DEPRECATED_3_4
0184 #  define X509v3_KU_UNDEF                0xffff     /* vestigial, not used */
0185 # endif
0186 
0187 struct X509_algor_st {
0188     ASN1_OBJECT *algorithm;
0189     ASN1_TYPE *parameter;
0190 } /* X509_ALGOR */ ;
0191 
0192 typedef STACK_OF(X509_ALGOR) X509_ALGORS;
0193 
0194 typedef struct X509_val_st {
0195     ASN1_TIME *notBefore;
0196     ASN1_TIME *notAfter;
0197 } X509_VAL;
0198 
0199 typedef struct X509_sig_st X509_SIG;
0200 
0201 typedef struct X509_name_entry_st X509_NAME_ENTRY;
0202 
0203 SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME_ENTRY, X509_NAME_ENTRY, X509_NAME_ENTRY)
0204 #define sk_X509_NAME_ENTRY_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))
0205 #define sk_X509_NAME_ENTRY_value(sk, idx) ((X509_NAME_ENTRY *)OPENSSL_sk_value(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), (idx)))
0206 #define sk_X509_NAME_ENTRY_new(cmp) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp)))
0207 #define sk_X509_NAME_ENTRY_new_null() ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_null())
0208 #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)))
0209 #define sk_X509_NAME_ENTRY_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_ENTRY_sk_type(sk), (n))
0210 #define sk_X509_NAME_ENTRY_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_ENTRY_sk_type(sk))
0211 #define sk_X509_NAME_ENTRY_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_ENTRY_sk_type(sk))
0212 #define sk_X509_NAME_ENTRY_delete(sk, i) ((X509_NAME_ENTRY *)OPENSSL_sk_delete(ossl_check_X509_NAME_ENTRY_sk_type(sk), (i)))
0213 #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)))
0214 #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))
0215 #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))
0216 #define sk_X509_NAME_ENTRY_pop(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_pop(ossl_check_X509_NAME_ENTRY_sk_type(sk)))
0217 #define sk_X509_NAME_ENTRY_shift(sk) ((X509_NAME_ENTRY *)OPENSSL_sk_shift(ossl_check_X509_NAME_ENTRY_sk_type(sk)))
0218 #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))
0219 #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))
0220 #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)))
0221 #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))
0222 #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))
0223 #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)
0224 #define sk_X509_NAME_ENTRY_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_ENTRY_sk_type(sk))
0225 #define sk_X509_NAME_ENTRY_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))
0226 #define sk_X509_NAME_ENTRY_dup(sk) ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)))
0227 #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)))
0228 #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)))
0229 
0230 
0231 # define X509_EX_V_NETSCAPE_HACK         0x8000
0232 # define X509_EX_V_INIT                  0x0001
0233 typedef struct X509_extension_st X509_EXTENSION;
0234 SKM_DEFINE_STACK_OF_INTERNAL(X509_EXTENSION, X509_EXTENSION, X509_EXTENSION)
0235 #define sk_X509_EXTENSION_num(sk) OPENSSL_sk_num(ossl_check_const_X509_EXTENSION_sk_type(sk))
0236 #define sk_X509_EXTENSION_value(sk, idx) ((X509_EXTENSION *)OPENSSL_sk_value(ossl_check_const_X509_EXTENSION_sk_type(sk), (idx)))
0237 #define sk_X509_EXTENSION_new(cmp) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new(ossl_check_X509_EXTENSION_compfunc_type(cmp)))
0238 #define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_null())
0239 #define sk_X509_EXTENSION_new_reserve(cmp, n) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_reserve(ossl_check_X509_EXTENSION_compfunc_type(cmp), (n)))
0240 #define sk_X509_EXTENSION_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_EXTENSION_sk_type(sk), (n))
0241 #define sk_X509_EXTENSION_free(sk) OPENSSL_sk_free(ossl_check_X509_EXTENSION_sk_type(sk))
0242 #define sk_X509_EXTENSION_zero(sk) OPENSSL_sk_zero(ossl_check_X509_EXTENSION_sk_type(sk))
0243 #define sk_X509_EXTENSION_delete(sk, i) ((X509_EXTENSION *)OPENSSL_sk_delete(ossl_check_X509_EXTENSION_sk_type(sk), (i)))
0244 #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)))
0245 #define sk_X509_EXTENSION_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
0246 #define sk_X509_EXTENSION_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
0247 #define sk_X509_EXTENSION_pop(sk) ((X509_EXTENSION *)OPENSSL_sk_pop(ossl_check_X509_EXTENSION_sk_type(sk)))
0248 #define sk_X509_EXTENSION_shift(sk) ((X509_EXTENSION *)OPENSSL_sk_shift(ossl_check_X509_EXTENSION_sk_type(sk)))
0249 #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))
0250 #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))
0251 #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)))
0252 #define sk_X509_EXTENSION_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr))
0253 #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))
0254 #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)
0255 #define sk_X509_EXTENSION_sort(sk) OPENSSL_sk_sort(ossl_check_X509_EXTENSION_sk_type(sk))
0256 #define sk_X509_EXTENSION_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_EXTENSION_sk_type(sk))
0257 #define sk_X509_EXTENSION_dup(sk) ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_dup(ossl_check_const_X509_EXTENSION_sk_type(sk)))
0258 #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)))
0259 #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)))
0260 
0261 typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
0262 typedef struct x509_attributes_st X509_ATTRIBUTE;
0263 SKM_DEFINE_STACK_OF_INTERNAL(X509_ATTRIBUTE, X509_ATTRIBUTE, X509_ATTRIBUTE)
0264 #define sk_X509_ATTRIBUTE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))
0265 #define sk_X509_ATTRIBUTE_value(sk, idx) ((X509_ATTRIBUTE *)OPENSSL_sk_value(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), (idx)))
0266 #define sk_X509_ATTRIBUTE_new(cmp) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp)))
0267 #define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_null())
0268 #define sk_X509_ATTRIBUTE_new_reserve(cmp, n) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_reserve(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp), (n)))
0269 #define sk_X509_ATTRIBUTE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ATTRIBUTE_sk_type(sk), (n))
0270 #define sk_X509_ATTRIBUTE_free(sk) OPENSSL_sk_free(ossl_check_X509_ATTRIBUTE_sk_type(sk))
0271 #define sk_X509_ATTRIBUTE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ATTRIBUTE_sk_type(sk))
0272 #define sk_X509_ATTRIBUTE_delete(sk, i) ((X509_ATTRIBUTE *)OPENSSL_sk_delete(ossl_check_X509_ATTRIBUTE_sk_type(sk), (i)))
0273 #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)))
0274 #define sk_X509_ATTRIBUTE_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
0275 #define sk_X509_ATTRIBUTE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
0276 #define sk_X509_ATTRIBUTE_pop(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_pop(ossl_check_X509_ATTRIBUTE_sk_type(sk)))
0277 #define sk_X509_ATTRIBUTE_shift(sk) ((X509_ATTRIBUTE *)OPENSSL_sk_shift(ossl_check_X509_ATTRIBUTE_sk_type(sk)))
0278 #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))
0279 #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))
0280 #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)))
0281 #define sk_X509_ATTRIBUTE_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr))
0282 #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))
0283 #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)
0284 #define sk_X509_ATTRIBUTE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ATTRIBUTE_sk_type(sk))
0285 #define sk_X509_ATTRIBUTE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))
0286 #define sk_X509_ATTRIBUTE_dup(sk) ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_dup(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)))
0287 #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)))
0288 #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)))
0289 
0290 typedef struct X509_req_info_st X509_REQ_INFO;
0291 typedef struct X509_req_st X509_REQ;
0292 typedef struct x509_cert_aux_st X509_CERT_AUX;
0293 typedef struct x509_cinf_st X509_CINF;
0294 
0295 /* Flags for X509_print_ex() */
0296 
0297 # define X509_FLAG_COMPAT                0
0298 # define X509_FLAG_NO_HEADER             1L
0299 # define X509_FLAG_NO_VERSION            (1L << 1)
0300 # define X509_FLAG_NO_SERIAL             (1L << 2)
0301 # define X509_FLAG_NO_SIGNAME            (1L << 3)
0302 # define X509_FLAG_NO_ISSUER             (1L << 4)
0303 # define X509_FLAG_NO_VALIDITY           (1L << 5)
0304 # define X509_FLAG_NO_SUBJECT            (1L << 6)
0305 # define X509_FLAG_NO_PUBKEY             (1L << 7)
0306 # define X509_FLAG_NO_EXTENSIONS         (1L << 8)
0307 # define X509_FLAG_NO_SIGDUMP            (1L << 9)
0308 # define X509_FLAG_NO_AUX                (1L << 10)
0309 # define X509_FLAG_NO_ATTRIBUTES         (1L << 11)
0310 # define X509_FLAG_NO_IDS                (1L << 12)
0311 # define X509_FLAG_EXTENSIONS_ONLY_KID   (1L << 13)
0312 
0313 /* Flags specific to X509_NAME_print_ex() */
0314 
0315 /* The field separator information */
0316 
0317 # define XN_FLAG_SEP_MASK        (0xf << 16)
0318 
0319 # define XN_FLAG_COMPAT          0/* Traditional; use old X509_NAME_print */
0320 # define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */
0321 # define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */
0322 # define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */
0323 # define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */
0324 
0325 # define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */
0326 
0327 /* How the field name is shown */
0328 
0329 # define XN_FLAG_FN_MASK         (0x3 << 21)
0330 
0331 # define XN_FLAG_FN_SN           0/* Object short name */
0332 # define XN_FLAG_FN_LN           (1 << 21)/* Object long name */
0333 # define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */
0334 # define XN_FLAG_FN_NONE         (3 << 21)/* No field names */
0335 
0336 # define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */
0337 
0338 /*
0339  * This determines if we dump fields we don't recognise: RFC2253 requires
0340  * this.
0341  */
0342 
0343 # define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
0344 
0345 # define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20
0346                                            * characters */
0347 
0348 /* Complete set of RFC2253 flags */
0349 
0350 # define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
0351                         XN_FLAG_SEP_COMMA_PLUS | \
0352                         XN_FLAG_DN_REV | \
0353                         XN_FLAG_FN_SN | \
0354                         XN_FLAG_DUMP_UNKNOWN_FIELDS)
0355 
0356 /* readable oneline form */
0357 
0358 # define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
0359                         ASN1_STRFLGS_ESC_QUOTE | \
0360                         XN_FLAG_SEP_CPLUS_SPC | \
0361                         XN_FLAG_SPC_EQ | \
0362                         XN_FLAG_FN_SN)
0363 
0364 /* readable multiline form */
0365 
0366 # define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
0367                         ASN1_STRFLGS_ESC_MSB | \
0368                         XN_FLAG_SEP_MULTILINE | \
0369                         XN_FLAG_SPC_EQ | \
0370                         XN_FLAG_FN_LN | \
0371                         XN_FLAG_FN_ALIGN)
0372 
0373 typedef struct X509_crl_info_st X509_CRL_INFO;
0374 
0375 typedef struct private_key_st {
0376     int version;
0377     /* The PKCS#8 data types */
0378     X509_ALGOR *enc_algor;
0379     ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
0380     /* When decrypted, the following will not be NULL */
0381     EVP_PKEY *dec_pkey;
0382     /* used to encrypt and decrypt */
0383     int key_length;
0384     char *key_data;
0385     int key_free;               /* true if we should auto free key_data */
0386     /* expanded version of 'enc_algor' */
0387     EVP_CIPHER_INFO cipher;
0388 } X509_PKEY;
0389 
0390 typedef struct X509_info_st {
0391     X509 *x509;
0392     X509_CRL *crl;
0393     X509_PKEY *x_pkey;
0394     EVP_CIPHER_INFO enc_cipher;
0395     int enc_len;
0396     char *enc_data;
0397 } X509_INFO;
0398 SKM_DEFINE_STACK_OF_INTERNAL(X509_INFO, X509_INFO, X509_INFO)
0399 #define sk_X509_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_X509_INFO_sk_type(sk))
0400 #define sk_X509_INFO_value(sk, idx) ((X509_INFO *)OPENSSL_sk_value(ossl_check_const_X509_INFO_sk_type(sk), (idx)))
0401 #define sk_X509_INFO_new(cmp) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new(ossl_check_X509_INFO_compfunc_type(cmp)))
0402 #define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_null())
0403 #define sk_X509_INFO_new_reserve(cmp, n) ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_reserve(ossl_check_X509_INFO_compfunc_type(cmp), (n)))
0404 #define sk_X509_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_INFO_sk_type(sk), (n))
0405 #define sk_X509_INFO_free(sk) OPENSSL_sk_free(ossl_check_X509_INFO_sk_type(sk))
0406 #define sk_X509_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_X509_INFO_sk_type(sk))
0407 #define sk_X509_INFO_delete(sk, i) ((X509_INFO *)OPENSSL_sk_delete(ossl_check_X509_INFO_sk_type(sk), (i)))
0408 #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)))
0409 #define sk_X509_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
0410 #define sk_X509_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
0411 #define sk_X509_INFO_pop(sk) ((X509_INFO *)OPENSSL_sk_pop(ossl_check_X509_INFO_sk_type(sk)))
0412 #define sk_X509_INFO_shift(sk) ((X509_INFO *)OPENSSL_sk_shift(ossl_check_X509_INFO_sk_type(sk)))
0413 #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))
0414 #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))
0415 #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)))
0416 #define sk_X509_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr))
0417 #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))
0418 #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)
0419 #define sk_X509_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_X509_INFO_sk_type(sk))
0420 #define sk_X509_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_INFO_sk_type(sk))
0421 #define sk_X509_INFO_dup(sk) ((STACK_OF(X509_INFO) *)OPENSSL_sk_dup(ossl_check_const_X509_INFO_sk_type(sk)))
0422 #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)))
0423 #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)))
0424 
0425 
0426 /*
0427  * The next 2 structures and their 8 routines are used to manipulate Netscape's
0428  * spki structures - useful if you are writing a CA web page
0429  */
0430 typedef struct Netscape_spkac_st {
0431     X509_PUBKEY *pubkey;
0432     ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */
0433 } NETSCAPE_SPKAC;
0434 
0435 typedef struct Netscape_spki_st {
0436     NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */
0437     X509_ALGOR sig_algor;
0438     ASN1_BIT_STRING *signature;
0439 } NETSCAPE_SPKI;
0440 
0441 /* Netscape certificate sequence structure */
0442 typedef struct Netscape_certificate_sequence {
0443     ASN1_OBJECT *type;
0444     STACK_OF(X509) *certs;
0445 } NETSCAPE_CERT_SEQUENCE;
0446 
0447 /*- Unused (and iv length is wrong)
0448 typedef struct CBCParameter_st
0449         {
0450         unsigned char iv[8];
0451         } CBC_PARAM;
0452 */
0453 
0454 /* Password based encryption structure */
0455 
0456 typedef struct PBEPARAM_st {
0457     ASN1_OCTET_STRING *salt;
0458     ASN1_INTEGER *iter;
0459 } PBEPARAM;
0460 
0461 /* Password based encryption V2 structures */
0462 
0463 typedef struct PBE2PARAM_st {
0464     X509_ALGOR *keyfunc;
0465     X509_ALGOR *encryption;
0466 } PBE2PARAM;
0467 
0468 typedef struct PBKDF2PARAM_st {
0469 /* Usually OCTET STRING but could be anything */
0470     ASN1_TYPE *salt;
0471     ASN1_INTEGER *iter;
0472     ASN1_INTEGER *keylength;
0473     X509_ALGOR *prf;
0474 } PBKDF2PARAM;
0475 
0476 typedef struct {
0477     X509_ALGOR *keyDerivationFunc;
0478     X509_ALGOR *messageAuthScheme;
0479 } PBMAC1PARAM;
0480 
0481 # ifndef OPENSSL_NO_SCRYPT
0482 typedef struct SCRYPT_PARAMS_st {
0483     ASN1_OCTET_STRING *salt;
0484     ASN1_INTEGER *costParameter;
0485     ASN1_INTEGER *blockSize;
0486     ASN1_INTEGER *parallelizationParameter;
0487     ASN1_INTEGER *keyLength;
0488 } SCRYPT_PARAMS;
0489 # endif
0490 
0491 #ifdef  __cplusplus
0492 }
0493 #endif
0494 
0495 # include <openssl/x509_vfy.h>
0496 # include <openssl/pkcs7.h>
0497 
0498 #ifdef  __cplusplus
0499 extern "C" {
0500 #endif
0501 
0502 # define X509_EXT_PACK_UNKNOWN   1
0503 # define X509_EXT_PACK_STRING    2
0504 
0505 # define         X509_extract_key(x)     X509_get_pubkey(x)/*****/
0506 # define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
0507 # define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))
0508 
0509 void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
0510 X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
0511                                      int (*crl_free) (X509_CRL *crl),
0512                                      int (*crl_lookup) (X509_CRL *crl,
0513                                                         X509_REVOKED **ret,
0514                                                         const
0515                                                         ASN1_INTEGER *serial,
0516                                                         const
0517                                                         X509_NAME *issuer),
0518                                      int (*crl_verify) (X509_CRL *crl,
0519                                                         EVP_PKEY *pk));
0520 void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
0521 
0522 void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
0523 void *X509_CRL_get_meth_data(X509_CRL *crl);
0524 
0525 const char *X509_verify_cert_error_string(long n);
0526 
0527 int X509_verify(X509 *a, EVP_PKEY *r);
0528 int X509_self_signed(X509 *cert, int verify_signature);
0529 
0530 int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *r, OSSL_LIB_CTX *libctx,
0531                        const char *propq);
0532 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
0533 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
0534 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
0535 
0536 NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);
0537 char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
0538 EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
0539 int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
0540 
0541 int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
0542 
0543 int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
0544 int X509_signature_print(BIO *bp, const X509_ALGOR *alg,
0545                          const ASN1_STRING *sig);
0546 
0547 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
0548 int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
0549 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
0550 int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
0551 int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
0552 int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
0553 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
0554 
0555 int X509_pubkey_digest(const X509 *data, const EVP_MD *type,
0556                        unsigned char *md, unsigned int *len);
0557 int X509_digest(const X509 *data, const EVP_MD *type,
0558                 unsigned char *md, unsigned int *len);
0559 ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert,
0560                                    EVP_MD **md_used, int *md_is_fallback);
0561 int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
0562                     unsigned char *md, unsigned int *len);
0563 int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,
0564                     unsigned char *md, unsigned int *len);
0565 int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,
0566                      unsigned char *md, unsigned int *len);
0567 
0568 X509 *X509_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);
0569 X509_CRL *X509_CRL_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);
0570 # ifndef OPENSSL_NO_DEPRECATED_3_0
0571 #  include <openssl/http.h> /* OSSL_HTTP_REQ_CTX_nbio_d2i */
0572 #  define X509_http_nbio(rctx, pcert) \
0573       OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcert, ASN1_ITEM_rptr(X509))
0574 #  define X509_CRL_http_nbio(rctx, pcrl) \
0575       OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcrl, ASN1_ITEM_rptr(X509_CRL))
0576 # endif
0577 
0578 # ifndef OPENSSL_NO_STDIO
0579 X509 *d2i_X509_fp(FILE *fp, X509 **x509);
0580 int i2d_X509_fp(FILE *fp, const X509 *x509);
0581 X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);
0582 int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl);
0583 X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);
0584 int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req);
0585 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0586 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);
0587 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa);
0588 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);
0589 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa);
0590 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);
0591 OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa);
0592 #  endif
0593 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0594 #   ifndef OPENSSL_NO_DSA
0595 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
0596 OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa);
0597 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
0598 OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa);
0599 #   endif
0600 #  endif
0601 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0602 #   ifndef OPENSSL_NO_EC
0603 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
0604 OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey);
0605 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
0606 OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey);
0607 #   endif /* OPENSSL_NO_EC */
0608 #  endif /* OPENSSL_NO_DEPRECATED_3_0 */
0609 X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);
0610 int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8);
0611 X509_PUBKEY *d2i_X509_PUBKEY_fp(FILE *fp, X509_PUBKEY **xpk);
0612 int i2d_X509_PUBKEY_fp(FILE *fp, const X509_PUBKEY *xpk);
0613 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
0614                                                 PKCS8_PRIV_KEY_INFO **p8inf);
0615 int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf);
0616 int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key);
0617 int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey);
0618 EVP_PKEY *d2i_PrivateKey_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
0619                                const char *propq);
0620 EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
0621 int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey);
0622 EVP_PKEY *d2i_PUBKEY_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
0623                            const char *propq);
0624 EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
0625 # endif
0626 
0627 X509 *d2i_X509_bio(BIO *bp, X509 **x509);
0628 int i2d_X509_bio(BIO *bp, const X509 *x509);
0629 X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);
0630 int i2d_X509_CRL_bio(BIO *bp, const X509_CRL *crl);
0631 X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);
0632 int i2d_X509_REQ_bio(BIO *bp, const X509_REQ *req);
0633 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0634 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);
0635 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_bio(BIO *bp, const RSA *rsa);
0636 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);
0637 OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_bio(BIO *bp, const RSA *rsa);
0638 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);
0639 OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa);
0640 #  endif
0641 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0642 #   ifndef OPENSSL_NO_DSA
0643 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
0644 OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa);
0645 OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
0646 OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa);
0647 #   endif
0648 #  endif
0649 
0650 #  ifndef OPENSSL_NO_DEPRECATED_3_0
0651 #   ifndef OPENSSL_NO_EC
0652 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
0653 OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *eckey);
0654 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
0655 OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey);
0656 #   endif /* OPENSSL_NO_EC */
0657 #  endif /* OPENSSL_NO_DEPRECATED_3_0 */
0658 
0659 X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);
0660 int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8);
0661 X509_PUBKEY *d2i_X509_PUBKEY_bio(BIO *bp, X509_PUBKEY **xpk);
0662 int i2d_X509_PUBKEY_bio(BIO *bp, const X509_PUBKEY *xpk);
0663 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
0664                                                  PKCS8_PRIV_KEY_INFO **p8inf);
0665 int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf);
0666 int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key);
0667 int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey);
0668 EVP_PKEY *d2i_PrivateKey_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
0669                                 const char *propq);
0670 EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
0671 int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey);
0672 EVP_PKEY *d2i_PUBKEY_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx,
0673                             const char *propq);
0674 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
0675 
0676 DECLARE_ASN1_DUP_FUNCTION(X509)
0677 DECLARE_ASN1_DUP_FUNCTION(X509_ALGOR)
0678 DECLARE_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
0679 DECLARE_ASN1_DUP_FUNCTION(X509_CRL)
0680 DECLARE_ASN1_DUP_FUNCTION(X509_EXTENSION)
0681 DECLARE_ASN1_DUP_FUNCTION(X509_PUBKEY)
0682 DECLARE_ASN1_DUP_FUNCTION(X509_REQ)
0683 DECLARE_ASN1_DUP_FUNCTION(X509_REVOKED)
0684 int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,
0685                     void *pval);
0686 void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
0687                      const void **ppval, const X509_ALGOR *algor);
0688 void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
0689 int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
0690 int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);
0691 
0692 DECLARE_ASN1_DUP_FUNCTION(X509_NAME)
0693 DECLARE_ASN1_DUP_FUNCTION(X509_NAME_ENTRY)
0694 
0695 int X509_cmp_time(const ASN1_TIME *s, time_t *t);
0696 int X509_cmp_current_time(const ASN1_TIME *s);
0697 int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm,
0698                        const ASN1_TIME *start, const ASN1_TIME *end);
0699 ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
0700 ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
0701                             int offset_day, long offset_sec, time_t *t);
0702 ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
0703 
0704 const char *X509_get_default_cert_area(void);
0705 const char *X509_get_default_cert_dir(void);
0706 const char *X509_get_default_cert_file(void);
0707 const char *X509_get_default_cert_dir_env(void);
0708 const char *X509_get_default_cert_file_env(void);
0709 const char *X509_get_default_private_dir(void);
0710 
0711 X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
0712 X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
0713 
0714 DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
0715 DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
0716 DECLARE_ASN1_FUNCTIONS(X509_VAL)
0717 
0718 DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
0719 
0720 X509_PUBKEY *X509_PUBKEY_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
0721 int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
0722 EVP_PKEY *X509_PUBKEY_get0(const X509_PUBKEY *key);
0723 EVP_PKEY *X509_PUBKEY_get(const X509_PUBKEY *key);
0724 int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);
0725 long X509_get_pathlen(X509 *x);
0726 DECLARE_ASN1_ENCODE_FUNCTIONS_only(EVP_PKEY, PUBKEY)
0727 EVP_PKEY *d2i_PUBKEY_ex(EVP_PKEY **a, const unsigned char **pp, long length,
0728                         OSSL_LIB_CTX *libctx, const char *propq);
0729 # ifndef OPENSSL_NO_DEPRECATED_3_0
0730 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,RSA, RSA_PUBKEY)
0731 # endif
0732 # ifndef OPENSSL_NO_DEPRECATED_3_0
0733 #  ifndef OPENSSL_NO_DSA
0734 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,DSA, DSA_PUBKEY)
0735 #  endif
0736 # endif
0737 # ifndef OPENSSL_NO_DEPRECATED_3_0
0738 #  ifndef OPENSSL_NO_EC
0739 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, EC_KEY, EC_PUBKEY)
0740 #  endif
0741 # endif
0742 
0743 DECLARE_ASN1_FUNCTIONS(X509_SIG)
0744 void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,
0745                    const ASN1_OCTET_STRING **pdigest);
0746 void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,
0747                    ASN1_OCTET_STRING **pdigest);
0748 
0749 DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
0750 DECLARE_ASN1_FUNCTIONS(X509_REQ)
0751 X509_REQ *X509_REQ_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
0752 
0753 DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
0754 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
0755 
0756 DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
0757 DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)
0758 
0759 DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
0760 
0761 DECLARE_ASN1_FUNCTIONS(X509_NAME)
0762 
0763 int X509_NAME_set(X509_NAME **xn, const X509_NAME *name);
0764 
0765 DECLARE_ASN1_FUNCTIONS(X509_CINF)
0766 DECLARE_ASN1_FUNCTIONS(X509)
0767 X509 *X509_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
0768 DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
0769 
0770 #define X509_get_ex_new_index(l, p, newf, dupf, freef) \
0771     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)
0772 int X509_set_ex_data(X509 *r, int idx, void *arg);
0773 void *X509_get_ex_data(const X509 *r, int idx);
0774 DECLARE_ASN1_ENCODE_FUNCTIONS_only(X509,X509_AUX)
0775 
0776 int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
0777 
0778 int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,
0779                       int *secbits, uint32_t *flags);
0780 void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,
0781                        int secbits, uint32_t flags);
0782 
0783 int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits,
0784                             uint32_t *flags);
0785 
0786 void X509_get0_signature(const ASN1_BIT_STRING **psig,
0787                          const X509_ALGOR **palg, const X509 *x);
0788 int X509_get_signature_nid(const X509 *x);
0789 
0790 void X509_set0_distinguishing_id(X509 *x, ASN1_OCTET_STRING *d_id);
0791 ASN1_OCTET_STRING *X509_get0_distinguishing_id(X509 *x);
0792 void X509_REQ_set0_distinguishing_id(X509_REQ *x, ASN1_OCTET_STRING *d_id);
0793 ASN1_OCTET_STRING *X509_REQ_get0_distinguishing_id(X509_REQ *x);
0794 
0795 int X509_alias_set1(X509 *x, const unsigned char *name, int len);
0796 int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
0797 unsigned char *X509_alias_get0(X509 *x, int *len);
0798 unsigned char *X509_keyid_get0(X509 *x, int *len);
0799 
0800 DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
0801 DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
0802 DECLARE_ASN1_FUNCTIONS(X509_CRL)
0803 X509_CRL *X509_CRL_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
0804 
0805 int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
0806 int X509_CRL_get0_by_serial(X509_CRL *crl,
0807                             X509_REVOKED **ret, const ASN1_INTEGER *serial);
0808 int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
0809 
0810 X509_PKEY *X509_PKEY_new(void);
0811 void X509_PKEY_free(X509_PKEY *a);
0812 
0813 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
0814 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
0815 DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
0816 
0817 X509_INFO *X509_INFO_new(void);
0818 void X509_INFO_free(X509_INFO *a);
0819 char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size);
0820 
0821 #ifndef OPENSSL_NO_DEPRECATED_3_0
0822 OSSL_DEPRECATEDIN_3_0
0823 int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
0824                 ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);
0825 OSSL_DEPRECATEDIN_3_0
0826 int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
0827                 unsigned char *md, unsigned int *len);
0828 OSSL_DEPRECATEDIN_3_0
0829 int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
0830               ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey,
0831               const EVP_MD *type);
0832 #endif
0833 int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,
0834                      unsigned char *md, unsigned int *len);
0835 int ASN1_item_verify(const ASN1_ITEM *it, const X509_ALGOR *alg,
0836                      const ASN1_BIT_STRING *signature, const void *data,
0837                      EVP_PKEY *pkey);
0838 int ASN1_item_verify_ctx(const ASN1_ITEM *it, const X509_ALGOR *alg,
0839                          const ASN1_BIT_STRING *signature, const void *data,
0840                          EVP_MD_CTX *ctx);
0841 int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
0842                    ASN1_BIT_STRING *signature, const void *data,
0843                    EVP_PKEY *pkey, const EVP_MD *md);
0844 int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
0845                        X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
0846                        const void *data, EVP_MD_CTX *ctx);
0847 
0848 #define X509_VERSION_1 0
0849 #define X509_VERSION_2 1
0850 #define X509_VERSION_3 2
0851 
0852 long X509_get_version(const X509 *x);
0853 int X509_set_version(X509 *x, long version);
0854 int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
0855 ASN1_INTEGER *X509_get_serialNumber(X509 *x);
0856 const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);
0857 int X509_set_issuer_name(X509 *x, const X509_NAME *name);
0858 X509_NAME *X509_get_issuer_name(const X509 *a);
0859 int X509_set_subject_name(X509 *x, const X509_NAME *name);
0860 X509_NAME *X509_get_subject_name(const X509 *a);
0861 const ASN1_TIME * X509_get0_notBefore(const X509 *x);
0862 ASN1_TIME *X509_getm_notBefore(const X509 *x);
0863 int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);
0864 const ASN1_TIME *X509_get0_notAfter(const X509 *x);
0865 ASN1_TIME *X509_getm_notAfter(const X509 *x);
0866 int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);
0867 int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
0868 int X509_up_ref(X509 *x);
0869 int X509_get_signature_type(const X509 *x);
0870 
0871 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0872 #  define X509_get_notBefore X509_getm_notBefore
0873 #  define X509_get_notAfter X509_getm_notAfter
0874 #  define X509_set_notBefore X509_set1_notBefore
0875 #  define X509_set_notAfter X509_set1_notAfter
0876 #endif
0877 
0878 
0879 /*
0880  * This one is only used so that a binary form can output, as in
0881  * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf)
0882  */
0883 X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
0884 const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
0885 void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,
0886                     const ASN1_BIT_STRING **psuid);
0887 const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
0888 
0889 EVP_PKEY *X509_get0_pubkey(const X509 *x);
0890 EVP_PKEY *X509_get_pubkey(X509 *x);
0891 ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
0892 
0893 #define X509_REQ_VERSION_1 0
0894 
0895 long X509_REQ_get_version(const X509_REQ *req);
0896 int X509_REQ_set_version(X509_REQ *x, long version);
0897 X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
0898 int X509_REQ_set_subject_name(X509_REQ *req, const X509_NAME *name);
0899 void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
0900                              const X509_ALGOR **palg);
0901 void X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig);
0902 int X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg);
0903 int X509_REQ_get_signature_nid(const X509_REQ *req);
0904 int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
0905 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
0906 EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
0907 EVP_PKEY *X509_REQ_get0_pubkey(const X509_REQ *req);
0908 X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);
0909 int X509_REQ_extension_nid(int nid);
0910 int *X509_REQ_get_extension_nids(void);
0911 void X509_REQ_set_extension_nids(int *nids);
0912 STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(OSSL_FUTURE_CONST X509_REQ *req);
0913 int X509_REQ_add_extensions_nid(X509_REQ *req,
0914                                 const STACK_OF(X509_EXTENSION) *exts, int nid);
0915 int X509_REQ_add_extensions(X509_REQ *req, const STACK_OF(X509_EXTENSION) *ext);
0916 int X509_REQ_get_attr_count(const X509_REQ *req);
0917 int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
0918 int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
0919                              int lastpos);
0920 X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
0921 X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
0922 int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
0923 int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
0924                               const ASN1_OBJECT *obj, int type,
0925                               const unsigned char *bytes, int len);
0926 int X509_REQ_add1_attr_by_NID(X509_REQ *req,
0927                               int nid, int type,
0928                               const unsigned char *bytes, int len);
0929 int X509_REQ_add1_attr_by_txt(X509_REQ *req,
0930                               const char *attrname, int type,
0931                               const unsigned char *bytes, int len);
0932 
0933 #define X509_CRL_VERSION_1 0
0934 #define X509_CRL_VERSION_2 1
0935 
0936 int X509_CRL_set_version(X509_CRL *x, long version);
0937 int X509_CRL_set_issuer_name(X509_CRL *x, const X509_NAME *name);
0938 int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
0939 int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
0940 int X509_CRL_sort(X509_CRL *crl);
0941 int X509_CRL_up_ref(X509_CRL *crl);
0942 
0943 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0944 #  define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate
0945 #  define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate
0946 #endif
0947 
0948 long X509_CRL_get_version(const X509_CRL *crl);
0949 const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);
0950 const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);
0951 #ifndef OPENSSL_NO_DEPRECATED_1_1_0
0952 OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl);
0953 OSSL_DEPRECATEDIN_1_1_0 ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
0954 #endif
0955 X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
0956 const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
0957 STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
0958 void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
0959                              const X509_ALGOR **palg);
0960 int X509_CRL_get_signature_nid(const X509_CRL *crl);
0961 int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
0962 
0963 const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);
0964 int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
0965 const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);
0966 int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
0967 const STACK_OF(X509_EXTENSION) *
0968 X509_REVOKED_get0_extensions(const X509_REVOKED *r);
0969 
0970 X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
0971                         EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);
0972 
0973 int X509_REQ_check_private_key(const X509_REQ *req, EVP_PKEY *pkey);
0974 
0975 int X509_check_private_key(const X509 *cert, const EVP_PKEY *pkey);
0976 int X509_chain_check_suiteb(int *perror_depth,
0977                             X509 *x, STACK_OF(X509) *chain,
0978                             unsigned long flags);
0979 int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);
0980 void OSSL_STACK_OF_X509_free(STACK_OF(X509) *certs);
0981 STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
0982 
0983 int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
0984 unsigned long X509_issuer_and_serial_hash(X509 *a);
0985 
0986 int X509_issuer_name_cmp(const X509 *a, const X509 *b);
0987 unsigned long X509_issuer_name_hash(X509 *a);
0988 
0989 int X509_subject_name_cmp(const X509 *a, const X509 *b);
0990 unsigned long X509_subject_name_hash(X509 *x);
0991 
0992 # ifndef OPENSSL_NO_MD5
0993 unsigned long X509_issuer_name_hash_old(X509 *a);
0994 unsigned long X509_subject_name_hash_old(X509 *x);
0995 # endif
0996 
0997 # define X509_ADD_FLAG_DEFAULT  0
0998 # define X509_ADD_FLAG_UP_REF   0x1
0999 # define X509_ADD_FLAG_PREPEND  0x2
1000 # define X509_ADD_FLAG_NO_DUP   0x4
1001 # define X509_ADD_FLAG_NO_SS    0x8
1002 int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags);
1003 int X509_add_certs(STACK_OF(X509) *sk, STACK_OF(X509) *certs, int flags);
1004 
1005 int X509_cmp(const X509 *a, const X509 *b);
1006 int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
1007 #ifndef OPENSSL_NO_DEPRECATED_3_0
1008 # define X509_NAME_hash(x) X509_NAME_hash_ex(x, NULL, NULL, NULL)
1009 OSSL_DEPRECATEDIN_3_0 int X509_certificate_type(const X509 *x,
1010                                                 const EVP_PKEY *pubkey);
1011 #endif
1012 unsigned long X509_NAME_hash_ex(const X509_NAME *x, OSSL_LIB_CTX *libctx,
1013                                 const char *propq, int *ok);
1014 unsigned long X509_NAME_hash_old(const X509_NAME *x);
1015 
1016 int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
1017 int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
1018 int X509_aux_print(BIO *out, X509 *x, int indent);
1019 # ifndef OPENSSL_NO_STDIO
1020 int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,
1021                      unsigned long cflag);
1022 int X509_print_fp(FILE *bp, X509 *x);
1023 int X509_CRL_print_fp(FILE *bp, X509_CRL *x);
1024 int X509_REQ_print_fp(FILE *bp, X509_REQ *req);
1025 int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,
1026                           unsigned long flags);
1027 # endif
1028 
1029 int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);
1030 int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,
1031                        unsigned long flags);
1032 int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,
1033                   unsigned long cflag);
1034 int X509_print(BIO *bp, X509 *x);
1035 int X509_ocspid_print(BIO *bp, X509 *x);
1036 int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag);
1037 int X509_CRL_print(BIO *bp, X509_CRL *x);
1038 int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,
1039                       unsigned long cflag);
1040 int X509_REQ_print(BIO *bp, X509_REQ *req);
1041 
1042 int X509_NAME_entry_count(const X509_NAME *name);
1043 int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid,
1044                               char *buf, int len);
1045 int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
1046                               char *buf, int len);
1047 
1048 /*
1049  * NOTE: you should be passing -1, not 0 as lastpos. The functions that use
1050  * lastpos, search after that position on.
1051  */
1052 int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos);
1053 int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
1054                                int lastpos);
1055 X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
1056 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
1057 int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,
1058                         int loc, int set);
1059 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
1060                                const unsigned char *bytes, int len, int loc,
1061                                int set);
1062 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
1063                                const unsigned char *bytes, int len, int loc,
1064                                int set);
1065 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
1066                                                const char *field, int type,
1067                                                const unsigned char *bytes,
1068                                                int len);
1069 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
1070                                                int type,
1071                                                const unsigned char *bytes,
1072                                                int len);
1073 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
1074                                const unsigned char *bytes, int len, int loc,
1075                                int set);
1076 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
1077                                                const ASN1_OBJECT *obj, int type,
1078                                                const unsigned char *bytes,
1079                                                int len);
1080 int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj);
1081 int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
1082                              const unsigned char *bytes, int len);
1083 ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);
1084 ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);
1085 int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
1086 
1087 int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder,
1088                        size_t *pderlen);
1089 
1090 int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
1091 int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
1092                           int nid, int lastpos);
1093 int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
1094                           const ASN1_OBJECT *obj, int lastpos);
1095 int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
1096                                int crit, int lastpos);
1097 X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
1098 X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
1099 STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
1100                                          X509_EXTENSION *ex, int loc);
1101 STACK_OF(X509_EXTENSION)
1102     *X509v3_add_extensions(STACK_OF(X509_EXTENSION) **target,
1103                            const STACK_OF(X509_EXTENSION) *exts);
1104 
1105 int X509_get_ext_count(const X509 *x);
1106 int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);
1107 int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos);
1108 int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);
1109 X509_EXTENSION *X509_get_ext(const X509 *x, int loc);
1110 X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
1111 int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
1112 void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
1113 int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
1114                       unsigned long flags);
1115 
1116 int X509_CRL_get_ext_count(const X509_CRL *x);
1117 int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);
1118 int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
1119                             int lastpos);
1120 int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos);
1121 X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
1122 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
1123 int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
1124 void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);
1125 int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
1126                           unsigned long flags);
1127 
1128 int X509_REVOKED_get_ext_count(const X509_REVOKED *x);
1129 int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos);
1130 int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
1131                                 int lastpos);
1132 int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
1133                                      int lastpos);
1134 X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);
1135 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
1136 int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
1137 void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit,
1138                                int *idx);
1139 int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
1140                               unsigned long flags);
1141 
1142 X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
1143                                              int nid, int crit,
1144                                              ASN1_OCTET_STRING *data);
1145 X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
1146                                              const ASN1_OBJECT *obj, int crit,
1147                                              ASN1_OCTET_STRING *data);
1148 int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);
1149 int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
1150 int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);
1151 ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);
1152 ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
1153 int X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
1154 
1155 int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
1156 int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
1157                            int lastpos);
1158 int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
1159                            const ASN1_OBJECT *obj, int lastpos);
1160 X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
1161 X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1162 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1163                                            X509_ATTRIBUTE *attr);
1164 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
1165                                                   **x, const ASN1_OBJECT *obj,
1166                                                   int type,
1167                                                   const unsigned char *bytes,
1168                                                   int len);
1169 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)
1170                                                   **x, int nid, int type,
1171                                                   const unsigned char *bytes,
1172                                                   int len);
1173 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)
1174                                                   **x, const char *attrname,
1175                                                   int type,
1176                                                   const unsigned char *bytes,
1177                                                   int len);
1178 void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x,
1179                               const ASN1_OBJECT *obj, int lastpos, int type);
1180 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1181                                              int atrtype, const void *data,
1182                                              int len);
1183 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1184                                              const ASN1_OBJECT *obj,
1185                                              int atrtype, const void *data,
1186                                              int len);
1187 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1188                                              const char *atrname, int type,
1189                                              const unsigned char *bytes,
1190                                              int len);
1191 int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
1192 int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
1193                              const void *data, int len);
1194 void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,
1195                                void *data);
1196 int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
1197 ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1198 ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
1199 
1200 int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
1201 int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
1202 int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
1203                              int lastpos);
1204 X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
1205 X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
1206 int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
1207 int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
1208                               const ASN1_OBJECT *obj, int type,
1209                               const unsigned char *bytes, int len);
1210 int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
1211                               int nid, int type,
1212                               const unsigned char *bytes, int len);
1213 int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
1214                               const char *attrname, int type,
1215                               const unsigned char *bytes, int len);
1216 
1217 /* lookup a cert from a X509 STACK */
1218 X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, const X509_NAME *name,
1219                                      const ASN1_INTEGER *serial);
1220 X509 *X509_find_by_subject(STACK_OF(X509) *sk, const X509_NAME *name);
1221 
1222 DECLARE_ASN1_FUNCTIONS(PBEPARAM)
1223 DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
1224 DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
1225 DECLARE_ASN1_FUNCTIONS(PBMAC1PARAM)
1226 # ifndef OPENSSL_NO_SCRYPT
1227 DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS)
1228 # endif
1229 
1230 int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
1231                          const unsigned char *salt, int saltlen);
1232 int PKCS5_pbe_set0_algor_ex(X509_ALGOR *algor, int alg, int iter,
1233                             const unsigned char *salt, int saltlen,
1234                             OSSL_LIB_CTX *libctx);
1235 
1236 X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
1237                           const unsigned char *salt, int saltlen);
1238 X509_ALGOR *PKCS5_pbe_set_ex(int alg, int iter,
1239                              const unsigned char *salt, int saltlen,
1240                              OSSL_LIB_CTX *libctx);
1241 
1242 X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
1243                            unsigned char *salt, int saltlen);
1244 X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
1245                               unsigned char *salt, int saltlen,
1246                               unsigned char *aiv, int prf_nid);
1247 X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter,
1248                                  unsigned char *salt, int saltlen,
1249                                  unsigned char *aiv, int prf_nid,
1250                                  OSSL_LIB_CTX *libctx);
1251 
1252 #ifndef OPENSSL_NO_SCRYPT
1253 X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,
1254                                   const unsigned char *salt, int saltlen,
1255                                   unsigned char *aiv, uint64_t N, uint64_t r,
1256                                   uint64_t p);
1257 #endif
1258 
1259 X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
1260                              int prf_nid, int keylen);
1261 X509_ALGOR *PKCS5_pbkdf2_set_ex(int iter, unsigned char *salt, int saltlen,
1262                                 int prf_nid, int keylen,
1263                                 OSSL_LIB_CTX *libctx);
1264 
1265 PBKDF2PARAM *PBMAC1_get1_pbkdf2_param(const X509_ALGOR *macalg);
1266 /* PKCS#8 utilities */
1267 
1268 DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
1269 
1270 EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);
1271 EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
1272                             const char *propq);
1273 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey);
1274 
1275 int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
1276                     int version, int ptype, void *pval,
1277                     unsigned char *penc, int penclen);
1278 int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,
1279                     const unsigned char **pk, int *ppklen,
1280                     const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);
1281 
1282 const STACK_OF(X509_ATTRIBUTE) *
1283 PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);
1284 int PKCS8_pkey_add1_attr(PKCS8_PRIV_KEY_INFO *p8, X509_ATTRIBUTE *attr);
1285 int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,
1286                                 const unsigned char *bytes, int len);
1287 int PKCS8_pkey_add1_attr_by_OBJ(PKCS8_PRIV_KEY_INFO *p8, const ASN1_OBJECT *obj,
1288                                 int type, const unsigned char *bytes, int len);
1289 
1290 
1291 void X509_PUBKEY_set0_public_key(X509_PUBKEY *pub,
1292                                  unsigned char *penc, int penclen);
1293 int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
1294                            int ptype, void *pval,
1295                            unsigned char *penc, int penclen);
1296 int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
1297                            const unsigned char **pk, int *ppklen,
1298                            X509_ALGOR **pa, const X509_PUBKEY *pub);
1299 int X509_PUBKEY_eq(const X509_PUBKEY *a, const X509_PUBKEY *b);
1300 
1301 # ifdef  __cplusplus
1302 }
1303 # endif
1304 #endif