VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/include/crypto/x509.h@ 100966

最後變更 在這個檔案從100966是 97984,由 vboxsync 提交於 2 年 前

libs/openssl-3.0.7: Shut up pragma once warnings for internal headers. Added sed script for doing that. bugref:10317

檔案大小: 13.1 KB
 
1/*
2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_CRYPTO_X509_H
11# define OSSL_CRYPTO_X509_H
12# ifndef RT_WITHOUT_PRAGMA_ONCE /* VBOX */
13# pragma once
14# endif /* VBOX */
15
16# include "internal/refcount.h"
17# include <openssl/asn1.h>
18# include <openssl/x509.h>
19# include <openssl/conf.h>
20# include "crypto/types.h"
21
22/* Internal X509 structures and functions: not for application use */
23
24/* Note: unless otherwise stated a field pointer is mandatory and should
25 * never be set to NULL: the ASN.1 code and accessors rely on mandatory
26 * fields never being NULL.
27 */
28
29/*
30 * name entry structure, equivalent to AttributeTypeAndValue defined
31 * in RFC5280 et al.
32 */
33struct X509_name_entry_st {
34 ASN1_OBJECT *object; /* AttributeType */
35 ASN1_STRING *value; /* AttributeValue */
36 int set; /* index of RDNSequence for this entry */
37 int size; /* temp variable */
38};
39
40/* Name from RFC 5280. */
41struct X509_name_st {
42 STACK_OF(X509_NAME_ENTRY) *entries; /* DN components */
43 int modified; /* true if 'bytes' needs to be built */
44 BUF_MEM *bytes; /* cached encoding: cannot be NULL */
45 /* canonical encoding used for rapid Name comparison */
46 unsigned char *canon_enc;
47 int canon_enclen;
48} /* X509_NAME */ ;
49
50/* Signature info structure */
51
52struct x509_sig_info_st {
53 /* NID of message digest */
54 int mdnid;
55 /* NID of public key algorithm */
56 int pknid;
57 /* Security bits */
58 int secbits;
59 /* Various flags */
60 uint32_t flags;
61};
62
63/* PKCS#10 certificate request */
64
65struct X509_req_info_st {
66 ASN1_ENCODING enc; /* cached encoding of signed part */
67 ASN1_INTEGER *version; /* version, defaults to v1(0) so can be NULL */
68 X509_NAME *subject; /* certificate request DN */
69 X509_PUBKEY *pubkey; /* public key of request */
70 /*
71 * Zero or more attributes.
72 * NB: although attributes is a mandatory field some broken
73 * encodings omit it so this may be NULL in that case.
74 */
75 STACK_OF(X509_ATTRIBUTE) *attributes;
76};
77
78struct X509_req_st {
79 X509_REQ_INFO req_info; /* signed certificate request data */
80 X509_ALGOR sig_alg; /* signature algorithm */
81 ASN1_BIT_STRING *signature; /* signature */
82 CRYPTO_REF_COUNT references;
83 CRYPTO_RWLOCK *lock;
84
85 /* Set on live certificates for authentication purposes */
86 ASN1_OCTET_STRING *distinguishing_id;
87 OSSL_LIB_CTX *libctx;
88 char *propq;
89};
90
91struct X509_crl_info_st {
92 ASN1_INTEGER *version; /* version: defaults to v1(0) so may be NULL */
93 X509_ALGOR sig_alg; /* signature algorithm */
94 X509_NAME *issuer; /* CRL issuer name */
95 ASN1_TIME *lastUpdate; /* lastUpdate field */
96 ASN1_TIME *nextUpdate; /* nextUpdate field: optional */
97 STACK_OF(X509_REVOKED) *revoked; /* revoked entries: optional */
98 STACK_OF(X509_EXTENSION) *extensions; /* extensions: optional */
99 ASN1_ENCODING enc; /* encoding of signed portion of CRL */
100};
101
102struct X509_crl_st {
103 X509_CRL_INFO crl; /* signed CRL data */
104 X509_ALGOR sig_alg; /* CRL signature algorithm */
105 ASN1_BIT_STRING signature; /* CRL signature */
106 CRYPTO_REF_COUNT references;
107 int flags;
108 /*
109 * Cached copies of decoded extension values, since extensions
110 * are optional any of these can be NULL.
111 */
112 AUTHORITY_KEYID *akid;
113 ISSUING_DIST_POINT *idp;
114 /* Convenient breakdown of IDP */
115 int idp_flags;
116 int idp_reasons;
117 /* CRL and base CRL numbers for delta processing */
118 ASN1_INTEGER *crl_number;
119 ASN1_INTEGER *base_crl_number;
120 STACK_OF(GENERAL_NAMES) *issuers;
121 /* hash of CRL */
122 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
123 /* alternative method to handle this CRL */
124 const X509_CRL_METHOD *meth;
125 void *meth_data;
126 CRYPTO_RWLOCK *lock;
127
128 OSSL_LIB_CTX *libctx;
129 char *propq;
130};
131
132struct x509_revoked_st {
133 ASN1_INTEGER serialNumber; /* revoked entry serial number */
134 ASN1_TIME *revocationDate; /* revocation date */
135 STACK_OF(X509_EXTENSION) *extensions; /* CRL entry extensions: optional */
136 /* decoded value of CRLissuer extension: set if indirect CRL */
137 STACK_OF(GENERAL_NAME) *issuer;
138 /* revocation reason: set to CRL_REASON_NONE if reason extension absent */
139 int reason;
140 /*
141 * CRL entries are reordered for faster lookup of serial numbers. This
142 * field contains the original load sequence for this entry.
143 */
144 int sequence;
145};
146
147/*
148 * This stuff is certificate "auxiliary info": it contains details which are
149 * useful in certificate stores and databases. When used this is tagged onto
150 * the end of the certificate itself. OpenSSL specific structure not defined
151 * in any RFC.
152 */
153
154struct x509_cert_aux_st {
155 STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */
156 STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */
157 ASN1_UTF8STRING *alias; /* "friendly name" */
158 ASN1_OCTET_STRING *keyid; /* key id of private key */
159 STACK_OF(X509_ALGOR) *other; /* other unspecified info */
160};
161
162struct x509_cinf_st {
163 ASN1_INTEGER *version; /* [ 0 ] default of v1 */
164 ASN1_INTEGER serialNumber;
165 X509_ALGOR signature;
166 X509_NAME *issuer;
167 X509_VAL validity;
168 X509_NAME *subject;
169 X509_PUBKEY *key;
170 ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */
171 ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */
172 STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
173 ASN1_ENCODING enc;
174};
175
176struct x509_st {
177 X509_CINF cert_info;
178 X509_ALGOR sig_alg;
179 ASN1_BIT_STRING signature;
180 X509_SIG_INFO siginf;
181 CRYPTO_REF_COUNT references;
182 CRYPTO_EX_DATA ex_data;
183 /* These contain copies of various extension values */
184 long ex_pathlen;
185 long ex_pcpathlen;
186 uint32_t ex_flags;
187 uint32_t ex_kusage;
188 uint32_t ex_xkusage;
189 uint32_t ex_nscert;
190 ASN1_OCTET_STRING *skid;
191 AUTHORITY_KEYID *akid;
192 X509_POLICY_CACHE *policy_cache;
193 STACK_OF(DIST_POINT) *crldp;
194 STACK_OF(GENERAL_NAME) *altname;
195 NAME_CONSTRAINTS *nc;
196# ifndef OPENSSL_NO_RFC3779
197 STACK_OF(IPAddressFamily) *rfc3779_addr;
198 struct ASIdentifiers_st *rfc3779_asid;
199# endif
200 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
201 X509_CERT_AUX *aux;
202 CRYPTO_RWLOCK *lock;
203 volatile int ex_cached;
204
205 /* Set on live certificates for authentication purposes */
206 ASN1_OCTET_STRING *distinguishing_id;
207
208 OSSL_LIB_CTX *libctx;
209 char *propq;
210} /* X509 */ ;
211
212/*
213 * This is a used when verifying cert chains. Since the gathering of the
214 * cert chain can take some time (and have to be 'retried', this needs to be
215 * kept and passed around.
216 */
217struct x509_store_ctx_st { /* X509_STORE_CTX */
218 X509_STORE *store;
219 /* The following are set by the caller */
220 /* The cert to check */
221 X509 *cert;
222 /* chain of X509s - untrusted - passed in */
223 STACK_OF(X509) *untrusted;
224 /* set of CRLs passed in */
225 STACK_OF(X509_CRL) *crls;
226 X509_VERIFY_PARAM *param;
227 /* Other info for use with get_issuer() */
228 void *other_ctx;
229 /* Callbacks for various operations */
230 /* called to verify a certificate */
231 int (*verify) (X509_STORE_CTX *ctx);
232 /* error callback */
233 int (*verify_cb) (int ok, X509_STORE_CTX *ctx);
234 /* get issuers cert from ctx */
235 int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
236 /* check issued */
237 int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
238 /* Check revocation status of chain */
239 int (*check_revocation) (X509_STORE_CTX *ctx);
240 /* retrieve CRL */
241 int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
242 /* Check CRL validity */
243 int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);
244 /* Check certificate against CRL */
245 int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
246 /* Check policy status of the chain */
247 int (*check_policy) (X509_STORE_CTX *ctx);
248 STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx,
249 const X509_NAME *nm);
250 /* cannot constify 'ctx' param due to lookup_certs_sk() in x509_vfy.c */
251 STACK_OF(X509_CRL) *(*lookup_crls) (const X509_STORE_CTX *ctx,
252 const X509_NAME *nm);
253 int (*cleanup) (X509_STORE_CTX *ctx);
254 /* The following is built up */
255 /* if 0, rebuild chain */
256 int valid;
257 /* number of untrusted certs */
258 int num_untrusted;
259 /* chain of X509s - built up and trusted */
260 STACK_OF(X509) *chain;
261 /* Valid policy tree */
262 X509_POLICY_TREE *tree;
263 /* Require explicit policy value */
264 int explicit_policy;
265 /* When something goes wrong, this is why */
266 int error_depth;
267 int error;
268 X509 *current_cert;
269 /* cert currently being tested as valid issuer */
270 X509 *current_issuer;
271 /* current CRL */
272 X509_CRL *current_crl;
273 /* score of current CRL */
274 int current_crl_score;
275 /* Reason mask */
276 unsigned int current_reasons;
277 /* For CRL path validation: parent context */
278 X509_STORE_CTX *parent;
279 CRYPTO_EX_DATA ex_data;
280 SSL_DANE *dane;
281 /* signed via bare TA public key, rather than CA certificate */
282 int bare_ta_signed;
283
284 OSSL_LIB_CTX *libctx;
285 char *propq;
286};
287
288/* PKCS#8 private key info structure */
289
290struct pkcs8_priv_key_info_st {
291 ASN1_INTEGER *version;
292 X509_ALGOR *pkeyalg;
293 ASN1_OCTET_STRING *pkey;
294 STACK_OF(X509_ATTRIBUTE) *attributes;
295};
296
297struct X509_sig_st {
298 X509_ALGOR *algor;
299 ASN1_OCTET_STRING *digest;
300};
301
302struct x509_object_st {
303 /* one of the above types */
304 X509_LOOKUP_TYPE type;
305 union {
306 char *ptr;
307 X509 *x509;
308 X509_CRL *crl;
309 EVP_PKEY *pkey;
310 } data;
311};
312
313int ossl_a2i_ipadd(unsigned char *ipout, const char *ipasc);
314int ossl_x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm);
315int ossl_x509_print_ex_brief(BIO *bio, X509 *cert, unsigned long neg_cflags);
316int ossl_x509v3_cache_extensions(X509 *x);
317int ossl_x509_init_sig_info(X509 *x);
318
319int ossl_x509_set0_libctx(X509 *x, OSSL_LIB_CTX *libctx, const char *propq);
320int ossl_x509_crl_set0_libctx(X509_CRL *x, OSSL_LIB_CTX *libctx,
321 const char *propq);
322int ossl_x509_req_set0_libctx(X509_REQ *x, OSSL_LIB_CTX *libctx,
323 const char *propq);
324int ossl_asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *type,
325 void *data, unsigned char *md, unsigned int *len,
326 OSSL_LIB_CTX *libctx, const char *propq);
327int ossl_x509_add_cert_new(STACK_OF(X509) **sk, X509 *cert, int flags);
328int ossl_x509_add_certs_new(STACK_OF(X509) **p_sk, STACK_OF(X509) *certs,
329 int flags);
330
331STACK_OF(X509_ATTRIBUTE) *ossl_x509at_dup(const STACK_OF(X509_ATTRIBUTE) *x);
332
333int ossl_x509_PUBKEY_get0_libctx(OSSL_LIB_CTX **plibctx, const char **ppropq,
334 const X509_PUBKEY *key);
335/* Calculate default key identifier according to RFC 5280 section 4.2.1.2 (1) */
336ASN1_OCTET_STRING *ossl_x509_pubkey_hash(X509_PUBKEY *pubkey);
337
338X509_PUBKEY *ossl_d2i_X509_PUBKEY_INTERNAL(const unsigned char **pp,
339 long len, OSSL_LIB_CTX *libctx);
340void ossl_X509_PUBKEY_INTERNAL_free(X509_PUBKEY *xpub);
341
342RSA *ossl_d2i_RSA_PSS_PUBKEY(RSA **a, const unsigned char **pp, long length);
343int ossl_i2d_RSA_PSS_PUBKEY(const RSA *a, unsigned char **pp);
344# ifndef OPENSSL_NO_DH
345DH *ossl_d2i_DH_PUBKEY(DH **a, const unsigned char **pp, long length);
346int ossl_i2d_DH_PUBKEY(const DH *a, unsigned char **pp);
347DH *ossl_d2i_DHx_PUBKEY(DH **a, const unsigned char **pp, long length);
348int ossl_i2d_DHx_PUBKEY(const DH *a, unsigned char **pp);
349# endif /* OPENSSL_NO_DH */
350# ifndef OPENSSL_NO_EC
351ECX_KEY *ossl_d2i_ED25519_PUBKEY(ECX_KEY **a,
352 const unsigned char **pp, long length);
353int ossl_i2d_ED25519_PUBKEY(const ECX_KEY *a, unsigned char **pp);
354ECX_KEY *ossl_d2i_ED448_PUBKEY(ECX_KEY **a,
355 const unsigned char **pp, long length);
356int ossl_i2d_ED448_PUBKEY(const ECX_KEY *a, unsigned char **pp);
357ECX_KEY *ossl_d2i_X25519_PUBKEY(ECX_KEY **a,
358 const unsigned char **pp, long length);
359int ossl_i2d_X25519_PUBKEY(const ECX_KEY *a, unsigned char **pp);
360ECX_KEY *ossl_d2i_X448_PUBKEY(ECX_KEY **a,
361 const unsigned char **pp, long length);
362int ossl_i2d_X448_PUBKEY(const ECX_KEY *a, unsigned char **pp);
363# endif /* OPENSSL_NO_EC */
364EVP_PKEY *ossl_d2i_PUBKEY_legacy(EVP_PKEY **a, const unsigned char **pp,
365 long length);
366
367int x509v3_add_len_value_uchar(const char *name, const unsigned char *value,
368 size_t vallen, STACK_OF(CONF_VALUE) **extlist);
369#endif /* OSSL_CRYPTO_X509_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette