]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/x509.h
ex_data part 2: doc fixes and CRYPTO_free_ex_index.
[thirdparty/openssl.git] / include / openssl / x509.h
CommitLineData
d02b48c6 1/* crypto/x509/x509.h */
58964a49 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
d02b48c6
RE
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.
0f113f3e 8 *
d02b48c6
RE
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).
0f113f3e 15 *
d02b48c6
RE
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.
0f113f3e 22 *
d02b48c6
RE
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 :-).
0f113f3e 37 * 4. If you include any Windows specific code (or a derivative thereof) from
d02b48c6
RE
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
0f113f3e 40 *
d02b48c6
RE
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.
0f113f3e 52 *
d02b48c6
RE
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 */
e172d60d
BM
58/* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
0f113f3e 60 * ECDH support in OpenSSL originally developed by
e172d60d
BM
61 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
62 */
d02b48c6
RE
63
64#ifndef HEADER_X509_H
0f113f3e
MC
65# define HEADER_X509_H
66
67# include <openssl/e_os2.h>
68# include <openssl/symhacks.h>
a00ae6c4
RS
69# include <openssl/buffer.h>
70# include <openssl/evp.h>
71# include <openssl/bio.h>
0f113f3e
MC
72# include <openssl/stack.h>
73# include <openssl/asn1.h>
74# include <openssl/safestack.h>
75
76# ifndef OPENSSL_NO_EC
77# include <openssl/ec.h>
0f113f3e 78# include <openssl/ecdsa.h>
0f113f3e
MC
79# include <openssl/ecdh.h>
80# endif
81
82# ifdef OPENSSL_USE_DEPRECATED
83# ifndef OPENSSL_NO_RSA
84# include <openssl/rsa.h>
85# endif
86# ifndef OPENSSL_NO_DSA
87# include <openssl/dsa.h>
88# endif
89# ifndef OPENSSL_NO_DH
90# include <openssl/dh.h>
91# endif
92# endif
93
474e469b 94# include <openssl/sha.h>
0f113f3e 95# include <openssl/ossl_typ.h>
4b55c2a3 96
82271cee
RL
97#ifdef __cplusplus
98extern "C" {
99#endif
100
0f113f3e 101# ifdef OPENSSL_SYS_WIN32
f96d1af4 102/* Under Win32 these are defined in wincrypt.h */
0f113f3e 103# undef X509_NAME
0f113f3e
MC
104# undef X509_EXTENSIONS
105# endif
106
107# define X509_FILETYPE_PEM 1
108# define X509_FILETYPE_ASN1 2
109# define X509_FILETYPE_DEFAULT 3
110
111# define X509v3_KU_DIGITAL_SIGNATURE 0x0080
112# define X509v3_KU_NON_REPUDIATION 0x0040
113# define X509v3_KU_KEY_ENCIPHERMENT 0x0020
114# define X509v3_KU_DATA_ENCIPHERMENT 0x0010
115# define X509v3_KU_KEY_AGREEMENT 0x0008
116# define X509v3_KU_KEY_CERT_SIGN 0x0004
117# define X509v3_KU_CRL_SIGN 0x0002
118# define X509v3_KU_ENCIPHER_ONLY 0x0001
119# define X509v3_KU_DECIPHER_ONLY 0x8000
120# define X509v3_KU_UNDEF 0xffff
121
0f113f3e
MC
122struct X509_algor_st {
123 ASN1_OBJECT *algorithm;
124 ASN1_TYPE *parameter;
125} /* X509_ALGOR */ ;
d02b48c6 126
8931b30d
DSH
127typedef STACK_OF(X509_ALGOR) X509_ALGORS;
128
0f113f3e
MC
129typedef struct X509_val_st {
130 ASN1_TIME *notBefore;
131 ASN1_TIME *notAfter;
132} X509_VAL;
133
134struct X509_pubkey_st {
135 X509_ALGOR *algor;
136 ASN1_BIT_STRING *public_key;
137 EVP_PKEY *pkey;
138};
139
140typedef struct X509_sig_st {
141 X509_ALGOR *algor;
142 ASN1_OCTET_STRING *digest;
143} X509_SIG;
144
2743e38c 145typedef struct X509_name_entry_st X509_NAME_ENTRY;
d02b48c6 146
65d4927b 147DECLARE_STACK_OF(X509_NAME_ENTRY)
65d4927b 148
f73e07cf
BL
149DECLARE_STACK_OF(X509_NAME)
150
0f113f3e
MC
151# define X509_EX_V_NETSCAPE_HACK 0x8000
152# define X509_EX_V_INIT 0x0001
4903abd5 153typedef struct X509_extension_st X509_EXTENSION;
d02b48c6 154
67c8e7f4
DSH
155typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
156
0b3f827c 157DECLARE_STACK_OF(X509_EXTENSION)
0b3f827c 158
9b0a4531 159typedef struct x509_attributes_st X509_ATTRIBUTE;
d500de16
BL
160
161DECLARE_STACK_OF(X509_ATTRIBUTE)
d500de16 162
124055a9 163typedef struct X509_req_info_st X509_REQ_INFO;
0f113f3e 164
124055a9 165typedef struct X509_req_st X509_REQ;
0f113f3e 166
bc3686df 167typedef struct x509_cert_aux_st X509_CERT_AUX;
0f113f3e 168
2c81e476 169typedef struct x509_cinf_st X509_CINF;
d02b48c6 170
f73e07cf 171DECLARE_STACK_OF(X509)
f73e07cf 172
d4cec6a1
DSH
173/* This is used for a table of trust checking functions */
174
175typedef struct x509_trust_st {
0f113f3e
MC
176 int trust;
177 int flags;
178 int (*check_trust) (struct x509_trust_st *, X509 *, int);
179 char *name;
180 int arg1;
181 void *arg2;
d4cec6a1
DSH
182} X509_TRUST;
183
9868232a
DSH
184DECLARE_STACK_OF(X509_TRUST)
185
186/* standard trust ids */
d4cec6a1 187
0f113f3e 188# define X509_TRUST_DEFAULT -1/* Only valid in purpose settings */
068fdce8 189
0f113f3e
MC
190# define X509_TRUST_COMPAT 1
191# define X509_TRUST_SSL_CLIENT 2
192# define X509_TRUST_SSL_SERVER 3
193# define X509_TRUST_EMAIL 4
194# define X509_TRUST_OBJECT_SIGN 5
195# define X509_TRUST_OCSP_SIGN 6
196# define X509_TRUST_OCSP_REQUEST 7
197# define X509_TRUST_TSA 8
9868232a 198
dd413410 199/* Keep these up to date! */
0f113f3e
MC
200# define X509_TRUST_MIN 1
201# define X509_TRUST_MAX 8
dd413410 202
9868232a 203/* trust_flags values */
0f113f3e
MC
204# define X509_TRUST_DYNAMIC 1
205# define X509_TRUST_DYNAMIC_NAME 2
9868232a
DSH
206
207/* check_trust return codes */
208
0f113f3e
MC
209# define X509_TRUST_TRUSTED 1
210# define X509_TRUST_REJECTED 2
211# define X509_TRUST_UNTRUSTED 3
d4cec6a1 212
d0c98589
DSH
213/* Flags for X509_print_ex() */
214
0f113f3e
MC
215# define X509_FLAG_COMPAT 0
216# define X509_FLAG_NO_HEADER 1L
217# define X509_FLAG_NO_VERSION (1L << 1)
218# define X509_FLAG_NO_SERIAL (1L << 2)
219# define X509_FLAG_NO_SIGNAME (1L << 3)
220# define X509_FLAG_NO_ISSUER (1L << 4)
221# define X509_FLAG_NO_VALIDITY (1L << 5)
222# define X509_FLAG_NO_SUBJECT (1L << 6)
223# define X509_FLAG_NO_PUBKEY (1L << 7)
224# define X509_FLAG_NO_EXTENSIONS (1L << 8)
225# define X509_FLAG_NO_SIGDUMP (1L << 9)
226# define X509_FLAG_NO_AUX (1L << 10)
227# define X509_FLAG_NO_ATTRIBUTES (1L << 11)
228# define X509_FLAG_NO_IDS (1L << 12)
229
230/* Flags specific to X509_NAME_print_ex() */
a657546f
DSH
231
232/* The field separator information */
233
0f113f3e 234# define XN_FLAG_SEP_MASK (0xf << 16)
a657546f 235
b0700d2c 236# define XN_FLAG_COMPAT 0/* Traditional; use old X509_NAME_print */
0f113f3e
MC
237# define XN_FLAG_SEP_COMMA_PLUS (1 << 16)/* RFC2253 ,+ */
238# define XN_FLAG_SEP_CPLUS_SPC (2 << 16)/* ,+ spaced: more readable */
239# define XN_FLAG_SEP_SPLUS_SPC (3 << 16)/* ;+ spaced */
240# define XN_FLAG_SEP_MULTILINE (4 << 16)/* One line per field */
a657546f 241
0f113f3e 242# define XN_FLAG_DN_REV (1 << 20)/* Reverse DN order */
a657546f
DSH
243
244/* How the field name is shown */
245
0f113f3e 246# define XN_FLAG_FN_MASK (0x3 << 21)
a657546f 247
0f113f3e
MC
248# define XN_FLAG_FN_SN 0/* Object short name */
249# define XN_FLAG_FN_LN (1 << 21)/* Object long name */
250# define XN_FLAG_FN_OID (2 << 21)/* Always use OIDs */
251# define XN_FLAG_FN_NONE (3 << 21)/* No field names */
a657546f 252
0f113f3e 253# define XN_FLAG_SPC_EQ (1 << 23)/* Put spaces round '=' */
a657546f 254
0f113f3e
MC
255/*
256 * This determines if we dump fields we don't recognise: RFC2253 requires
257 * this.
a657546f
DSH
258 */
259
0f113f3e 260# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
a657546f 261
0f113f3e
MC
262# define XN_FLAG_FN_ALIGN (1 << 25)/* Align field names to 20
263 * characters */
535d79da 264
a657546f
DSH
265/* Complete set of RFC2253 flags */
266
0f113f3e
MC
267# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
268 XN_FLAG_SEP_COMMA_PLUS | \
269 XN_FLAG_DN_REV | \
270 XN_FLAG_FN_SN | \
271 XN_FLAG_DUMP_UNKNOWN_FIELDS)
a657546f
DSH
272
273/* readable oneline form */
274
0f113f3e
MC
275# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
276 ASN1_STRFLGS_ESC_QUOTE | \
277 XN_FLAG_SEP_CPLUS_SPC | \
278 XN_FLAG_SPC_EQ | \
279 XN_FLAG_FN_SN)
a657546f
DSH
280
281/* readable multiline form */
282
0f113f3e
MC
283# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
284 ASN1_STRFLGS_ESC_MSB | \
285 XN_FLAG_SEP_MULTILINE | \
286 XN_FLAG_SPC_EQ | \
287 XN_FLAG_FN_LN | \
288 XN_FLAG_FN_ALIGN)
289
ee8ba0b2 290DECLARE_STACK_OF(X509_REVOKED)
ee8ba0b2 291
e3e57192 292typedef struct X509_crl_info_st X509_CRL_INFO;
d02b48c6 293
6d114240 294DECLARE_STACK_OF(X509_CRL)
6d114240 295
0f113f3e
MC
296typedef struct private_key_st {
297 int version;
298 /* The PKCS#8 data types */
299 X509_ALGOR *enc_algor;
300 ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
301 /* When decrypted, the following will not be NULL */
302 EVP_PKEY *dec_pkey;
303 /* used to encrypt and decrypt */
304 int key_length;
305 char *key_data;
306 int key_free; /* true if we should auto free key_data */
307 /* expanded version of 'enc_algor' */
308 EVP_CIPHER_INFO cipher;
309 int references;
310} X509_PKEY;
311
0f113f3e
MC
312typedef struct X509_info_st {
313 X509 *x509;
314 X509_CRL *crl;
315 X509_PKEY *x_pkey;
316 EVP_CIPHER_INFO enc_cipher;
317 int enc_len;
318 char *enc_data;
319 int references;
320} X509_INFO;
20b85fdd
RE
321
322DECLARE_STACK_OF(X509_INFO)
d02b48c6 323
0f113f3e
MC
324/*
325 * The next 2 structures and their 8 routines were sent to me by Pat Richard
326 * <patr@x509.com> and are used to manipulate Netscapes spki structures -
327 * useful if you are writing a CA web page
d02b48c6 328 */
0f113f3e
MC
329typedef struct Netscape_spkac_st {
330 X509_PUBKEY *pubkey;
331 ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */
332} NETSCAPE_SPKAC;
333
334typedef struct Netscape_spki_st {
335 NETSCAPE_SPKAC *spkac; /* signed public key and challenge */
6e63c142 336 X509_ALGOR sig_algor;
0f113f3e
MC
337 ASN1_BIT_STRING *signature;
338} NETSCAPE_SPKI;
d02b48c6 339
92c046ca 340/* Netscape certificate sequence structure */
0f113f3e
MC
341typedef struct Netscape_certificate_sequence {
342 ASN1_OBJECT *type;
343 STACK_OF(X509) *certs;
344} NETSCAPE_CERT_SEQUENCE;
92c046ca 345
1d97c843 346/*- Unused (and iv length is wrong)
d02b48c6 347typedef struct CBCParameter_st
0f113f3e
MC
348 {
349 unsigned char iv[8];
350 } CBC_PARAM;
54a656ef 351*/
d02b48c6 352
cfcefcbe
DSH
353/* Password based encryption structure */
354
355typedef struct PBEPARAM_st {
0f113f3e
MC
356 ASN1_OCTET_STRING *salt;
357 ASN1_INTEGER *iter;
cfcefcbe
DSH
358} PBEPARAM;
359
d2e26dcc
DSH
360/* Password based encryption V2 structures */
361
362typedef struct PBE2PARAM_st {
0f113f3e
MC
363 X509_ALGOR *keyfunc;
364 X509_ALGOR *encryption;
d2e26dcc
DSH
365} PBE2PARAM;
366
367typedef struct PBKDF2PARAM_st {
68d39f3c 368/* Usually OCTET STRING but could be anything */
0f113f3e
MC
369 ASN1_TYPE *salt;
370 ASN1_INTEGER *iter;
371 ASN1_INTEGER *keylength;
372 X509_ALGOR *prf;
d2e26dcc
DSH
373} PBKDF2PARAM;
374
cfcefcbe
DSH
375/* PKCS#8 private key info structure */
376
0f113f3e
MC
377struct pkcs8_priv_key_info_st {
378 /* Flag for various broken formats */
379 int broken;
380# define PKCS8_OK 0
381# define PKCS8_NO_OCTET 1
382# define PKCS8_EMBEDDED_PARAM 2
383# define PKCS8_NS_DB 3
384# define PKCS8_NEG_PRIVKEY 4
385 ASN1_INTEGER *version;
386 X509_ALGOR *pkeyalg;
387 /* Should be OCTET STRING but some are broken */
388 ASN1_TYPE *pkey;
389 STACK_OF(X509_ATTRIBUTE) *attributes;
390};
cfcefcbe 391
82271cee
RL
392#ifdef __cplusplus
393}
394#endif
395
0f113f3e
MC
396# include <openssl/x509_vfy.h>
397# include <openssl/pkcs7.h>
d02b48c6 398
82271cee
RL
399#ifdef __cplusplus
400extern "C" {
401#endif
402
0f113f3e
MC
403# define X509_EXT_PACK_UNKNOWN 1
404# define X509_EXT_PACK_STRING 2
405
0f113f3e 406# define X509_extract_key(x) X509_get_pubkey(x)/*****/
0f113f3e
MC
407# define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
408# define X509_name_cmp(a,b) X509_NAME_cmp((a),(b))
0f113f3e 409
f4c630ab 410void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
0f113f3e
MC
411X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
412 int (*crl_free) (X509_CRL *crl),
413 int (*crl_lookup) (X509_CRL *crl,
414 X509_REVOKED **ret,
415 ASN1_INTEGER *ser,
416 X509_NAME *issuer),
417 int (*crl_verify) (X509_CRL *crl,
418 EVP_PKEY *pk));
f4c630ab
DSH
419void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
420
421void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
422void *X509_CRL_get_meth_data(X509_CRL *crl);
423
16bc9fea
BM
424const char *X509_verify_cert_error_string(long n);
425
d02b48c6 426int X509_verify(X509 *a, EVP_PKEY *r);
d02b48c6
RE
427
428int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
429int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
430int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
431
0f113f3e
MC
432NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);
433char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
8ce97163
DSH
434EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
435int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
436
437int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
438
0f113f3e
MC
439int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
440int X509_signature_print(BIO *bp, X509_ALGOR *alg, ASN1_STRING *sig);
de487514 441
e778802f 442int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
8d207ee3 443int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
f4042781 444int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);
e778802f 445int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
8d207ee3 446int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
e778802f 447int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
8d207ee3 448int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
6f9076ff 449int X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);
e778802f 450int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
d02b48c6 451
0f113f3e
MC
452int X509_pubkey_digest(const X509 *data, const EVP_MD *type,
453 unsigned char *md, unsigned int *len);
454int X509_digest(const X509 *data, const EVP_MD *type,
455 unsigned char *md, unsigned int *len);
456int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
457 unsigned char *md, unsigned int *len);
458int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,
459 unsigned char *md, unsigned int *len);
460int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,
461 unsigned char *md, unsigned int *len);
0f113f3e
MC
462
463# ifndef OPENSSL_NO_STDIO
31a352d1 464X509 *d2i_X509_fp(FILE *fp, X509 **x509);
0f113f3e
MC
465int i2d_X509_fp(FILE *fp, X509 *x509);
466X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);
467int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);
468X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);
469int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);
470# ifndef OPENSSL_NO_RSA
471RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);
472int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);
473RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);
474int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);
475RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);
476int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);
477# endif
478# ifndef OPENSSL_NO_DSA
52664f50
DSH
479DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
480int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
31a352d1 481DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
f5d7a031 482int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
0f113f3e
MC
483# endif
484# ifndef OPENSSL_NO_EC
14a7cfb3 485EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
0f113f3e 486int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
14a7cfb3 487EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
0f113f3e
MC
488int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
489# endif
490X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);
491int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);
3cbb7937 492PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
0f113f3e
MC
493 PKCS8_PRIV_KEY_INFO **p8inf);
494int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);
36217a94 495int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
e6f3c585 496int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
20432eae 497EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
bd08a2bd
DSH
498int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
499EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
0f113f3e
MC
500# endif
501
0f113f3e
MC
502X509 *d2i_X509_bio(BIO *bp, X509 **x509);
503int i2d_X509_bio(BIO *bp, X509 *x509);
504X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);
505int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);
506X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);
507int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);
508# ifndef OPENSSL_NO_RSA
509RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);
510int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);
511RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);
512int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);
513RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);
514int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);
515# endif
516# ifndef OPENSSL_NO_DSA
52664f50
DSH
517DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
518int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
31a352d1 519DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
f5d7a031 520int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
0f113f3e
MC
521# endif
522# ifndef OPENSSL_NO_EC
14a7cfb3 523EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
0f113f3e 524int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
14a7cfb3 525EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
0f113f3e
MC
526int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
527# endif
528X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);
529int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);
3cbb7937 530PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
0f113f3e
MC
531 PKCS8_PRIV_KEY_INFO **p8inf);
532int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);
36217a94 533int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
e6f3c585 534int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
20432eae 535EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
bd08a2bd
DSH
536int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
537EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
d02b48c6
RE
538
539X509 *X509_dup(X509 *x509);
dfeab068 540X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
d02b48c6
RE
541X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
542X509_CRL *X509_CRL_dup(X509_CRL *crl);
2e8cb108 543X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);
d02b48c6 544X509_REQ *X509_REQ_dup(X509_REQ *req);
dfeab068 545X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
0f113f3e
MC
546int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,
547 void *pval);
448be743 548void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
0f113f3e 549 X509_ALGOR *algor);
ce25c720 550void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
4c52816d 551int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
448be743 552
d02b48c6
RE
553X509_NAME *X509_NAME_dup(X509_NAME *xn);
554X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
d02b48c6 555
0f113f3e
MC
556int X509_cmp_time(const ASN1_TIME *s, time_t *t);
557int X509_cmp_current_time(const ASN1_TIME *s);
558ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
559ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
560 int offset_day, long offset_sec, time_t *t);
561ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
d02b48c6 562
0f113f3e
MC
563const char *X509_get_default_cert_area(void);
564const char *X509_get_default_cert_dir(void);
565const char *X509_get_default_cert_file(void);
566const char *X509_get_default_cert_dir_env(void);
567const char *X509_get_default_cert_file_env(void);
568const char *X509_get_default_private_dir(void);
d02b48c6 569
0f113f3e
MC
570X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
571X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
d02b48c6 572
9d6b1ce6 573DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
8931b30d 574DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
9d6b1ce6 575DECLARE_ASN1_FUNCTIONS(X509_VAL)
d02b48c6 576
9d6b1ce6 577DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
d02b48c6 578
0f113f3e
MC
579int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
580EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);
581int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);
582int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);
583EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);
584# ifndef OPENSSL_NO_RSA
585int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);
586RSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);
587# endif
588# ifndef OPENSSL_NO_DSA
589int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);
590DSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);
591# endif
592# ifndef OPENSSL_NO_EC
593int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
594EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);
595# endif
d02b48c6 596
9d6b1ce6
DSH
597DECLARE_ASN1_FUNCTIONS(X509_SIG)
598DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
599DECLARE_ASN1_FUNCTIONS(X509_REQ)
d02b48c6 600
9d6b1ce6 601DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
c8b41850 602X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
dfeab068 603
9d6b1ce6 604DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
67c8e7f4 605DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)
d02b48c6 606
9d6b1ce6 607DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
d02b48c6 608
9d6b1ce6 609DECLARE_ASN1_FUNCTIONS(X509_NAME)
d02b48c6 610
0f113f3e 611int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
d02b48c6 612
9d6b1ce6 613DECLARE_ASN1_FUNCTIONS(X509_CINF)
d02b48c6 614
9d6b1ce6
DSH
615DECLARE_ASN1_FUNCTIONS(X509)
616DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
d02b48c6 617
e6390aca
RS
618#define X509_new_index(l, p, newf, dupf, freef) \
619 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)
dd9d233e
DSH
620int X509_set_ex_data(X509 *r, int idx, void *arg);
621void *X509_get_ex_data(X509 *r, int idx);
0f113f3e
MC
622int i2d_X509_AUX(X509 *a, unsigned char **pp);
623X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);
ce1b4fe1 624
95b1752c
EK
625int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
626
6e63c142 627void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509 *x);
dfcf48f4
DSH
628int X509_get_signature_nid(const X509 *x);
629
748118a8 630int X509_trusted(const X509 *x);
6d0d5431 631int X509_alias_set1(X509 *x, unsigned char *name, int len);
84b65340 632int X509_keyid_set1(X509 *x, unsigned char *id, int len);
0f113f3e
MC
633unsigned char *X509_alias_get0(X509 *x, int *len);
634unsigned char *X509_keyid_get0(X509 *x, int *len);
635int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,
636 int);
926a56bf 637int X509_TRUST_set(int *t, int trust);
c7cb16a8
DSH
638int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
639int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
6447cce3
DSH
640void X509_trust_clear(X509 *x);
641void X509_reject_clear(X509 *x);
d02b48c6 642
748118a8
DSH
643STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x);
644STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x);
645
9d6b1ce6
DSH
646DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
647DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
648DECLARE_ASN1_FUNCTIONS(X509_CRL)
d02b48c6 649
9d6b1ce6 650int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
010fa0b3 651int X509_CRL_get0_by_serial(X509_CRL *crl,
0f113f3e 652 X509_REVOKED **ret, ASN1_INTEGER *serial);
d0fff69d 653int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
d02b48c6 654
0f113f3e
MC
655X509_PKEY *X509_PKEY_new(void);
656void X509_PKEY_free(X509_PKEY *a);
d02b48c6 657
9d6b1ce6
DSH
658DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
659DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
660DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
92c046ca 661
0f113f3e
MC
662X509_INFO *X509_INFO_new(void);
663void X509_INFO_free(X509_INFO *a);
664char *X509_NAME_oneline(X509_NAME *a, char *buf, int size);
d02b48c6 665
8bb826ee 666int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
0f113f3e 667 ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);
d02b48c6 668
0f113f3e
MC
669int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
670 unsigned char *md, unsigned int *len);
d02b48c6 671
8bb826ee 672int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
0f113f3e
MC
673 X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
674 char *data, EVP_PKEY *pkey, const EVP_MD *type);
09ab755c 675
0f113f3e
MC
676int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,
677 unsigned char *md, unsigned int *len);
09ab755c
DSH
678
679int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
0f113f3e
MC
680 ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);
681
682int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,
683 X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,
684 EVP_PKEY *pkey, const EVP_MD *type);
685int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
686 X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
687 void *asn, EVP_MD_CTX *ctx);
0f113f3e 688
f728254a 689long X509_get_version(X509 *x);
0f113f3e
MC
690int X509_set_version(X509 *x, long version);
691int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
692ASN1_INTEGER *X509_get_serialNumber(X509 *x);
693int X509_set_issuer_name(X509 *x, X509_NAME *name);
694X509_NAME *X509_get_issuer_name(X509 *a);
695int X509_set_subject_name(X509 *x, X509_NAME *name);
696X509_NAME *X509_get_subject_name(X509 *a);
f728254a 697ASN1_TIME * X509_get_notBefore(X509 *x);
0f113f3e 698int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
f728254a 699ASN1_TIME *X509_get_notAfter(X509 *x);
0f113f3e
MC
700int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
701int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
05f0fb9f 702void X509_up_ref(X509 *x);
f728254a
DSH
703int X509_get_signature_type(const X509 *x);
704/*
705 * This one is only used so that a binary form can output, as in
706 * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf)
707 */
708X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
748118a8
DSH
709STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
710void X509_get0_uids(ASN1_BIT_STRING **piuid, ASN1_BIT_STRING **psuid, X509 *x);
711X509_ALGOR *X509_get0_tbs_sigalg(X509 *x);
f728254a 712
0f113f3e
MC
713EVP_PKEY *X509_get_pubkey(X509 *x);
714ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
715int X509_certificate_type(X509 *x, EVP_PKEY *pubkey /* optional */ );
716
124055a9 717long X509_REQ_get_version(X509_REQ *req);
0f113f3e 718int X509_REQ_set_version(X509_REQ *x, long version);
124055a9 719X509_NAME *X509_REQ_get_subject_name(X509_REQ *req);
0f113f3e 720int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
a9732d04
DSH
721void X509_REQ_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
722 X509_REQ *req);
723int X509_REQ_get_signature_nid(const X509_REQ *req);
724int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
0f113f3e
MC
725int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
726EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
1f143e08 727X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);
0f113f3e
MC
728int X509_REQ_extension_nid(int nid);
729int *X509_REQ_get_extension_nids(void);
730void X509_REQ_set_extension_nids(int *nids);
87c49f62 731STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
fd520577 732int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
0f113f3e 733 int nid);
fd520577 734int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
6e6bc352 735int X509_REQ_get_attr_count(const X509_REQ *req);
0f113f3e 736int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
6e6bc352 737int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
0f113f3e 738 int lastpos);
6e6bc352
DSH
739X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
740X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
c7cb16a8
DSH
741int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
742int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
0f113f3e
MC
743 const ASN1_OBJECT *obj, int type,
744 const unsigned char *bytes, int len);
c7cb16a8 745int X509_REQ_add1_attr_by_NID(X509_REQ *req,
0f113f3e
MC
746 int nid, int type,
747 const unsigned char *bytes, int len);
c7cb16a8 748int X509_REQ_add1_attr_by_txt(X509_REQ *req,
0f113f3e
MC
749 const char *attrname, int type,
750 const unsigned char *bytes, int len);
d02b48c6 751
35bf3541
DSH
752int X509_CRL_set_version(X509_CRL *x, long version);
753int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
91b73acb
NL
754int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
755int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
35bf3541 756int X509_CRL_sort(X509_CRL *crl);
65cbf983 757void X509_CRL_up_ref(X509_CRL *crl);
35bf3541 758
e3e57192
DSH
759long X509_CRL_get_version(X509_CRL *crl);
760ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl);
761ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
762X509_NAME *X509_CRL_get_issuer(X509_CRL *crl);
835911b8 763STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(X509_CRL *crl);
e3e57192
DSH
764STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
765void X509_CRL_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
6e63c142 766 X509_CRL *crl);
a9732d04
DSH
767int X509_CRL_get_signature_nid(const X509_CRL *crl);
768int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
e3e57192 769
dc29030a 770ASN1_INTEGER *X509_REVOKED_get0_serialNumber(X509_REVOKED *x);
35bf3541 771int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
dc29030a 772ASN1_TIME *X509_REVOKED_get0_revocationDate(X509_REVOKED *x);
35bf3541 773int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
835911b8 774STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(X509_REVOKED *r);
35bf3541 775
2e8cb108 776X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
0f113f3e 777 EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);
2e8cb108 778
0f113f3e 779int X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);
e6526fbf 780
0f113f3e
MC
781int X509_check_private_key(X509 *x509, EVP_PKEY *pkey);
782int X509_chain_check_suiteb(int *perror_depth,
783 X509 *x, STACK_OF(X509) *chain,
784 unsigned long flags);
785int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);
3b0648eb 786STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
d02b48c6 787
0f113f3e
MC
788int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
789unsigned long X509_issuer_and_serial_hash(X509 *a);
790
791int X509_issuer_name_cmp(const X509 *a, const X509 *b);
792unsigned long X509_issuer_name_hash(X509 *a);
793
794int X509_subject_name_cmp(const X509 *a, const X509 *b);
795unsigned long X509_subject_name_hash(X509 *x);
796
797# ifndef OPENSSL_NO_MD5
798unsigned long X509_issuer_name_hash_old(X509 *a);
799unsigned long X509_subject_name_hash_old(X509 *x);
800# endif
801
802int X509_cmp(const X509 *a, const X509 *b);
803int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
804unsigned long X509_NAME_hash(X509_NAME *x);
805unsigned long X509_NAME_hash_old(X509_NAME *x);
806
807int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
808int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
809# ifndef OPENSSL_NO_STDIO
810int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,
811 unsigned long cflag);
812int X509_print_fp(FILE *bp, X509 *x);
699f1635 813int X509_aux_print(BIO *out, X509 *x, int indent);
0f113f3e
MC
814int X509_CRL_print_fp(FILE *bp, X509_CRL *x);
815int X509_REQ_print_fp(FILE *bp, X509_REQ *req);
816int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent,
817 unsigned long flags);
818# endif
819
0f113f3e
MC
820int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
821int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent,
822 unsigned long flags);
823int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,
824 unsigned long cflag);
825int X509_print(BIO *bp, X509 *x);
826int X509_ocspid_print(BIO *bp, X509 *x);
0f113f3e
MC
827int X509_CRL_print(BIO *bp, X509_CRL *x);
828int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,
829 unsigned long cflag);
830int X509_REQ_print(BIO *bp, X509_REQ *req);
0f113f3e
MC
831
832int X509_NAME_entry_count(X509_NAME *name);
833int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);
834int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
835 char *buf, int len);
836
837/*
838 * NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
839 * lastpos, search after that position on.
840 */
841int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);
842int X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
843 int lastpos);
d02b48c6
RE
844X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
845X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
0f113f3e
MC
846int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne,
847 int loc, int set);
74400f73 848int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
0f113f3e
MC
849 unsigned char *bytes, int len, int loc,
850 int set);
74400f73 851int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
0f113f3e
MC
852 unsigned char *bytes, int len, int loc,
853 int set);
74400f73 854X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
0f113f3e
MC
855 const char *field, int type,
856 const unsigned char *bytes,
857 int len);
d02b48c6 858X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
0f113f3e
MC
859 int type, unsigned char *bytes,
860 int len);
0821bcd4 861int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
0f113f3e
MC
862 const unsigned char *bytes, int len, int loc,
863 int set);
d02b48c6 864X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
0f113f3e
MC
865 ASN1_OBJECT *obj, int type,
866 const unsigned char *bytes,
867 int len);
868int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);
869int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
870 const unsigned char *bytes, int len);
871ASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
872ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
2743e38c 873int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
0f113f3e
MC
874
875int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
876int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
877 int nid, int lastpos);
878int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
879 ASN1_OBJECT *obj, int lastpos);
880int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
881 int crit, int lastpos);
0b3f827c
BL
882X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
883X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
884STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
0f113f3e 885 X509_EXTENSION *ex, int loc);
58964a49 886
0f113f3e
MC
887int X509_get_ext_count(X509 *x);
888int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
889int X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos);
890int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
d02b48c6
RE
891X509_EXTENSION *X509_get_ext(X509 *x, int loc);
892X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
0f113f3e
MC
893int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
894void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
895int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
896 unsigned long flags);
897
898int X509_CRL_get_ext_count(X509_CRL *x);
899int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
900int X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos);
901int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
d02b48c6
RE
902X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
903X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
0f113f3e
MC
904int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
905void *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
906int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
907 unsigned long flags);
908
909int X509_REVOKED_get_ext_count(X509_REVOKED *x);
910int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
911int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj,
912 int lastpos);
913int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
d02b48c6
RE
914X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
915X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
0f113f3e
MC
916int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
917void *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
918int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
919 unsigned long flags);
d02b48c6
RE
920
921X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
0f113f3e
MC
922 int nid, int crit,
923 ASN1_OCTET_STRING *data);
d02b48c6 924X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
0f113f3e
MC
925 ASN1_OBJECT *obj, int crit,
926 ASN1_OCTET_STRING *data);
927int X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj);
928int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
929int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);
930ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);
d02b48c6 931ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
0f113f3e 932int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
d02b48c6 933
77b47b90
DSH
934int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
935int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
0f113f3e
MC
936 int lastpos);
937int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
938 ASN1_OBJECT *obj, int lastpos);
77b47b90
DSH
939X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
940X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
c7cb16a8 941STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
0f113f3e
MC
942 X509_ATTRIBUTE *attr);
943STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
944 **x, const ASN1_OBJECT *obj,
945 int type,
946 const unsigned char *bytes,
947 int len);
948STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)
949 **x, int nid, int type,
950 const unsigned char *bytes,
951 int len);
952STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)
953 **x, const char *attrname,
954 int type,
955 const unsigned char *bytes,
956 int len);
957void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj,
958 int lastpos, int type);
b38f9f66 959X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
0f113f3e
MC
960 int atrtype, const void *data,
961 int len);
b38f9f66 962X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
0f113f3e
MC
963 const ASN1_OBJECT *obj,
964 int atrtype, const void *data,
965 int len);
77b47b90 966X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
0f113f3e
MC
967 const char *atrname, int type,
968 const unsigned char *bytes,
969 int len);
f2a253e0 970int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
0f113f3e
MC
971int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
972 const void *data, int len);
973void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,
974 void *data);
35f4850a 975int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
c7cb16a8
DSH
976ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
977ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
b38f9f66 978
b6995add 979int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
0f113f3e 980int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
b6995add 981int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
0f113f3e 982 int lastpos);
b6995add
DSH
983X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
984X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
985int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
986int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
0f113f3e
MC
987 const ASN1_OBJECT *obj, int type,
988 const unsigned char *bytes, int len);
b6995add 989int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
0f113f3e
MC
990 int nid, int type,
991 const unsigned char *bytes, int len);
b6995add 992int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
0f113f3e
MC
993 const char *attrname, int type,
994 const unsigned char *bytes, int len);
b6995add 995
0f113f3e 996int X509_verify_cert(X509_STORE_CTX *ctx);
d02b48c6
RE
997
998/* lookup a cert from a X509 STACK */
0f113f3e
MC
999X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
1000 ASN1_INTEGER *serial);
1001X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);
d02b48c6 1002
9d6b1ce6
DSH
1003DECLARE_ASN1_FUNCTIONS(PBEPARAM)
1004DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
1005DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
1006
8931b30d 1007int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
0f113f3e 1008 const unsigned char *salt, int saltlen);
8931b30d
DSH
1009
1010X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
0f113f3e 1011 const unsigned char *salt, int saltlen);
8eb57af5 1012X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
0f113f3e 1013 unsigned char *salt, int saltlen);
ae519a24 1014X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
0f113f3e
MC
1015 unsigned char *salt, int saltlen,
1016 unsigned char *aiv, int prf_nid);
cfcefcbe 1017
b0809bc8 1018#ifndef OPENSSL_NO_SCRYPT
e98aa30d
DSH
1019X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,
1020 const unsigned char *salt, int saltlen,
1021 unsigned char *aiv, uint64_t N, uint64_t r,
1022 uint64_t p);
b0809bc8 1023#endif
e98aa30d 1024
007f7ec1 1025X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
0f113f3e 1026 int prf_nid, int keylen);
007f7ec1 1027
cfcefcbe
DSH
1028/* PKCS#8 utilities */
1029
9d6b1ce6 1030DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
cfcefcbe
DSH
1031
1032EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
1033PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
66430207 1034PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
cfcefcbe
DSH
1035PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
1036
448be743 1037int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
0f113f3e
MC
1038 int version, int ptype, void *pval,
1039 unsigned char *penc, int penclen);
448be743 1040int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
0f113f3e
MC
1041 const unsigned char **pk, int *ppklen,
1042 X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);
448be743
DSH
1043
1044int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
0f113f3e
MC
1045 int ptype, void *pval,
1046 unsigned char *penc, int penclen);
448be743 1047int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
0f113f3e
MC
1048 const unsigned char **pk, int *ppklen,
1049 X509_ALGOR **pa, X509_PUBKEY *pub);
448be743 1050
9868232a
DSH
1051int X509_check_trust(X509 *x, int id, int flags);
1052int X509_TRUST_get_count(void);
0f113f3e 1053X509_TRUST *X509_TRUST_get0(int idx);
9868232a 1054int X509_TRUST_get_by_id(int id);
0f113f3e
MC
1055int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
1056 char *name, int arg1, void *arg2);
9868232a 1057void X509_TRUST_cleanup(void);
dd413410 1058int X509_TRUST_get_flags(X509_TRUST *xp);
c7cb16a8 1059char *X509_TRUST_get0_name(X509_TRUST *xp);
9868232a
DSH
1060int X509_TRUST_get_trust(X509_TRUST *xp);
1061
d02b48c6 1062/* BEGIN ERROR CODES */
0f113f3e
MC
1063/*
1064 * The following lines are auto generated by the script mkerr.pl. Any changes
6d311938
DSH
1065 * made after this point may be overwritten when the script is next run.
1066 */
926a56bf 1067void ERR_load_X509_strings(void);
6d311938 1068
d02b48c6
RE
1069/* Error codes for the X509 functions. */
1070
1071/* Function codes. */
0f113f3e
MC
1072# define X509_F_ADD_CERT_DIR 100
1073# define X509_F_BY_FILE_CTRL 101
1074# define X509_F_CHECK_POLICY 145
1075# define X509_F_DIR_CTRL 102
1076# define X509_F_GET_CERT_BY_SUBJECT 103
1077# define X509_F_NETSCAPE_SPKI_B64_DECODE 129
1078# define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
1079# define X509_F_X509AT_ADD1_ATTR 135
1080# define X509_F_X509V3_ADD_EXT 104
1081# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
1082# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
1083# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
1084# define X509_F_X509_ATTRIBUTE_GET0_DATA 139
1085# define X509_F_X509_ATTRIBUTE_SET1_DATA 138
1086# define X509_F_X509_CHECK_PRIVATE_KEY 128
1087# define X509_F_X509_CRL_DIFF 105
1088# define X509_F_X509_CRL_PRINT_FP 147
1089# define X509_F_X509_EXTENSION_CREATE_BY_NID 108
1090# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
1091# define X509_F_X509_GET_PUBKEY_PARAMETERS 110
1092# define X509_F_X509_LOAD_CERT_CRL_FILE 132
1093# define X509_F_X509_LOAD_CERT_FILE 111
1094# define X509_F_X509_LOAD_CRL_FILE 112
1095# define X509_F_X509_NAME_ADD_ENTRY 113
1096# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
1097# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
1098# define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
1099# define X509_F_X509_NAME_ONELINE 116
1100# define X509_F_X509_NAME_PRINT 117
1101# define X509_F_X509_PRINT_EX_FP 118
1102# define X509_F_X509_PUBKEY_GET 119
1103# define X509_F_X509_PUBKEY_SET 120
1104# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144
1105# define X509_F_X509_REQ_PRINT_EX 121
1106# define X509_F_X509_REQ_PRINT_FP 122
1107# define X509_F_X509_REQ_TO_X509 123
1108# define X509_F_X509_STORE_ADD_CERT 124
1109# define X509_F_X509_STORE_ADD_CRL 125
1110# define X509_F_X509_STORE_CTX_GET1_ISSUER 146
1111# define X509_F_X509_STORE_CTX_INIT 143
1112# define X509_F_X509_STORE_CTX_NEW 142
1113# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
1114# define X509_F_X509_TO_X509_REQ 126
1115# define X509_F_X509_TRUST_ADD 133
1116# define X509_F_X509_TRUST_SET 141
1117# define X509_F_X509_VERIFY_CERT 127
d02b48c6
RE
1118
1119/* Reason codes. */
0f113f3e
MC
1120# define X509_R_AKID_MISMATCH 110
1121# define X509_R_BAD_X509_FILETYPE 100
1122# define X509_R_BASE64_DECODE_ERROR 118
1123# define X509_R_CANT_CHECK_DH_KEY 114
1124# define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
1125# define X509_R_CRL_ALREADY_DELTA 127
1126# define X509_R_CRL_VERIFY_FAILURE 131
1127# define X509_R_ERR_ASN1_LIB 102
1128# define X509_R_IDP_MISMATCH 128
1129# define X509_R_INVALID_DIRECTORY 113
1130# define X509_R_INVALID_FIELD_NAME 119
1131# define X509_R_INVALID_TRUST 123
1132# define X509_R_ISSUER_MISMATCH 129
1133# define X509_R_KEY_TYPE_MISMATCH 115
1134# define X509_R_KEY_VALUES_MISMATCH 116
1135# define X509_R_LOADING_CERT_DIR 103
1136# define X509_R_LOADING_DEFAULTS 104
1137# define X509_R_METHOD_NOT_SUPPORTED 124
1138# define X509_R_NEWER_CRL_NOT_NEWER 132
1139# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
1140# define X509_R_NO_CRL_NUMBER 130
1141# define X509_R_PUBLIC_KEY_DECODE_ERROR 125
1142# define X509_R_PUBLIC_KEY_ENCODE_ERROR 126
1143# define X509_R_SHOULD_RETRY 106
1144# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
1145# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
1146# define X509_R_UNKNOWN_KEY_TYPE 117
1147# define X509_R_UNKNOWN_NID 109
1148# define X509_R_UNKNOWN_PURPOSE_ID 121
1149# define X509_R_UNKNOWN_TRUST_ID 120
1150# define X509_R_UNSUPPORTED_ALGORITHM 111
1151# define X509_R_WRONG_LOOKUP_TYPE 112
1152# define X509_R_WRONG_TYPE 122
6d311938 1153
d02b48c6
RE
1154#ifdef __cplusplus
1155}
1156#endif
1157#endif