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