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