1 /* $OpenBSD: x509.h,v 1.90 2022/07/12 14:42:50 kn Exp $ */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  *
9  * This library is free for commercial and non-commercial use as long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  *
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  *
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  *
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58 /* ====================================================================
59  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60  * ECDH support in OpenSSL originally developed by
61  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
62  */
63 
64 #ifndef HEADER_X509_H
65 #define HEADER_X509_H
66 
67 #include <openssl/opensslconf.h>
68 
69 #ifndef OPENSSL_NO_BUFFER
70 #include <openssl/buffer.h>
71 #endif
72 #ifndef OPENSSL_NO_EVP
73 #include <openssl/evp.h>
74 #endif
75 #ifndef OPENSSL_NO_BIO
76 #include <openssl/bio.h>
77 #endif
78 #include <openssl/stack.h>
79 #include <openssl/asn1.h>
80 #include <openssl/safestack.h>
81 
82 #ifndef OPENSSL_NO_EC
83 #include <openssl/ec.h>
84 #endif
85 
86 #ifndef OPENSSL_NO_ECDSA
87 #include <openssl/ecdsa.h>
88 #endif
89 
90 #ifndef OPENSSL_NO_ECDH
91 #include <openssl/ecdh.h>
92 #endif
93 
94 #ifndef OPENSSL_NO_DEPRECATED
95 #ifndef OPENSSL_NO_RSA
96 #include <openssl/rsa.h>
97 #endif
98 #ifndef OPENSSL_NO_DSA
99 #include <openssl/dsa.h>
100 #endif
101 #ifndef OPENSSL_NO_DH
102 #include <openssl/dh.h>
103 #endif
104 #endif
105 
106 #ifndef OPENSSL_NO_SHA
107 #include <openssl/sha.h>
108 #endif
109 #include <openssl/ossl_typ.h>
110 
111 #ifdef  __cplusplus
112 extern "C" {
113 #endif
114 
115 #if defined(_WIN32) && defined(__WINCRYPT_H__)
116 #ifndef LIBRESSL_INTERNAL
117 #ifdef _MSC_VER
118 #pragma message("Warning, overriding WinCrypt defines")
119 #else
120 #warning overriding WinCrypt defines
121 #endif
122 #endif
123 #undef X509_NAME
124 #undef X509_CERT_PAIR
125 #undef X509_EXTENSIONS
126 #endif
127 
128 #define X509_FILETYPE_PEM	1
129 #define X509_FILETYPE_ASN1	2
130 #define X509_FILETYPE_DEFAULT	3
131 
132 #define X509v3_KU_DIGITAL_SIGNATURE	0x0080
133 #define X509v3_KU_NON_REPUDIATION	0x0040
134 #define X509v3_KU_KEY_ENCIPHERMENT	0x0020
135 #define X509v3_KU_DATA_ENCIPHERMENT	0x0010
136 #define X509v3_KU_KEY_AGREEMENT		0x0008
137 #define X509v3_KU_KEY_CERT_SIGN		0x0004
138 #define X509v3_KU_CRL_SIGN		0x0002
139 #define X509v3_KU_ENCIPHER_ONLY		0x0001
140 #define X509v3_KU_DECIPHER_ONLY		0x8000
141 #define X509v3_KU_UNDEF			0xffff
142 
143 struct X509_algor_st {
144 	ASN1_OBJECT *algorithm;
145 	ASN1_TYPE *parameter;
146 } /* X509_ALGOR */;
147 
148 typedef STACK_OF(X509_ALGOR) X509_ALGORS;
149 
150 typedef struct X509_val_st {
151 	ASN1_TIME *notBefore;
152 	ASN1_TIME *notAfter;
153 } X509_VAL;
154 
155 typedef struct X509_sig_st X509_SIG;
156 
157 typedef struct X509_name_entry_st X509_NAME_ENTRY;
158 
159 DECLARE_STACK_OF(X509_NAME_ENTRY)
160 
161 DECLARE_STACK_OF(X509_NAME)
162 
163 typedef struct X509_extension_st X509_EXTENSION;
164 
165 typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
166 
167 DECLARE_STACK_OF(X509_EXTENSION)
168 
169 typedef struct x509_attributes_st X509_ATTRIBUTE;
170 
171 DECLARE_STACK_OF(X509_ATTRIBUTE)
172 
173 typedef struct X509_req_info_st X509_REQ_INFO;
174 
175 typedef struct X509_req_st X509_REQ;
176 
177 typedef struct x509_cert_aux_st X509_CERT_AUX;
178 
179 typedef struct x509_cinf_st X509_CINF;
180 
181 DECLARE_STACK_OF(X509)
182 
183 /* This is used for a table of trust checking functions */
184 
185 typedef struct x509_trust_st {
186 	int trust;
187 	int flags;
188 	int (*check_trust)(struct x509_trust_st *, X509 *, int);
189 	char *name;
190 	int arg1;
191 	void *arg2;
192 } X509_TRUST;
193 
194 DECLARE_STACK_OF(X509_TRUST)
195 
196 /* standard trust ids */
197 
198 /* OpenSSL changed this to 0 */
199 #define X509_TRUST_DEFAULT	-1	/* Only valid in purpose settings */
200 
201 #define X509_TRUST_COMPAT	1
202 #define X509_TRUST_SSL_CLIENT	2
203 #define X509_TRUST_SSL_SERVER	3
204 #define X509_TRUST_EMAIL	4
205 #define X509_TRUST_OBJECT_SIGN	5
206 #define X509_TRUST_OCSP_SIGN	6
207 #define X509_TRUST_OCSP_REQUEST	7
208 #define X509_TRUST_TSA		8
209 
210 /* Keep these up to date! */
211 #define X509_TRUST_MIN		1
212 #define X509_TRUST_MAX		8
213 
214 
215 /* trust_flags values */
216 #define	X509_TRUST_DYNAMIC 	1
217 #define	X509_TRUST_DYNAMIC_NAME	2
218 
219 /* check_trust return codes */
220 
221 #define X509_TRUST_TRUSTED	1
222 #define X509_TRUST_REJECTED	2
223 #define X509_TRUST_UNTRUSTED	3
224 
225 /* Flags for X509_print_ex() */
226 
227 #define	X509_FLAG_COMPAT		0
228 #define	X509_FLAG_NO_HEADER		1L
229 #define	X509_FLAG_NO_VERSION		(1L << 1)
230 #define	X509_FLAG_NO_SERIAL		(1L << 2)
231 #define	X509_FLAG_NO_SIGNAME		(1L << 3)
232 #define	X509_FLAG_NO_ISSUER		(1L << 4)
233 #define	X509_FLAG_NO_VALIDITY		(1L << 5)
234 #define	X509_FLAG_NO_SUBJECT		(1L << 6)
235 #define	X509_FLAG_NO_PUBKEY		(1L << 7)
236 #define	X509_FLAG_NO_EXTENSIONS		(1L << 8)
237 #define	X509_FLAG_NO_SIGDUMP		(1L << 9)
238 #define	X509_FLAG_NO_AUX		(1L << 10)
239 #define	X509_FLAG_NO_ATTRIBUTES		(1L << 11)
240 
241 /* Flags specific to X509_NAME_print_ex() */
242 
243 /* The field separator information */
244 
245 #define XN_FLAG_SEP_MASK	(0xf << 16)
246 
247 #define XN_FLAG_COMPAT		0		/* Traditional SSLeay: use old X509_NAME_print */
248 #define XN_FLAG_SEP_COMMA_PLUS	(1 << 16)	/* RFC2253 ,+ */
249 #define XN_FLAG_SEP_CPLUS_SPC	(2 << 16)	/* ,+ spaced: more readable */
250 #define XN_FLAG_SEP_SPLUS_SPC	(3 << 16)	/* ;+ spaced */
251 #define XN_FLAG_SEP_MULTILINE	(4 << 16)	/* One line per field */
252 
253 #define XN_FLAG_DN_REV		(1 << 20)	/* Reverse DN order */
254 
255 /* How the field name is shown */
256 
257 #define XN_FLAG_FN_MASK		(0x3 << 21)
258 
259 #define XN_FLAG_FN_SN		0		/* Object short name */
260 #define XN_FLAG_FN_LN		(1 << 21)	/* Object long name */
261 #define XN_FLAG_FN_OID		(2 << 21)	/* Always use OIDs */
262 #define XN_FLAG_FN_NONE		(3 << 21)	/* No field names */
263 
264 #define XN_FLAG_SPC_EQ		(1 << 23)	/* Put spaces round '=' */
265 
266 /* This determines if we dump fields we don't recognise:
267  * RFC2253 requires this.
268  */
269 
270 #define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
271 
272 #define XN_FLAG_FN_ALIGN	(1 << 25)	/* Align field names to 20 characters */
273 
274 /* Complete set of RFC2253 flags */
275 
276 #define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
277 			XN_FLAG_SEP_COMMA_PLUS | \
278 			XN_FLAG_DN_REV | \
279 			XN_FLAG_FN_SN | \
280 			XN_FLAG_DUMP_UNKNOWN_FIELDS)
281 
282 /* readable oneline form */
283 
284 #define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
285 			ASN1_STRFLGS_ESC_QUOTE | \
286 			XN_FLAG_SEP_CPLUS_SPC | \
287 			XN_FLAG_SPC_EQ | \
288 			XN_FLAG_FN_SN)
289 
290 /* readable multiline form */
291 
292 #define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
293 			ASN1_STRFLGS_ESC_MSB | \
294 			XN_FLAG_SEP_MULTILINE | \
295 			XN_FLAG_SPC_EQ | \
296 			XN_FLAG_FN_LN | \
297 			XN_FLAG_FN_ALIGN)
298 
299 DECLARE_STACK_OF(X509_REVOKED)
300 
301 typedef struct X509_crl_info_st X509_CRL_INFO;
302 
303 DECLARE_STACK_OF(X509_CRL)
304 
305 typedef struct private_key_st {
306 	int version;
307 	/* The PKCS#8 data types */
308 	X509_ALGOR *enc_algor;
309 	ASN1_OCTET_STRING *enc_pkey;	/* encrypted pub key */
310 
311 	/* When decrypted, the following will not be NULL */
312 	EVP_PKEY *dec_pkey;
313 
314 	/* used to encrypt and decrypt */
315 	int key_length;
316 	char *key_data;
317 	int key_free;	/* true if we should auto free key_data */
318 
319 	/* expanded version of 'enc_algor' */
320 	EVP_CIPHER_INFO cipher;
321 
322 	int references;
323 } X509_PKEY;
324 
325 #ifndef OPENSSL_NO_EVP
326 typedef struct X509_info_st {
327 	X509 *x509;
328 	X509_CRL *crl;
329 	X509_PKEY *x_pkey;
330 
331 	EVP_CIPHER_INFO enc_cipher;
332 	int enc_len;
333 	char *enc_data;
334 
335 	int references;
336 } X509_INFO;
337 
338 DECLARE_STACK_OF(X509_INFO)
339 #endif
340 
341 /* The next 2 structures and their 8 routines were sent to me by
342  * Pat Richard <patr@x509.com> and are used to manipulate
343  * Netscapes spki structures - useful if you are writing a CA web page
344  */
345 typedef struct Netscape_spkac_st {
346 	X509_PUBKEY *pubkey;
347 	ASN1_IA5STRING *challenge;	/* challenge sent in atlas >= PR2 */
348 } NETSCAPE_SPKAC;
349 
350 typedef struct Netscape_spki_st {
351 	NETSCAPE_SPKAC *spkac;	/* signed public key and challenge */
352 	X509_ALGOR *sig_algor;
353 	ASN1_BIT_STRING *signature;
354 } NETSCAPE_SPKI;
355 
356 /* Netscape certificate sequence structure */
357 typedef struct Netscape_certificate_sequence {
358 	ASN1_OBJECT *type;
359 	STACK_OF(X509) *certs;
360 } NETSCAPE_CERT_SEQUENCE;
361 
362 
363 /* Password based encryption structure */
364 
365 typedef struct PBEPARAM_st {
366 	ASN1_OCTET_STRING *salt;
367 	ASN1_INTEGER *iter;
368 } PBEPARAM;
369 
370 /* Password based encryption V2 structures */
371 
372 typedef struct PBE2PARAM_st {
373 	X509_ALGOR *keyfunc;
374 	X509_ALGOR *encryption;
375 } PBE2PARAM;
376 
377 typedef struct PBKDF2PARAM_st {
378 	/* Usually OCTET STRING but could be anything */
379 	ASN1_TYPE *salt;
380 	ASN1_INTEGER *iter;
381 	ASN1_INTEGER *keylength;
382 	X509_ALGOR *prf;
383 } PBKDF2PARAM;
384 
385 #ifdef  __cplusplus
386 }
387 #endif
388 
389 #include <openssl/x509_vfy.h>
390 #include <openssl/pkcs7.h>
391 
392 #ifdef  __cplusplus
393 extern "C" {
394 #endif
395 
396 #define		X509_extract_key(x)	X509_get_pubkey(x) /*****/
397 #define		X509_REQ_extract_key(a)	X509_REQ_get_pubkey(a)
398 #define		X509_name_cmp(a,b)	X509_NAME_cmp((a),(b))
399 
400 int X509_CRL_up_ref(X509_CRL *x);
401 int X509_CRL_get_signature_nid(const X509_CRL *crl);
402 
403 int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
404 
405 const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
406 long X509_CRL_get_version(const X509_CRL *crl);
407 const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);
408 const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);
409 ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl);
410 ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
411 X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
412 STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
413 void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
414     const X509_ALGOR **palg);
415 
416 int X509_REQ_get_signature_nid(const X509_REQ *req);
417 
418 void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
419     const X509_ALGOR **palg);
420 
421 void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
422 X509_CRL_METHOD *X509_CRL_METHOD_new(
423 	int (*crl_init)(X509_CRL *crl),
424 	int (*crl_free)(X509_CRL *crl),
425 	int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
426 				ASN1_INTEGER *ser, X509_NAME *issuer),
427 	int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk));
428 void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
429 
430 void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
431 void *X509_CRL_get_meth_data(X509_CRL *crl);
432 
433 X509_PUBKEY	*X509_get_X509_PUBKEY(const X509 *x);
434 
435 const char *X509_verify_cert_error_string(long n);
436 
437 #ifndef OPENSSL_NO_EVP
438 int X509_verify(X509 *a, EVP_PKEY *r);
439 
440 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
441 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
442 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
443 
444 NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
445 char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
446 EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
447 int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
448 
449 int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
450 
451 int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
452 int X509_signature_print(BIO *bp, const X509_ALGOR *alg,
453     const ASN1_STRING *sig);
454 
455 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
456 int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
457 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
458 int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
459 int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
460 int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
461 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
462 
463 int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
464 		unsigned char *md, unsigned int *len);
465 int X509_digest(const X509 *data,const EVP_MD *type,
466 		unsigned char *md, unsigned int *len);
467 int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
468 		unsigned char *md, unsigned int *len);
469 int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
470 		unsigned char *md, unsigned int *len);
471 int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
472 		unsigned char *md, unsigned int *len);
473 #endif
474 
475 X509 *d2i_X509_fp(FILE *fp, X509 **x509);
476 int i2d_X509_fp(FILE *fp,X509 *x509);
477 X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
478 int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
479 X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
480 int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
481 #ifndef OPENSSL_NO_RSA
482 RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
483 int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
484 RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
485 int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
486 RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
487 int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
488 #endif
489 #ifndef OPENSSL_NO_DSA
490 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
491 int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
492 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
493 int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
494 #endif
495 #ifndef OPENSSL_NO_EC
496 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
497 int   i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
498 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
499 int   i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
500 #endif
501 X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
502 int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
503 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
504 						PKCS8_PRIV_KEY_INFO **p8inf);
505 int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
506 int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
507 int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
508 EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
509 int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
510 EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
511 
512 #ifndef OPENSSL_NO_BIO
513 X509 *d2i_X509_bio(BIO *bp,X509 **x509);
514 int i2d_X509_bio(BIO *bp,X509 *x509);
515 X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
516 int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
517 X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
518 int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
519 #ifndef OPENSSL_NO_RSA
520 RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
521 int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
522 RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
523 int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
524 RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
525 int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
526 #endif
527 #ifndef OPENSSL_NO_DSA
528 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
529 int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
530 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
531 int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
532 #endif
533 #ifndef OPENSSL_NO_EC
534 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
535 int   i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
536 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
537 int   i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
538 #endif
539 X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
540 int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
541 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
542 						PKCS8_PRIV_KEY_INFO **p8inf);
543 int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
544 int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
545 int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
546 EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
547 int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
548 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
549 #endif
550 
551 X509 *X509_dup(X509 *x509);
552 X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
553 X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
554 X509_CRL *X509_CRL_dup(X509_CRL *crl);
555 X509_REQ *X509_REQ_dup(X509_REQ *req);
556 X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
557 int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
558 void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval,
559     const X509_ALGOR *algor);
560 void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
561 int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
562 
563 X509_NAME *X509_NAME_dup(X509_NAME *xn);
564 int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, size_t *pderlen);
565 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
566 
567 int		X509_cmp_time(const ASN1_TIME *s, time_t *t);
568 int		X509_cmp_current_time(const ASN1_TIME *s);
569 ASN1_TIME *	X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
570 ASN1_TIME *	X509_time_adj_ex(ASN1_TIME *s,
571 				int offset_day, long offset_sec, time_t *t);
572 ASN1_TIME *	X509_gmtime_adj(ASN1_TIME *s, long adj);
573 
574 const char *	X509_get_default_cert_area(void );
575 const char *	X509_get_default_cert_dir(void );
576 const char *	X509_get_default_cert_file(void );
577 const char *	X509_get_default_cert_dir_env(void );
578 const char *	X509_get_default_cert_file_env(void );
579 const char *	X509_get_default_private_dir(void );
580 
581 X509_REQ *	X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
582 X509 *		X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
583 
584 X509_ALGOR *X509_ALGOR_new(void);
585 void X509_ALGOR_free(X509_ALGOR *a);
586 X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, const unsigned char **in, long len);
587 int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **out);
588 extern const ASN1_ITEM X509_ALGOR_it;
589 X509_ALGORS *d2i_X509_ALGORS(X509_ALGORS **a, const unsigned char **in, long len);
590 int i2d_X509_ALGORS(X509_ALGORS *a, unsigned char **out);
591 extern const ASN1_ITEM X509_ALGORS_it;
592 X509_VAL *X509_VAL_new(void);
593 void X509_VAL_free(X509_VAL *a);
594 X509_VAL *d2i_X509_VAL(X509_VAL **a, const unsigned char **in, long len);
595 int i2d_X509_VAL(X509_VAL *a, unsigned char **out);
596 extern const ASN1_ITEM X509_VAL_it;
597 
598 X509_PUBKEY *X509_PUBKEY_new(void);
599 void X509_PUBKEY_free(X509_PUBKEY *a);
600 X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **a, const unsigned char **in, long len);
601 int i2d_X509_PUBKEY(X509_PUBKEY *a, unsigned char **out);
602 extern const ASN1_ITEM X509_PUBKEY_it;
603 
604 int		X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
605 EVP_PKEY *	X509_PUBKEY_get(X509_PUBKEY *key);
606 EVP_PKEY *	X509_PUBKEY_get0(X509_PUBKEY *key);
607 int		X509_get_pubkey_parameters(EVP_PKEY *pkey,
608 					   STACK_OF(X509) *chain);
609 int		i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
610 EVP_PKEY *	d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
611 			long length);
612 #ifndef OPENSSL_NO_RSA
613 int		i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
614 RSA *		d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
615 			long length);
616 #endif
617 #ifndef OPENSSL_NO_DSA
618 int		i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
619 DSA *		d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
620 			long length);
621 #endif
622 #ifndef OPENSSL_NO_EC
623 int		i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
624 EC_KEY 		*d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
625 			long length);
626 #endif
627 
628 X509_SIG *X509_SIG_new(void);
629 void X509_SIG_free(X509_SIG *a);
630 X509_SIG *d2i_X509_SIG(X509_SIG **a, const unsigned char **in, long len);
631 int i2d_X509_SIG(X509_SIG *a, unsigned char **out);
632 extern const ASN1_ITEM X509_SIG_it;
633 void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,
634     const ASN1_OCTET_STRING **pdigest);
635 void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,
636     ASN1_OCTET_STRING **pdigest);
637 
638 X509_REQ_INFO *X509_REQ_INFO_new(void);
639 void X509_REQ_INFO_free(X509_REQ_INFO *a);
640 X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, const unsigned char **in, long len);
641 int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **out);
642 extern const ASN1_ITEM X509_REQ_INFO_it;
643 X509_REQ *X509_REQ_new(void);
644 void X509_REQ_free(X509_REQ *a);
645 X509_REQ *d2i_X509_REQ(X509_REQ **a, const unsigned char **in, long len);
646 int i2d_X509_REQ(X509_REQ *a, unsigned char **out);
647 extern const ASN1_ITEM X509_REQ_it;
648 
649 X509_ATTRIBUTE *X509_ATTRIBUTE_new(void);
650 void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
651 X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a, const unsigned char **in, long len);
652 int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a, unsigned char **out);
653 extern const ASN1_ITEM X509_ATTRIBUTE_it;
654 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
655 
656 X509_EXTENSION *X509_EXTENSION_new(void);
657 void X509_EXTENSION_free(X509_EXTENSION *a);
658 X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, const unsigned char **in, long len);
659 int i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **out);
660 extern const ASN1_ITEM X509_EXTENSION_it;
661 X509_EXTENSIONS *d2i_X509_EXTENSIONS(X509_EXTENSIONS **a, const unsigned char **in, long len);
662 int i2d_X509_EXTENSIONS(X509_EXTENSIONS *a, unsigned char **out);
663 extern const ASN1_ITEM X509_EXTENSIONS_it;
664 
665 X509_NAME_ENTRY *X509_NAME_ENTRY_new(void);
666 void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a);
667 X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a, const unsigned char **in, long len);
668 int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a, unsigned char **out);
669 extern const ASN1_ITEM X509_NAME_ENTRY_it;
670 
671 X509_NAME *X509_NAME_new(void);
672 void X509_NAME_free(X509_NAME *a);
673 X509_NAME *d2i_X509_NAME(X509_NAME **a, const unsigned char **in, long len);
674 int i2d_X509_NAME(X509_NAME *a, unsigned char **out);
675 extern const ASN1_ITEM X509_NAME_it;
676 
677 int		X509_NAME_set(X509_NAME **xn, X509_NAME *name);
678 
679 X509_CINF *X509_CINF_new(void);
680 void X509_CINF_free(X509_CINF *a);
681 X509_CINF *d2i_X509_CINF(X509_CINF **a, const unsigned char **in, long len);
682 int i2d_X509_CINF(X509_CINF *a, unsigned char **out);
683 extern const ASN1_ITEM X509_CINF_it;
684 
685 X509 *X509_new(void);
686 void X509_free(X509 *a);
687 X509 *d2i_X509(X509 **a, const unsigned char **in, long len);
688 int i2d_X509(X509 *a, unsigned char **out);
689 extern const ASN1_ITEM X509_it;
690 X509_CERT_AUX *X509_CERT_AUX_new(void);
691 void X509_CERT_AUX_free(X509_CERT_AUX *a);
692 X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, const unsigned char **in, long len);
693 int i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **out);
694 extern const ASN1_ITEM X509_CERT_AUX_it;
695 
696 int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
697 	     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
698 int X509_set_ex_data(X509 *r, int idx, void *arg);
699 void *X509_get_ex_data(X509 *r, int idx);
700 int		i2d_X509_AUX(X509 *a,unsigned char **pp);
701 X509 *		d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
702 
703 int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
704 
705 void X509_get0_signature(const ASN1_BIT_STRING **psig,
706     const X509_ALGOR **palg, const X509 *x);
707 int X509_get_signature_nid(const X509 *x);
708 
709 int X509_alias_set1(X509 *x, const unsigned char *name, int len);
710 int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
711 unsigned char *X509_alias_get0(X509 *x, int *len);
712 unsigned char *X509_keyid_get0(X509 *x, int *len);
713 int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
714 int X509_TRUST_set(int *t, int trust);
715 int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
716 int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);
717 void X509_trust_clear(X509 *x);
718 void X509_reject_clear(X509 *x);
719 
720 X509_REVOKED *X509_REVOKED_new(void);
721 void X509_REVOKED_free(X509_REVOKED *a);
722 X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *a);
723 X509_REVOKED *d2i_X509_REVOKED(X509_REVOKED **a, const unsigned char **in, long len);
724 int i2d_X509_REVOKED(X509_REVOKED *a, unsigned char **out);
725 extern const ASN1_ITEM X509_REVOKED_it;
726 
727 X509_CRL_INFO *X509_CRL_INFO_new(void);
728 void X509_CRL_INFO_free(X509_CRL_INFO *a);
729 X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, const unsigned char **in, long len);
730 int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **out);
731 extern const ASN1_ITEM X509_CRL_INFO_it;
732 
733 X509_CRL *X509_CRL_new(void);
734 void X509_CRL_free(X509_CRL *a);
735 X509_CRL *d2i_X509_CRL(X509_CRL **a, const unsigned char **in, long len);
736 int i2d_X509_CRL(X509_CRL *a, unsigned char **out);
737 extern const ASN1_ITEM X509_CRL_it;
738 
739 int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
740 int X509_CRL_get0_by_serial(X509_CRL *crl,
741 		X509_REVOKED **ret, ASN1_INTEGER *serial);
742 int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
743 
744 X509_PKEY *	X509_PKEY_new(void );
745 void		X509_PKEY_free(X509_PKEY *a);
746 
747 NETSCAPE_SPKI *NETSCAPE_SPKI_new(void);
748 void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a);
749 NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, const unsigned char **in, long len);
750 int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **out);
751 extern const ASN1_ITEM NETSCAPE_SPKI_it;
752 NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void);
753 void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a);
754 NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a, const unsigned char **in, long len);
755 int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a, unsigned char **out);
756 extern const ASN1_ITEM NETSCAPE_SPKAC_it;
757 NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void);
758 void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a);
759 NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, const unsigned char **in, long len);
760 int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **out);
761 extern const ASN1_ITEM NETSCAPE_CERT_SEQUENCE_it;
762 
763 #ifndef OPENSSL_NO_EVP
764 X509_INFO *	X509_INFO_new(void);
765 void		X509_INFO_free(X509_INFO *a);
766 char *		X509_NAME_oneline(const X509_NAME *a, char *buf, int size);
767 
768 int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
769 	unsigned char *md,unsigned int *len);
770 
771 int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
772 	ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
773 
774 int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
775 	ASN1_BIT_STRING *signature,
776 	void *data, EVP_PKEY *pkey, const EVP_MD *type);
777 int ASN1_item_sign_ctx(const ASN1_ITEM *it,
778 		X509_ALGOR *algor1, X509_ALGOR *algor2,
779 	     	ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx);
780 #endif
781 
782 const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
783 const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
784 int 		X509_set_version(X509 *x, long version);
785 long		X509_get_version(const X509 *x);
786 int 		X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
787 ASN1_INTEGER *	X509_get_serialNumber(X509 *x);
788 const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);
789 int 		X509_set_issuer_name(X509 *x, X509_NAME *name);
790 X509_NAME *	X509_get_issuer_name(const X509 *a);
791 int 		X509_set_subject_name(X509 *x, X509_NAME *name);
792 X509_NAME *	X509_get_subject_name(const X509 *a);
793 int 		X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
794 int 		X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);
795 int 		X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
796 int 		X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);
797 const ASN1_TIME *X509_get0_notBefore(const X509 *x);
798 ASN1_TIME *X509_getm_notBefore(const X509 *x);
799 const ASN1_TIME *X509_get0_notAfter(const X509 *x);
800 ASN1_TIME *X509_getm_notAfter(const X509 *x);
801 int 		X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
802 EVP_PKEY *	X509_get_pubkey(X509 *x);
803 EVP_PKEY *	X509_get0_pubkey(const X509 *x);
804 ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
805 int		X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey);
806 int		X509_get_signature_type(const X509 *x);
807 
808 #define X509_get_notBefore	X509_getm_notBefore
809 #define X509_get_notAfter	X509_getm_notAfter
810 
811 int		X509_REQ_set_version(X509_REQ *x,long version);
812 long		X509_REQ_get_version(const X509_REQ *x);
813 int		X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
814 X509_NAME	*X509_REQ_get_subject_name(const X509_REQ *x);
815 int		X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
816 EVP_PKEY *	X509_REQ_get_pubkey(X509_REQ *req);
817 int		i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
818 EVP_PKEY *	X509_REQ_get0_pubkey(X509_REQ *req);
819 int		X509_REQ_extension_nid(int nid);
820 int *		X509_REQ_get_extension_nids(void);
821 void		X509_REQ_set_extension_nids(int *nids);
822 STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
823 int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
824 				int nid);
825 int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
826 int X509_REQ_get_attr_count(const X509_REQ *req);
827 int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
828 			  int lastpos);
829 int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
830 			  int lastpos);
831 X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
832 X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
833 int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
834 int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
835 			const ASN1_OBJECT *obj, int type,
836 			const unsigned char *bytes, int len);
837 int X509_REQ_add1_attr_by_NID(X509_REQ *req,
838 			int nid, int type,
839 			const unsigned char *bytes, int len);
840 int X509_REQ_add1_attr_by_txt(X509_REQ *req,
841 			const char *attrname, int type,
842 			const unsigned char *bytes, int len);
843 
844 int X509_CRL_set_version(X509_CRL *x, long version);
845 int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
846 int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
847 int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
848 int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
849 int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
850 int X509_CRL_sort(X509_CRL *crl);
851 
852 const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *x);
853 const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);
854 const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);
855 int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
856 int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
857 
858 int		X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
859 
860 int		X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);
861 
862 int		X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
863 unsigned long	X509_issuer_and_serial_hash(X509 *a);
864 
865 int		X509_issuer_name_cmp(const X509 *a, const X509 *b);
866 unsigned long	X509_issuer_name_hash(X509 *a);
867 
868 int		X509_subject_name_cmp(const X509 *a, const X509 *b);
869 unsigned long	X509_subject_name_hash(X509 *x);
870 
871 #ifndef OPENSSL_NO_MD5
872 unsigned long	X509_issuer_name_hash_old(X509 *a);
873 unsigned long	X509_subject_name_hash_old(X509 *x);
874 #endif
875 
876 int		X509_cmp(const X509 *a, const X509 *b);
877 int		X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
878 unsigned long	X509_NAME_hash(X509_NAME *x);
879 unsigned long	X509_NAME_hash_old(X509_NAME *x);
880 
881 int		X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
882 int		X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
883 int		X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
884 int		X509_print_fp(FILE *bp,X509 *x);
885 int		X509_CRL_print_fp(FILE *bp,X509_CRL *x);
886 int		X509_REQ_print_fp(FILE *bp,X509_REQ *req);
887 int		X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,
888 		    unsigned long flags);
889 
890 #ifndef OPENSSL_NO_BIO
891 int		X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);
892 int		X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,
893 		    unsigned long flags);
894 int		X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
895 int		X509_print(BIO *bp,X509 *x);
896 int		X509_ocspid_print(BIO *bp,X509 *x);
897 int		X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
898 int		X509_CRL_print(BIO *bp,X509_CRL *x);
899 int		X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
900 int		X509_REQ_print(BIO *bp,X509_REQ *req);
901 #endif
902 
903 int 		X509_NAME_entry_count(const X509_NAME *name);
904 int 		X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
905 			char *buf,int len);
906 int		X509_NAME_get_text_by_OBJ(X509_NAME *name,
907 			const ASN1_OBJECT *obj, char *buf,int len);
908 
909 /* NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use
910  * lastpos, search after that position on. */
911 int 		X509_NAME_get_index_by_NID(const X509_NAME *name, int nid,
912 			int lastpos);
913 int 		X509_NAME_get_index_by_OBJ(const X509_NAME *name,
914 			const ASN1_OBJECT *obj, int lastpos);
915 X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
916 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
917 int 		X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,
918 			int loc, int set);
919 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,
920     int type, const unsigned char *bytes, int len, int loc, int set);
921 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
922 			const unsigned char *bytes, int len, int loc, int set);
923 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
924 		const char *field, int type, const unsigned char *bytes, int len);
925 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
926 			int type, const unsigned char *bytes, int len);
927 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
928 			const unsigned char *bytes, int len, int loc, int set);
929 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
930 			const ASN1_OBJECT *obj, int type,
931 			const unsigned char *bytes, int len);
932 int 		X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
933 			const ASN1_OBJECT *obj);
934 int 		X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
935 			const unsigned char *bytes, int len);
936 ASN1_OBJECT *	X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);
937 ASN1_STRING *	X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);
938 int		X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
939 
940 int		X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
941 int		X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
942 				      int nid, int lastpos);
943 int		X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
944 				      const ASN1_OBJECT *obj, int lastpos);
945 int		X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
946 					   int crit, int lastpos);
947 X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
948 X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
949 STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
950 					 X509_EXTENSION *ex, int loc);
951 
952 int		X509_get_ext_count(const X509 *x);
953 int		X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);
954 int		X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj,
955 		    int lastpos);
956 int		X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);
957 X509_EXTENSION *X509_get_ext(const X509 *x, int loc);
958 X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
959 int		X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
960 void	*	X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
961 int		X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
962 							unsigned long flags);
963 
964 int		X509_CRL_get_ext_count(const X509_CRL *x);
965 int		X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid,
966 		    int lastpos);
967 int		X509_CRL_get_ext_by_OBJ(const X509_CRL *x,
968 		    const ASN1_OBJECT *obj, int lastpos);
969 int		X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit,
970 		    int lastpos);
971 X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
972 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
973 int		X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
974 void	*	X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit,
975 		    int *idx);
976 int		X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value,
977 		    int crit, unsigned long flags);
978 
979 int		X509_REVOKED_get_ext_count(const X509_REVOKED *x);
980 int		X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid,
981 		    int lastpos);
982 int		X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x,
983 		    const ASN1_OBJECT *obj, int lastpos);
984 int		X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x,
985 		    int crit, int lastpos);
986 X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);
987 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
988 int		X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex,
989 		    int loc);
990 void	*	X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid,
991 		    int *crit, int *idx);
992 int		X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value,
993 		    int crit, unsigned long flags);
994 
995 X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
996 			int nid, int crit, ASN1_OCTET_STRING *data);
997 X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
998     const ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data);
999 int		X509_EXTENSION_set_object(X509_EXTENSION *ex,
1000 		    const ASN1_OBJECT *obj);
1001 int		X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
1002 int		X509_EXTENSION_set_data(X509_EXTENSION *ex,
1003 			ASN1_OCTET_STRING *data);
1004 ASN1_OBJECT *	X509_EXTENSION_get_object(X509_EXTENSION *ex);
1005 ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
1006 int		X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
1007 
1008 int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
1009 int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
1010 			  int lastpos);
1011 int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
1012     const ASN1_OBJECT *obj, int lastpos);
1013 X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
1014 X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1015 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1016 					 X509_ATTRIBUTE *attr);
1017 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
1018 			const ASN1_OBJECT *obj, int type,
1019 			const unsigned char *bytes, int len);
1020 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
1021 			int nid, int type,
1022 			const unsigned char *bytes, int len);
1023 STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
1024 			const char *attrname, int type,
1025 			const unsigned char *bytes, int len);
1026 void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
1027     const ASN1_OBJECT *obj, int lastpos, int type);
1028 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1029 	     int atrtype, const void *data, int len);
1030 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1031 	     const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
1032 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1033 		const char *atrname, int type, const unsigned char *bytes, int len);
1034 int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
1035 int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
1036 void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
1037 					int atrtype, void *data);
1038 int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
1039 ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1040 ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
1041 
1042 int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
1043 int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
1044 			  int lastpos);
1045 int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
1046 			  int lastpos);
1047 X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
1048 X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
1049 int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
1050 int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
1051 			const ASN1_OBJECT *obj, int type,
1052 			const unsigned char *bytes, int len);
1053 int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
1054 			int nid, int type,
1055 			const unsigned char *bytes, int len);
1056 int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
1057 			const char *attrname, int type,
1058 			const unsigned char *bytes, int len);
1059 
1060 int		X509_verify_cert(X509_STORE_CTX *ctx);
1061 
1062 /* lookup a cert from a X509 STACK */
1063 X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
1064 				     ASN1_INTEGER *serial);
1065 X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
1066 
1067 PBEPARAM *PBEPARAM_new(void);
1068 void PBEPARAM_free(PBEPARAM *a);
1069 PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, const unsigned char **in, long len);
1070 int i2d_PBEPARAM(PBEPARAM *a, unsigned char **out);
1071 extern const ASN1_ITEM PBEPARAM_it;
1072 PBE2PARAM *PBE2PARAM_new(void);
1073 void PBE2PARAM_free(PBE2PARAM *a);
1074 PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, const unsigned char **in, long len);
1075 int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **out);
1076 extern const ASN1_ITEM PBE2PARAM_it;
1077 PBKDF2PARAM *PBKDF2PARAM_new(void);
1078 void PBKDF2PARAM_free(PBKDF2PARAM *a);
1079 PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, const unsigned char **in, long len);
1080 int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **out);
1081 extern const ASN1_ITEM PBKDF2PARAM_it;
1082 
1083 int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
1084 				const unsigned char *salt, int saltlen);
1085 
1086 X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
1087 				const unsigned char *salt, int saltlen);
1088 X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
1089 					 unsigned char *salt, int saltlen);
1090 X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
1091 				 unsigned char *salt, int saltlen,
1092 				 unsigned char *aiv, int prf_nid);
1093 
1094 X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
1095 				int prf_nid, int keylen);
1096 
1097 /* PKCS#8 utilities */
1098 
1099 PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void);
1100 void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
1101 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, const unsigned char **in, long len);
1102 int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **out);
1103 extern const ASN1_ITEM PKCS8_PRIV_KEY_INFO_it;
1104 
1105 EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);
1106 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
1107 
1108 int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version,
1109     int ptype, void *pval, unsigned char *penc, int penclen);
1110 int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk,
1111     int *ppklen, const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);
1112 
1113 const STACK_OF(X509_ATTRIBUTE) *PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);
1114 int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,
1115     const unsigned char *bytes, int len);
1116 
1117 int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
1118 					int ptype, void *pval,
1119 					unsigned char *penc, int penclen);
1120 int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
1121 		const unsigned char **pk, int *ppklen,
1122 		X509_ALGOR **pa,
1123 		X509_PUBKEY *pub);
1124 
1125 int X509_check_trust(X509 *x, int id, int flags);
1126 int X509_TRUST_get_count(void);
1127 X509_TRUST * X509_TRUST_get0(int idx);
1128 int X509_TRUST_get_by_id(int id);
1129 int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
1130     const char *name, int arg1, void *arg2);
1131 void X509_TRUST_cleanup(void);
1132 int X509_TRUST_get_flags(const X509_TRUST *xp);
1133 char *X509_TRUST_get0_name(const X509_TRUST *xp);
1134 int X509_TRUST_get_trust(const X509_TRUST *xp);
1135 
1136 int X509_up_ref(X509 *x);
1137 STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
1138 
1139 void ERR_load_X509_strings(void);
1140 
1141 /* Error codes for the X509 functions. */
1142 
1143 /* Function codes. */
1144 #define X509_F_ADD_CERT_DIR				 100
1145 #define X509_F_BY_FILE_CTRL				 101
1146 #define X509_F_CHECK_POLICY				 145
1147 #define X509_F_DIR_CTRL					 102
1148 #define X509_F_GET_CERT_BY_SUBJECT			 103
1149 #define X509_F_NETSCAPE_SPKI_B64_DECODE			 129
1150 #define X509_F_NETSCAPE_SPKI_B64_ENCODE			 130
1151 #define X509_F_X509AT_ADD1_ATTR				 135
1152 #define X509_F_X509V3_ADD_EXT				 104
1153 #define X509_F_X509_ATTRIBUTE_CREATE_BY_NID		 136
1154 #define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ		 137
1155 #define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT		 140
1156 #define X509_F_X509_ATTRIBUTE_GET0_DATA			 139
1157 #define X509_F_X509_ATTRIBUTE_SET1_DATA			 138
1158 #define X509_F_X509_CHECK_PRIVATE_KEY			 128
1159 #define X509_F_X509_CRL_PRINT_FP			 147
1160 #define X509_F_X509_EXTENSION_CREATE_BY_NID		 108
1161 #define X509_F_X509_EXTENSION_CREATE_BY_OBJ		 109
1162 #define X509_F_X509_GET_PUBKEY_PARAMETERS		 110
1163 #define X509_F_X509_LOAD_CERT_CRL_FILE			 132
1164 #define X509_F_X509_LOAD_CERT_FILE			 111
1165 #define X509_F_X509_LOAD_CRL_FILE			 112
1166 #define X509_F_X509_NAME_ADD_ENTRY			 113
1167 #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID		 114
1168 #define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT		 131
1169 #define X509_F_X509_NAME_ENTRY_SET_OBJECT		 115
1170 #define X509_F_X509_NAME_ONELINE			 116
1171 #define X509_F_X509_NAME_PRINT				 117
1172 #define X509_F_X509_PRINT_EX_FP				 118
1173 #define X509_F_X509_PUBKEY_GET				 119
1174 #define X509_F_X509_PUBKEY_SET				 120
1175 #define X509_F_X509_REQ_CHECK_PRIVATE_KEY		 144
1176 #define X509_F_X509_REQ_PRINT_EX			 121
1177 #define X509_F_X509_REQ_PRINT_FP			 122
1178 #define X509_F_X509_REQ_TO_X509				 123
1179 #define X509_F_X509_STORE_ADD_CERT			 124
1180 #define X509_F_X509_STORE_ADD_CRL			 125
1181 #define X509_F_X509_STORE_CTX_GET1_ISSUER		 146
1182 #define X509_F_X509_STORE_CTX_INIT			 143
1183 #define X509_F_X509_STORE_CTX_NEW			 142
1184 #define X509_F_X509_STORE_CTX_PURPOSE_INHERIT		 134
1185 #define X509_F_X509_TO_X509_REQ				 126
1186 #define X509_F_X509_TRUST_ADD				 133
1187 #define X509_F_X509_TRUST_SET				 141
1188 #define X509_F_X509_VERIFY_CERT				 127
1189 
1190 /* Reason codes. */
1191 #define X509_R_BAD_X509_FILETYPE			 100
1192 #define X509_R_BASE64_DECODE_ERROR			 118
1193 #define X509_R_CANT_CHECK_DH_KEY			 114
1194 #define X509_R_CERT_ALREADY_IN_HASH_TABLE		 101
1195 #define X509_R_ERR_ASN1_LIB				 102
1196 #define X509_R_INVALID_DIRECTORY			 113
1197 #define X509_R_INVALID_FIELD_NAME			 119
1198 #define X509_R_INVALID_TRUST				 123
1199 #define X509_R_KEY_TYPE_MISMATCH			 115
1200 #define X509_R_KEY_VALUES_MISMATCH			 116
1201 #define X509_R_LOADING_CERT_DIR				 103
1202 #define X509_R_LOADING_DEFAULTS				 104
1203 #define X509_R_METHOD_NOT_SUPPORTED			 124
1204 #define X509_R_NO_CERTIFICATE_OR_CRL_FOUND		 136
1205 #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY		 105
1206 #define X509_R_PUBLIC_KEY_DECODE_ERROR			 125
1207 #define X509_R_PUBLIC_KEY_ENCODE_ERROR			 126
1208 #define X509_R_SHOULD_RETRY				 106
1209 #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN	 107
1210 #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY		 108
1211 #define X509_R_UNKNOWN_KEY_TYPE				 117
1212 #define X509_R_UNKNOWN_NID				 109
1213 #define X509_R_UNKNOWN_PURPOSE_ID			 121
1214 #define X509_R_UNKNOWN_TRUST_ID				 120
1215 #define X509_R_UNSUPPORTED_ALGORITHM			 111
1216 #define X509_R_WRONG_LOOKUP_TYPE			 112
1217 #define X509_R_WRONG_TYPE				 122
1218 
1219 #ifdef  __cplusplus
1220 }
1221 #endif
1222 #endif
1223