x509.h

Go to the documentation of this file.
00001 /* crypto/x509/x509.h */
00002 /* Copyright (C) 1995-1998 Eric Young ([email protected])
00003  * All rights reserved.
00004  *
00005  * This package is an SSL implementation written
00006  * by Eric Young ([email protected]).
00007  * The implementation was written so as to conform with Netscapes SSL.
00008  * 
00009  * This library is free for commercial and non-commercial use as long as
00010  * the following conditions are aheared to.  The following conditions
00011  * apply to all code found in this distribution, be it the RC4, RSA,
00012  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
00013  * included with this distribution is covered by the same copyright terms
00014  * except that the holder is Tim Hudson ([email protected]).
00015  * 
00016  * Copyright remains Eric Young's, and as such any Copyright notices in
00017  * the code are not to be removed.
00018  * If this package is used in a product, Eric Young should be given attribution
00019  * as the author of the parts of the library used.
00020  * This can be in the form of a textual message at program startup or
00021  * in documentation (online or textual) provided with the package.
00022  * 
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions
00025  * are met:
00026  * 1. Redistributions of source code must retain the copyright
00027  *    notice, this list of conditions and the following disclaimer.
00028  * 2. Redistributions in binary form must reproduce the above copyright
00029  *    notice, this list of conditions and the following disclaimer in the
00030  *    documentation and/or other materials provided with the distribution.
00031  * 3. All advertising materials mentioning features or use of this software
00032  *    must display the following acknowledgement:
00033  *    "This product includes cryptographic software written by
00034  *     Eric Young ([email protected])"
00035  *    The word 'cryptographic' can be left out if the rouines from the library
00036  *    being used are not cryptographic related :-).
00037  * 4. If you include any Windows specific code (or a derivative thereof) from 
00038  *    the apps directory (application code) you must include an acknowledgement:
00039  *    "This product includes software written by Tim Hudson ([email protected])"
00040  * 
00041  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
00042  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00044  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00045  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00047  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00048  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00049  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00050  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00051  * SUCH DAMAGE.
00052  * 
00053  * The licence and distribution terms for any publically available version or
00054  * derivative of this code cannot be changed.  i.e. this code cannot simply be
00055  * copied and put under another distribution licence
00056  * [including the GNU Public Licence.]
00057  */
00058 /* ====================================================================
00059  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
00060  * ECDH support in OpenSSL originally developed by 
00061  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
00062  */
00063 /*
00064  © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00065  */
00066 
00067 #ifndef HEADER_X509_H
00068 #define HEADER_X509_H
00069 
00070 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00071 #define SYMBIAN
00072 #endif
00073 
00074 #ifdef SYMBIAN
00075 #include <e32def.h>
00076 #endif
00077 #include <openssl/e_os2.h>
00078 #include <openssl/symhacks.h>
00079 #ifndef OPENSSL_NO_BUFFER
00080 #include <openssl/buffer.h>
00081 #endif
00082 #ifndef OPENSSL_NO_EVP
00083 #include <openssl/evp.h>
00084 #endif
00085 #ifndef OPENSSL_NO_BIO
00086 #include <openssl/bio.h>
00087 #endif
00088 #include <openssl/stack.h>
00089 #include <openssl/asn1.h>
00090 #include <openssl/safestack.h>
00091 
00092 #ifndef OPENSSL_NO_EC
00093 #include <openssl/ec.h>
00094 #endif
00095 
00096 #ifndef OPENSSL_NO_ECDSA
00097 #include <openssl/ecdsa.h>
00098 #endif
00099 
00100 #ifndef OPENSSL_NO_ECDH
00101 #include <openssl/ecdh.h>
00102 #endif
00103 
00104 #ifndef OPENSSL_NO_DEPRECATED
00105 #ifndef OPENSSL_NO_RSA
00106 #include <openssl/rsa.h>
00107 #endif
00108 #ifndef OPENSSL_NO_DSA
00109 #include <openssl/dsa.h>
00110 #endif
00111 #ifndef OPENSSL_NO_DH
00112 #include <openssl/dh.h>
00113 #endif
00114 #endif
00115 
00116 #ifndef OPENSSL_NO_SHA
00117 #include <openssl/sha.h>
00118 #endif
00119 #include <openssl/ossl_typ.h>
00120 
00121 #ifdef  __cplusplus
00122 extern "C" {
00123 #endif
00124 
00125 #ifdef OPENSSL_SYS_WIN32
00126 /* Under Win32 these are defined in wincrypt.h */
00127 #undef X509_NAME
00128 #undef X509_CERT_PAIR
00129 #endif
00130 
00131 #define X509_FILETYPE_PEM       1
00132 #define X509_FILETYPE_ASN1      2
00133 #define X509_FILETYPE_DEFAULT   3
00134 
00135 #define X509v3_KU_DIGITAL_SIGNATURE     0x0080
00136 #define X509v3_KU_NON_REPUDIATION       0x0040
00137 #define X509v3_KU_KEY_ENCIPHERMENT      0x0020
00138 #define X509v3_KU_DATA_ENCIPHERMENT     0x0010
00139 #define X509v3_KU_KEY_AGREEMENT         0x0008
00140 #define X509v3_KU_KEY_CERT_SIGN         0x0004
00141 #define X509v3_KU_CRL_SIGN              0x0002
00142 #define X509v3_KU_ENCIPHER_ONLY         0x0001
00143 #define X509v3_KU_DECIPHER_ONLY         0x8000
00144 #define X509v3_KU_UNDEF                 0xffff
00145 
00146 typedef struct X509_objects_st
00147         {
00148         int nid;
00149         int (*a2i)(void);
00150         int (*i2a)(void);
00151         } X509_OBJECTS;
00152 
00153 struct X509_algor_st
00154         {
00155         ASN1_OBJECT *algorithm;
00156         ASN1_TYPE *parameter;
00157         } /* X509_ALGOR */;
00158 
00159 DECLARE_STACK_OF(X509_ALGOR)
00160 DECLARE_ASN1_SET_OF(X509_ALGOR)
00161 
00162 typedef struct X509_val_st
00163         {
00164         ASN1_TIME *notBefore;
00165         ASN1_TIME *notAfter;
00166         } X509_VAL;
00167 
00168 typedef struct X509_pubkey_st
00169         {
00170         X509_ALGOR *algor;
00171         ASN1_BIT_STRING *public_key;
00172         EVP_PKEY *pkey;
00173         } X509_PUBKEY;
00174 
00175 typedef struct X509_sig_st
00176         {
00177         X509_ALGOR *algor;
00178         ASN1_OCTET_STRING *digest;
00179         } X509_SIG;
00180 
00181 typedef struct X509_name_entry_st
00182         {
00183         ASN1_OBJECT *object;
00184         ASN1_STRING *value;
00185         int set;
00186         int size;       /* temp variable */
00187         } X509_NAME_ENTRY;
00188 
00189 DECLARE_STACK_OF(X509_NAME_ENTRY)
00190 DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
00191 
00192 /* we always keep X509_NAMEs in 2 forms. */
00193 struct X509_name_st
00194         {
00195         STACK_OF(X509_NAME_ENTRY) *entries;
00196         int modified;   /* true if 'bytes' needs to be built */
00197 #ifndef OPENSSL_NO_BUFFER
00198         BUF_MEM *bytes;
00199 #else
00200         char *bytes;
00201 #endif
00202         unsigned long hash; /* Keep the hash around for lookups */
00203         } /* X509_NAME */;
00204 
00205 DECLARE_STACK_OF(X509_NAME)
00206 
00207 #define X509_EX_V_NETSCAPE_HACK         0x8000
00208 #define X509_EX_V_INIT                  0x0001
00209 typedef struct X509_extension_st
00210         {
00211         ASN1_OBJECT *object;
00212         ASN1_BOOLEAN critical;
00213         ASN1_OCTET_STRING *value;
00214         } X509_EXTENSION;
00215 
00216 DECLARE_STACK_OF(X509_EXTENSION)
00217 DECLARE_ASN1_SET_OF(X509_EXTENSION)
00218 
00219 /* a sequence of these are used */
00220 typedef struct x509_attributes_st
00221         {
00222         ASN1_OBJECT *object;
00223         int single; /* 0 for a set, 1 for a single item (which is wrong) */
00224         union   {
00225                 char            *ptr;
00226 /* 0 */         STACK_OF(ASN1_TYPE) *set;
00227 /* 1 */         ASN1_TYPE       *single;
00228                 } value;
00229         } X509_ATTRIBUTE;
00230 
00231 DECLARE_STACK_OF(X509_ATTRIBUTE)
00232 DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
00233 
00234 
00235 typedef struct X509_req_info_st
00236         {
00237         ASN1_ENCODING enc;
00238         ASN1_INTEGER *version;
00239         X509_NAME *subject;
00240         X509_PUBKEY *pubkey;
00241         /*  d=2 hl=2 l=  0 cons: cont: 00 */
00242         STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
00243         } X509_REQ_INFO;
00244 
00245 typedef struct X509_req_st
00246         {
00247         X509_REQ_INFO *req_info;
00248         X509_ALGOR *sig_alg;
00249         ASN1_BIT_STRING *signature;
00250         int references;
00251         } X509_REQ;
00252 
00253 typedef struct x509_cinf_st
00254         {
00255         ASN1_INTEGER *version;          /* [ 0 ] default of v1 */
00256         ASN1_INTEGER *serialNumber;
00257         X509_ALGOR *signature;
00258         X509_NAME *issuer;
00259         X509_VAL *validity;
00260         X509_NAME *subject;
00261         X509_PUBKEY *key;
00262         ASN1_BIT_STRING *issuerUID;             /* [ 1 ] optional in v2 */
00263         ASN1_BIT_STRING *subjectUID;            /* [ 2 ] optional in v2 */
00264         STACK_OF(X509_EXTENSION) *extensions;   /* [ 3 ] optional in v3 */
00265         } X509_CINF;
00266 
00267 /* This stuff is certificate "auxiliary info"
00268  * it contains details which are useful in certificate
00269  * stores and databases. When used this is tagged onto
00270  * the end of the certificate itself
00271  */
00272 
00273 typedef struct x509_cert_aux_st
00274         {
00275         STACK_OF(ASN1_OBJECT) *trust;           /* trusted uses */
00276         STACK_OF(ASN1_OBJECT) *reject;          /* rejected uses */
00277         ASN1_UTF8STRING *alias;                 /* "friendly name" */
00278         ASN1_OCTET_STRING *keyid;               /* key id of private key */
00279         STACK_OF(X509_ALGOR) *other;            /* other unspecified info */
00280         } X509_CERT_AUX;
00281 
00282 struct x509_st
00283         {
00284         X509_CINF *cert_info;
00285         X509_ALGOR *sig_alg;
00286         ASN1_BIT_STRING *signature;
00287         int valid;
00288         int references;
00289         char *name;
00290         CRYPTO_EX_DATA ex_data;
00291         /* These contain copies of various extension values */
00292         long ex_pathlen;
00293         long ex_pcpathlen;
00294         unsigned long ex_flags;
00295         unsigned long ex_kusage;
00296         unsigned long ex_xkusage;
00297         unsigned long ex_nscert;
00298         ASN1_OCTET_STRING *skid;
00299         struct AUTHORITY_KEYID_st *akid;
00300         X509_POLICY_CACHE *policy_cache;
00301 #ifndef OPENSSL_NO_SHA
00302         unsigned char sha1_hash[SHA_DIGEST_LENGTH];
00303 #endif
00304         X509_CERT_AUX *aux;
00305         } /* X509 */;
00306 
00307 DECLARE_STACK_OF(X509)
00308 DECLARE_ASN1_SET_OF(X509)
00309 
00310 /* This is used for a table of trust checking functions */
00311 
00312 typedef struct x509_trust_st {
00313         int trust;
00314         int flags;
00315         int (*check_trust)(struct x509_trust_st *, X509 *, int);
00316         char *name;
00317         int arg1;
00318         void *arg2;
00319 } X509_TRUST;
00320 
00321 DECLARE_STACK_OF(X509_TRUST)
00322 
00323 typedef struct x509_cert_pair_st {
00324         X509 *forward;
00325         X509 *reverse;
00326 } X509_CERT_PAIR;
00327 
00328 /* standard trust ids */
00329 
00330 #define X509_TRUST_DEFAULT      -1      /* Only valid in purpose settings */
00331 
00332 #define X509_TRUST_COMPAT       1
00333 #define X509_TRUST_SSL_CLIENT   2
00334 #define X509_TRUST_SSL_SERVER   3
00335 #define X509_TRUST_EMAIL        4
00336 #define X509_TRUST_OBJECT_SIGN  5
00337 #define X509_TRUST_OCSP_SIGN    6
00338 #define X509_TRUST_OCSP_REQUEST 7
00339 
00340 /* Keep these up to date! */
00341 #define X509_TRUST_MIN          1
00342 #define X509_TRUST_MAX          7
00343 
00344 
00345 /* trust_flags values */
00346 #define X509_TRUST_DYNAMIC      1
00347 #define X509_TRUST_DYNAMIC_NAME 2
00348 
00349 /* check_trust return codes */
00350 
00351 #define X509_TRUST_TRUSTED      1
00352 #define X509_TRUST_REJECTED     2
00353 #define X509_TRUST_UNTRUSTED    3
00354 
00355 /* Flags for X509_print_ex() */
00356 
00357 #define X509_FLAG_COMPAT                0
00358 #define X509_FLAG_NO_HEADER             1L
00359 #define X509_FLAG_NO_VERSION            (1L << 1)
00360 #define X509_FLAG_NO_SERIAL             (1L << 2)
00361 #define X509_FLAG_NO_SIGNAME            (1L << 3)
00362 #define X509_FLAG_NO_ISSUER             (1L << 4)
00363 #define X509_FLAG_NO_VALIDITY           (1L << 5)
00364 #define X509_FLAG_NO_SUBJECT            (1L << 6)
00365 #define X509_FLAG_NO_PUBKEY             (1L << 7)
00366 #define X509_FLAG_NO_EXTENSIONS         (1L << 8)
00367 #define X509_FLAG_NO_SIGDUMP            (1L << 9)
00368 #define X509_FLAG_NO_AUX                (1L << 10)
00369 #define X509_FLAG_NO_ATTRIBUTES         (1L << 11)
00370 
00371 /* Flags specific to X509_NAME_print_ex() */    
00372 
00373 /* The field separator information */
00374 
00375 #define XN_FLAG_SEP_MASK        (0xf << 16)
00376 
00377 #define XN_FLAG_COMPAT          0               /* Traditional SSLeay: use old X509_NAME_print */
00378 #define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)       /* RFC2253 ,+ */
00379 #define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)       /* ,+ spaced: more readable */
00380 #define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)       /* ;+ spaced */
00381 #define XN_FLAG_SEP_MULTILINE   (4 << 16)       /* One line per field */
00382 
00383 #define XN_FLAG_DN_REV          (1 << 20)       /* Reverse DN order */
00384 
00385 /* How the field name is shown */
00386 
00387 #define XN_FLAG_FN_MASK         (0x3 << 21)
00388 
00389 #define XN_FLAG_FN_SN           0               /* Object short name */
00390 #define XN_FLAG_FN_LN           (1 << 21)       /* Object long name */
00391 #define XN_FLAG_FN_OID          (2 << 21)       /* Always use OIDs */
00392 #define XN_FLAG_FN_NONE         (3 << 21)       /* No field names */
00393 
00394 #define XN_FLAG_SPC_EQ          (1 << 23)       /* Put spaces round '=' */
00395 
00396 /* This determines if we dump fields we don't recognise:
00397  * RFC2253 requires this.
00398  */
00399 
00400 #define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
00401 
00402 #define XN_FLAG_FN_ALIGN        (1 << 25)       /* Align field names to 20 characters */
00403 
00404 /* Complete set of RFC2253 flags */
00405 
00406 #define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
00407                         XN_FLAG_SEP_COMMA_PLUS | \
00408                         XN_FLAG_DN_REV | \
00409                         XN_FLAG_FN_SN | \
00410                         XN_FLAG_DUMP_UNKNOWN_FIELDS)
00411 
00412 /* readable oneline form */
00413 
00414 #define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
00415                         ASN1_STRFLGS_ESC_QUOTE | \
00416                         XN_FLAG_SEP_CPLUS_SPC | \
00417                         XN_FLAG_SPC_EQ | \
00418                         XN_FLAG_FN_SN)
00419 
00420 /* readable multiline form */
00421 
00422 #define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
00423                         ASN1_STRFLGS_ESC_MSB | \
00424                         XN_FLAG_SEP_MULTILINE | \
00425                         XN_FLAG_SPC_EQ | \
00426                         XN_FLAG_FN_LN | \
00427                         XN_FLAG_FN_ALIGN)
00428 
00429 typedef struct X509_revoked_st
00430         {
00431         ASN1_INTEGER *serialNumber;
00432         ASN1_TIME *revocationDate;
00433         STACK_OF(X509_EXTENSION) /* optional */ *extensions;
00434         int sequence; /* load sequence */
00435         } X509_REVOKED;
00436 
00437 DECLARE_STACK_OF(X509_REVOKED)
00438 DECLARE_ASN1_SET_OF(X509_REVOKED)
00439 
00440 typedef struct X509_crl_info_st
00441         {
00442         ASN1_INTEGER *version;
00443         X509_ALGOR *sig_alg;
00444         X509_NAME *issuer;
00445         ASN1_TIME *lastUpdate;
00446         ASN1_TIME *nextUpdate;
00447         STACK_OF(X509_REVOKED) *revoked;
00448         STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
00449         ASN1_ENCODING enc;
00450         } X509_CRL_INFO;
00451 
00452 struct X509_crl_st
00453         {
00454         /* actual signature */
00455         X509_CRL_INFO *crl;
00456         X509_ALGOR *sig_alg;
00457         ASN1_BIT_STRING *signature;
00458         int references;
00459         } /* X509_CRL */;
00460 
00461 DECLARE_STACK_OF(X509_CRL)
00462 DECLARE_ASN1_SET_OF(X509_CRL)
00463 
00464 typedef struct private_key_st
00465         {
00466         int version;
00467         /* The PKCS#8 data types */
00468         X509_ALGOR *enc_algor;
00469         ASN1_OCTET_STRING *enc_pkey;    /* encrypted pub key */
00470 
00471         /* When decrypted, the following will not be NULL */
00472         EVP_PKEY *dec_pkey;
00473 
00474         /* used to encrypt and decrypt */
00475         int key_length;
00476         char *key_data;
00477         int key_free;   /* true if we should auto free key_data */
00478 
00479         /* expanded version of 'enc_algor' */
00480         EVP_CIPHER_INFO cipher;
00481 
00482         int references;
00483         } X509_PKEY;
00484 
00485 #ifndef OPENSSL_NO_EVP
00486 typedef struct X509_info_st
00487         {
00488         X509 *x509;
00489         X509_CRL *crl;
00490         X509_PKEY *x_pkey;
00491 
00492         EVP_CIPHER_INFO enc_cipher;
00493         int enc_len;
00494         char *enc_data;
00495 
00496         int references;
00497         } X509_INFO;
00498 
00499 DECLARE_STACK_OF(X509_INFO)
00500 #endif
00501 
00502 /* The next 2 structures and their 8 routines were sent to me by
00503  * Pat Richard <[email protected]> and are used to manipulate
00504  * Netscapes spki structures - useful if you are writing a CA web page
00505  */
00506 typedef struct Netscape_spkac_st
00507         {
00508         X509_PUBKEY *pubkey;
00509         ASN1_IA5STRING *challenge;      /* challenge sent in atlas >= PR2 */
00510         } NETSCAPE_SPKAC;
00511 
00512 typedef struct Netscape_spki_st
00513         {
00514         NETSCAPE_SPKAC *spkac;  /* signed public key and challenge */
00515         X509_ALGOR *sig_algor;
00516         ASN1_BIT_STRING *signature;
00517         } NETSCAPE_SPKI;
00518 
00519 /* Netscape certificate sequence structure */
00520 typedef struct Netscape_certificate_sequence
00521         {
00522         ASN1_OBJECT *type;
00523         STACK_OF(X509) *certs;
00524         } NETSCAPE_CERT_SEQUENCE;
00525 
00526 /* Unused (and iv length is wrong)
00527 typedef struct CBCParameter_st
00528         {
00529         unsigned char iv[8];
00530         } CBC_PARAM;
00531 */
00532 
00533 /* Password based encryption structure */
00534 
00535 typedef struct PBEPARAM_st {
00536 ASN1_OCTET_STRING *salt;
00537 ASN1_INTEGER *iter;
00538 } PBEPARAM;
00539 
00540 /* Password based encryption V2 structures */
00541 
00542 typedef struct PBE2PARAM_st {
00543 X509_ALGOR *keyfunc;
00544 X509_ALGOR *encryption;
00545 } PBE2PARAM;
00546 
00547 typedef struct PBKDF2PARAM_st {
00548 ASN1_TYPE *salt;        /* Usually OCTET STRING but could be anything */
00549 ASN1_INTEGER *iter;
00550 ASN1_INTEGER *keylength;
00551 X509_ALGOR *prf;
00552 } PBKDF2PARAM;
00553 
00554 
00555 /* PKCS#8 private key info structure */
00556 
00557 typedef struct pkcs8_priv_key_info_st
00558         {
00559         int broken;     /* Flag for various broken formats */
00560 #define PKCS8_OK                0
00561 #define PKCS8_NO_OCTET          1
00562 #define PKCS8_EMBEDDED_PARAM    2
00563 #define PKCS8_NS_DB             3
00564         ASN1_INTEGER *version;
00565         X509_ALGOR *pkeyalg;
00566         ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
00567         STACK_OF(X509_ATTRIBUTE) *attributes;
00568         } PKCS8_PRIV_KEY_INFO;
00569 
00570 #ifdef  __cplusplus
00571 }
00572 #endif
00573 
00574 #include <openssl/x509_vfy.h>
00575 #include <openssl/pkcs7.h>
00576 
00577 #ifdef  __cplusplus
00578 extern "C" {
00579 #endif
00580 
00581 #ifdef SSLEAY_MACROS
00582 #define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\
00583         a->signature,(char *)a->cert_info,r)
00584 #define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \
00585         a->sig_alg,a->signature,(char *)a->req_info,r)
00586 #define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \
00587         a->sig_alg, a->signature,(char *)a->crl,r)
00588 
00589 #define X509_sign(x,pkey,md) \
00590         ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \
00591                 x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)
00592 #define X509_REQ_sign(x,pkey,md) \
00593         ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \
00594                 x->signature, (char *)x->req_info,pkey,md)
00595 #define X509_CRL_sign(x,pkey,md) \
00596         ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \
00597                 x->signature, (char *)x->crl,pkey,md)
00598 #define NETSCAPE_SPKI_sign(x,pkey,md) \
00599         ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \
00600                 x->signature, (char *)x->spkac,pkey,md)
00601 
00602 #define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \
00603                 (char *(*)())d2i_X509,(char *)x509)
00604 #define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\
00605                 (int (*)())i2d_X509_ATTRIBUTE, \
00606                 (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa)
00607 #define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \
00608                 (int (*)())i2d_X509_EXTENSION, \
00609                 (char *(*)())d2i_X509_EXTENSION,(char *)ex)
00610 #define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \
00611                 (char *(*)())d2i_X509, (fp),(unsigned char **)(x509))
00612 #define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)
00613 #define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \
00614                 (char *(*)())d2i_X509, (bp),(unsigned char **)(x509))
00615 #define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)
00616 
00617 #define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \
00618                 (char *(*)())d2i_X509_CRL,(char *)crl)
00619 #define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \
00620                 X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\
00621                 (unsigned char **)(crl))
00622 #define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\
00623                 (unsigned char *)crl)
00624 #define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \
00625                 X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\
00626                 (unsigned char **)(crl))
00627 #define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\
00628                 (unsigned char *)crl)
00629 
00630 #define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \
00631                 (char *(*)())d2i_PKCS7,(char *)p7)
00632 #define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \
00633                 PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\
00634                 (unsigned char **)(p7))
00635 #define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\
00636                 (unsigned char *)p7)
00637 #define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \
00638                 PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\
00639                 (unsigned char **)(p7))
00640 #define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\
00641                 (unsigned char *)p7)
00642 
00643 #define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \
00644                 (char *(*)())d2i_X509_REQ,(char *)req)
00645 #define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\
00646                 X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\
00647                 (unsigned char **)(req))
00648 #define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\
00649                 (unsigned char *)req)
00650 #define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\
00651                 X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\
00652                 (unsigned char **)(req))
00653 #define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\
00654                 (unsigned char *)req)
00655 
00656 #define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \
00657                 (char *(*)())d2i_RSAPublicKey,(char *)rsa)
00658 #define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \
00659                 (char *(*)())d2i_RSAPrivateKey,(char *)rsa)
00660 
00661 #define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
00662                 RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \
00663                 (unsigned char **)(rsa))
00664 #define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \
00665                 (unsigned char *)rsa)
00666 #define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
00667                 RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \
00668                 (unsigned char **)(rsa))
00669 #define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \
00670                 (unsigned char *)rsa)
00671 
00672 #define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
00673                 RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \
00674                 (unsigned char **)(rsa))
00675 #define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \
00676                 (unsigned char *)rsa)
00677 #define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
00678                 RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \
00679                 (unsigned char **)(rsa))
00680 #define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \
00681                 (unsigned char *)rsa)
00682 
00683 #define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\
00684                 DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \
00685                 (unsigned char **)(dsa))
00686 #define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \
00687                 (unsigned char *)dsa)
00688 #define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\
00689                 DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \
00690                 (unsigned char **)(dsa))
00691 #define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \
00692                 (unsigned char *)dsa)
00693 
00694 #define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\
00695                 EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \
00696                 (unsigned char **)(ecdsa))
00697 #define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \
00698                 (unsigned char *)ecdsa)
00699 #define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\
00700                 EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \
00701                 (unsigned char **)(ecdsa))
00702 #define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \
00703                 (unsigned char *)ecdsa)
00704 
00705 #define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\
00706                 (char *(*)())d2i_X509_ALGOR,(char *)xn)
00707 
00708 #define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \
00709                 (char *(*)())d2i_X509_NAME,(char *)xn)
00710 #define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \
00711                 (int (*)())i2d_X509_NAME_ENTRY, \
00712                 (char *(*)())d2i_X509_NAME_ENTRY,\
00713                 (char *)ne)
00714 
00715 #define X509_digest(data,type,md,len) \
00716         ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)
00717 #define X509_NAME_digest(data,type,md,len) \
00718         ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)
00719 #ifndef PKCS7_ISSUER_AND_SERIAL_digest
00720 #define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
00721         ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
00722                 (char *)data,md,len)
00723 #endif
00724 #endif
00725 
00726 #define X509_EXT_PACK_UNKNOWN   1
00727 #define X509_EXT_PACK_STRING    2
00728 
00729 #define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)
00730 /* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */
00731 #define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
00732 #define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
00733 #define         X509_extract_key(x)     X509_get_pubkey(x) /*****/
00734 #define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)
00735 #define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)
00736 #define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
00737 #define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))
00738 #define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))
00739 
00740 #define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)
00741 #define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)
00742 #define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)
00743 #define         X509_CRL_get_issuer(x) ((x)->crl->issuer)
00744 #define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)
00745 
00746 /* This one is only used so that a binary form can output, as in
00747  * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
00748 #define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)
00749 
00750 
00751 IMPORT_C const char *X509_verify_cert_error_string(long n);
00752 
00753 #ifndef SSLEAY_MACROS
00754 #ifndef OPENSSL_NO_EVP
00755 IMPORT_C int X509_verify(X509 *a, EVP_PKEY *r);
00756 
00757 IMPORT_C int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
00758 IMPORT_C int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
00759 IMPORT_C int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
00760 
00761 IMPORT_C NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
00762 IMPORT_C char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
00763 IMPORT_C EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
00764 IMPORT_C int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
00765 
00766 IMPORT_C int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
00767 
00768 IMPORT_C int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
00769 
00770 IMPORT_C int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
00771 IMPORT_C int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
00772 IMPORT_C int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
00773 IMPORT_C int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
00774 
00775 IMPORT_C int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
00776                 unsigned char *md, unsigned int *len);
00777 IMPORT_C int X509_digest(const X509 *data,const EVP_MD *type,
00778                 unsigned char *md, unsigned int *len);
00779 IMPORT_C int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
00780                 unsigned char *md, unsigned int *len);
00781 IMPORT_C int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
00782                 unsigned char *md, unsigned int *len);
00783 IMPORT_C int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
00784                 unsigned char *md, unsigned int *len);
00785 #endif
00786 
00787 #ifndef OPENSSL_NO_FP_API
00788 IMPORT_C X509 *d2i_X509_fp(FILE *fp, X509 **x509);
00789 IMPORT_C int i2d_X509_fp(FILE *fp,X509 *x509);
00790 IMPORT_C X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
00791 IMPORT_C int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
00792 X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
00793 IMPORT_C int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
00794 #ifndef OPENSSL_NO_RSA
00795 IMPORT_C RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
00796 IMPORT_C int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
00797 IMPORT_C RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
00798 IMPORT_C int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
00799 IMPORT_C RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
00800 IMPORT_C int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
00801 #endif
00802 #ifndef OPENSSL_NO_DSA
00803 IMPORT_C DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
00804 IMPORT_C int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
00805 IMPORT_C DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
00806 IMPORT_C int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
00807 #endif
00808 IMPORT_C X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
00809 IMPORT_C int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
00810 IMPORT_C PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
00811                                                 PKCS8_PRIV_KEY_INFO **p8inf);
00812 IMPORT_C int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
00813 IMPORT_C int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
00814 IMPORT_C int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
00815 IMPORT_C EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
00816 IMPORT_C int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
00817 IMPORT_C EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
00818 #endif
00819 
00820 #ifndef OPENSSL_NO_BIO
00821 IMPORT_C X509 *d2i_X509_bio(BIO *bp,X509 **x509);
00822 IMPORT_C int i2d_X509_bio(BIO *bp,X509 *x509);
00823 IMPORT_C X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
00824 IMPORT_C int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
00825 IMPORT_C X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
00826 IMPORT_C int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
00827 #ifndef OPENSSL_NO_RSA
00828 IMPORT_C RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
00829 IMPORT_C int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
00830 IMPORT_C RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
00831 IMPORT_C int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
00832 IMPORT_C RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
00833 IMPORT_C int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
00834 #endif
00835 #ifndef OPENSSL_NO_DSA
00836 IMPORT_C DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
00837 IMPORT_C int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
00838 IMPORT_C DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
00839 IMPORT_C int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
00840 #endif
00841 IMPORT_C X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
00842 IMPORT_C int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
00843 IMPORT_C PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
00844                                                 PKCS8_PRIV_KEY_INFO **p8inf);
00845 IMPORT_C int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
00846 IMPORT_C int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
00847 IMPORT_C int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
00848 IMPORT_C EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
00849 IMPORT_C int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
00850 IMPORT_C EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
00851 #endif
00852 
00853 IMPORT_C X509 *X509_dup(X509 *x509);
00854 IMPORT_C X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
00855 IMPORT_C X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
00856 IMPORT_C X509_CRL *X509_CRL_dup(X509_CRL *crl);
00857 IMPORT_C X509_REQ *X509_REQ_dup(X509_REQ *req);
00858 IMPORT_C X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
00859 IMPORT_C X509_NAME *X509_NAME_dup(X509_NAME *xn);
00860 IMPORT_C X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
00861 
00862 #endif /* !SSLEAY_MACROS */
00863 
00864 IMPORT_C int            X509_cmp_time(ASN1_TIME *s, time_t *t);
00865 IMPORT_C int            X509_cmp_current_time(ASN1_TIME *s);
00866 IMPORT_C ASN1_TIME *    X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
00867 IMPORT_C ASN1_TIME *    X509_gmtime_adj(ASN1_TIME *s, long adj);
00868 
00869 IMPORT_C const char *   X509_get_default_cert_area(void );
00870 IMPORT_C const char *   X509_get_default_cert_dir(void );
00871 IMPORT_C const char *   X509_get_default_cert_file(void );
00872 IMPORT_C const char *   X509_get_default_cert_dir_env(void );
00873 IMPORT_C const char *   X509_get_default_cert_file_env(void );
00874 IMPORT_C const char *   X509_get_default_private_dir(void );
00875 
00876 IMPORT_C X509_REQ *     X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
00877 IMPORT_C X509 *         X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
00878 
00879 DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
00880 DECLARE_ASN1_FUNCTIONS(X509_VAL)
00881 
00882 DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
00883 
00884 IMPORT_C int            X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
00885 IMPORT_C EVP_PKEY *     X509_PUBKEY_get(X509_PUBKEY *key);
00886 IMPORT_C int            X509_get_pubkey_parameters(EVP_PKEY *pkey,
00887                                            STACK_OF(X509) *chain);
00888 IMPORT_C int            i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
00889 IMPORT_C EVP_PKEY *     d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
00890                         long length);
00891 #ifndef OPENSSL_NO_RSA
00892 IMPORT_C int            i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
00893 IMPORT_C RSA *          d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
00894                         long length);
00895 #endif
00896 #ifndef OPENSSL_NO_DSA
00897 IMPORT_C int            i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
00898 IMPORT_C DSA *          d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
00899                         long length);
00900 #endif
00901 #ifndef OPENSSL_NO_EC
00902 IMPORT_C int            i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
00903 EC_KEY          *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
00904                         long length);
00905 #endif
00906 
00907 DECLARE_ASN1_FUNCTIONS(X509_SIG)
00908 DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
00909 DECLARE_ASN1_FUNCTIONS(X509_REQ)
00910 
00911 DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
00912 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
00913 
00914 DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
00915 
00916 DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
00917 
00918 DECLARE_ASN1_FUNCTIONS(X509_NAME)
00919 
00920 int             X509_NAME_set(X509_NAME **xn, X509_NAME *name);
00921 
00922 DECLARE_ASN1_FUNCTIONS(X509_CINF)
00923 
00924 DECLARE_ASN1_FUNCTIONS(X509)
00925 DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
00926 
00927 DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)
00928 
00929 IMPORT_C int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
00930              CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
00931 IMPORT_C int X509_set_ex_data(X509 *r, int idx, void *arg);
00932 IMPORT_C void *X509_get_ex_data(X509 *r, int idx);
00933 IMPORT_C int            i2d_X509_AUX(X509 *a,unsigned char **pp);
00934 IMPORT_C X509 *         d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
00935 
00936 IMPORT_C int X509_alias_set1(X509 *x, unsigned char *name, int len);
00937 IMPORT_C int X509_keyid_set1(X509 *x, unsigned char *id, int len);
00938 IMPORT_C unsigned char * X509_alias_get0(X509 *x, int *len);
00939 IMPORT_C unsigned char * X509_keyid_get0(X509 *x, int *len);
00940 IMPORT_C int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
00941 IMPORT_C int X509_TRUST_set(int *t, int trust);
00942 IMPORT_C int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
00943 IMPORT_C int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
00944 IMPORT_C void X509_trust_clear(X509 *x);
00945 IMPORT_C void X509_reject_clear(X509 *x);
00946 
00947 DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
00948 DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
00949 DECLARE_ASN1_FUNCTIONS(X509_CRL)
00950 
00951 IMPORT_C int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
00952 
00953 IMPORT_C X509_PKEY *    X509_PKEY_new(void );
00954 IMPORT_C void           X509_PKEY_free(X509_PKEY *a);
00955 IMPORT_C int            i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
00956 IMPORT_C X509_PKEY *    d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);
00957 
00958 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
00959 DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
00960 DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
00961 
00962 #ifndef OPENSSL_NO_EVP
00963 IMPORT_C X509_INFO *    X509_INFO_new(void);
00964 void            X509_INFO_free(X509_INFO *a);
00965 IMPORT_C char *         X509_NAME_oneline(X509_NAME *a,char *buf,int size);
00966 
00967 IMPORT_C int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
00968                 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
00969 
00970 IMPORT_C int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data,
00971                 unsigned char *md,unsigned int *len);
00972 
00973 IMPORT_C int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
00974               X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
00975               char *data,EVP_PKEY *pkey, const EVP_MD *type);
00976 
00977 IMPORT_C int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
00978         unsigned char *md,unsigned int *len);
00979 
00980 IMPORT_C int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
00981         ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
00982 
00983 IMPORT_C int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
00984         ASN1_BIT_STRING *signature,
00985         void *data, EVP_PKEY *pkey, const EVP_MD *type);
00986 #endif
00987 
00988 IMPORT_C int            X509_set_version(X509 *x,long version);
00989 IMPORT_C int            X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
00990 IMPORT_C ASN1_INTEGER * X509_get_serialNumber(X509 *x);
00991 IMPORT_C int            X509_set_issuer_name(X509 *x, X509_NAME *name);
00992 IMPORT_C X509_NAME *    X509_get_issuer_name(X509 *a);
00993 IMPORT_C int            X509_set_subject_name(X509 *x, X509_NAME *name);
00994 IMPORT_C X509_NAME *    X509_get_subject_name(X509 *a);
00995 IMPORT_C int            X509_set_notBefore(X509 *x, ASN1_TIME *tm);
00996 IMPORT_C int            X509_set_notAfter(X509 *x, ASN1_TIME *tm);
00997 IMPORT_C int            X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
00998 IMPORT_C EVP_PKEY *     X509_get_pubkey(X509 *x);
00999 IMPORT_C ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
01000 IMPORT_C int            X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);
01001 
01002 IMPORT_C int            X509_REQ_set_version(X509_REQ *x,long version);
01003 IMPORT_C int            X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
01004 IMPORT_C int            X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
01005 IMPORT_C EVP_PKEY *     X509_REQ_get_pubkey(X509_REQ *req);
01006 IMPORT_C int            X509_REQ_extension_nid(int nid);
01007 IMPORT_C int *          X509_REQ_get_extension_nids(void);
01008 IMPORT_C void           X509_REQ_set_extension_nids(int *nids);
01009 IMPORT_C STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
01010 IMPORT_C int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
01011                                 int nid);
01012 IMPORT_C int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
01013 IMPORT_C int X509_REQ_get_attr_count(const X509_REQ *req);
01014 IMPORT_C int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
01015                           int lastpos);
01016 IMPORT_C int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
01017                           int lastpos);
01018 IMPORT_C X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
01019 IMPORT_C X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
01020 IMPORT_C int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
01021 IMPORT_C int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
01022                         const ASN1_OBJECT *obj, int type,
01023                         const unsigned char *bytes, int len);
01024 IMPORT_C int X509_REQ_add1_attr_by_NID(X509_REQ *req,
01025                         int nid, int type,
01026                         const unsigned char *bytes, int len);
01027 int X509_REQ_add1_attr_by_txt(X509_REQ *req,
01028                         const char *attrname, int type,
01029                         const unsigned char *bytes, int len);
01030 
01031 IMPORT_C int X509_CRL_set_version(X509_CRL *x, long version);
01032 IMPORT_C int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
01033 IMPORT_C int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm);
01034 IMPORT_C int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm);
01035 IMPORT_C int X509_CRL_sort(X509_CRL *crl);
01036 
01037 IMPORT_C int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
01038 IMPORT_C int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
01039 
01040 IMPORT_C int            X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
01041 
01042 IMPORT_C int            X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
01043 
01044 IMPORT_C int            X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
01045 IMPORT_C unsigned long  X509_issuer_and_serial_hash(X509 *a);
01046 
01047 IMPORT_C int            X509_issuer_name_cmp(const X509 *a, const X509 *b);
01048 IMPORT_C unsigned long  X509_issuer_name_hash(X509 *a);
01049 
01050 IMPORT_C int            X509_subject_name_cmp(const X509 *a, const X509 *b);
01051 IMPORT_C unsigned long  X509_subject_name_hash(X509 *x);
01052 
01053 IMPORT_C int            X509_cmp(const X509 *a, const X509 *b);
01054 IMPORT_C int            X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
01055 IMPORT_C unsigned long  X509_NAME_hash(X509_NAME *x);
01056 
01057 IMPORT_C int            X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
01058 #ifndef OPENSSL_NO_FP_API
01059 IMPORT_C int            X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
01060 IMPORT_C int            X509_print_fp(FILE *bp,X509 *x);
01061 IMPORT_C int            X509_CRL_print_fp(FILE *bp,X509_CRL *x);
01062 IMPORT_C int            X509_REQ_print_fp(FILE *bp,X509_REQ *req);
01063 IMPORT_C int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
01064 #endif
01065 
01066 #ifndef OPENSSL_NO_BIO
01067 IMPORT_C int            X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
01068 IMPORT_C int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
01069 IMPORT_C int            X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
01070 IMPORT_C int            X509_print(BIO *bp,X509 *x);
01071 IMPORT_C int            X509_ocspid_print(BIO *bp,X509 *x);
01072 IMPORT_C int            X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
01073 IMPORT_C int            X509_CRL_print(BIO *bp,X509_CRL *x);
01074 IMPORT_C int            X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
01075 IMPORT_C int            X509_REQ_print(BIO *bp,X509_REQ *req);
01076 #endif
01077 
01078 IMPORT_C int            X509_NAME_entry_count(X509_NAME *name);
01079 IMPORT_C int            X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
01080                         char *buf,int len);
01081 IMPORT_C int            X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
01082                         char *buf,int len);
01083 
01084 /* NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use
01085  * lastpos, search after that position on. */
01086 IMPORT_C int            X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
01087 IMPORT_C int            X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
01088                         int lastpos);
01089 IMPORT_C X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
01090 IMPORT_C X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
01091 IMPORT_C int            X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
01092                         int loc, int set);
01093 IMPORT_C int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
01094                         unsigned char *bytes, int len, int loc, int set);
01095 IMPORT_C int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
01096                         unsigned char *bytes, int len, int loc, int set);
01097 IMPORT_C X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
01098                 const char *field, int type, const unsigned char *bytes, int len);
01099 IMPORT_C X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
01100                         int type,unsigned char *bytes, int len);
01101 IMPORT_C int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
01102                         const unsigned char *bytes, int len, int loc, int set);
01103 IMPORT_C X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
01104                         ASN1_OBJECT *obj, int type,const unsigned char *bytes,
01105                         int len);
01106 IMPORT_C int            X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
01107                         ASN1_OBJECT *obj);
01108 IMPORT_C int            X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
01109                         const unsigned char *bytes, int len);
01110 IMPORT_C ASN1_OBJECT *  X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
01111 IMPORT_C ASN1_STRING *  X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
01112 
01113 IMPORT_C int            X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
01114 IMPORT_C int            X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
01115                                       int nid, int lastpos);
01116 IMPORT_C int            X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
01117                                       ASN1_OBJECT *obj,int lastpos);
01118 IMPORT_C int            X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
01119                                            int crit, int lastpos);
01120 IMPORT_C X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
01121 IMPORT_C X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
01122 IMPORT_C STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
01123                                          X509_EXTENSION *ex, int loc);
01124 
01125 IMPORT_C int            X509_get_ext_count(X509 *x);
01126 IMPORT_C int            X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
01127 IMPORT_C int            X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
01128 IMPORT_C int            X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
01129 IMPORT_C X509_EXTENSION *X509_get_ext(X509 *x, int loc);
01130 IMPORT_C X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
01131 IMPORT_C int            X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
01132 IMPORT_C void   *       X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
01133 IMPORT_C int            X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
01134                                                         unsigned long flags);
01135 
01136 IMPORT_C int            X509_CRL_get_ext_count(X509_CRL *x);
01137 IMPORT_C int            X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
01138 IMPORT_C int            X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
01139 IMPORT_C int            X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
01140 IMPORT_C X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
01141 IMPORT_C X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
01142 IMPORT_C int            X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
01143 IMPORT_C void   *       X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
01144 IMPORT_C int            X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
01145                                                         unsigned long flags);
01146 
01147 IMPORT_C int            X509_REVOKED_get_ext_count(X509_REVOKED *x);
01148 IMPORT_C int            X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
01149 IMPORT_C int            X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
01150 IMPORT_C int            X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
01151 IMPORT_C X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
01152 IMPORT_C X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
01153 IMPORT_C int            X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
01154 IMPORT_C void   *       X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
01155 IMPORT_C int            X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
01156                                                         unsigned long flags);
01157 
01158 IMPORT_C X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
01159                         int nid, int crit, ASN1_OCTET_STRING *data);
01160 IMPORT_C X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
01161                         ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
01162 IMPORT_C int            X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
01163 IMPORT_C int            X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
01164 IMPORT_C int            X509_EXTENSION_set_data(X509_EXTENSION *ex,
01165                         ASN1_OCTET_STRING *data);
01166 IMPORT_C ASN1_OBJECT *  X509_EXTENSION_get_object(X509_EXTENSION *ex);
01167 IMPORT_C ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
01168 IMPORT_C int            X509_EXTENSION_get_critical(X509_EXTENSION *ex);
01169 
01170 IMPORT_C int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
01171 IMPORT_C int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
01172                           int lastpos);
01173 IMPORT_C int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
01174                           int lastpos);
01175 IMPORT_C X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
01176 IMPORT_C X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
01177 IMPORT_C STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
01178                                          X509_ATTRIBUTE *attr);
01179 IMPORT_C STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
01180                         const ASN1_OBJECT *obj, int type,
01181                         const unsigned char *bytes, int len);
01182 IMPORT_C STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
01183                         int nid, int type,
01184                         const unsigned char *bytes, int len);
01185 IMPORT_C STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
01186                         const char *attrname, int type,
01187                         const unsigned char *bytes, int len);
01188 IMPORT_C X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
01189              int atrtype, const void *data, int len);
01190 IMPORT_C X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
01191              const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
01192 IMPORT_C X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
01193                 const char *atrname, int type, const unsigned char *bytes, int len);
01194 IMPORT_C int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
01195 IMPORT_C int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
01196 IMPORT_C void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
01197                                         int atrtype, void *data);
01198 IMPORT_C int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
01199 IMPORT_C ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
01200 IMPORT_C ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
01201 
01202 IMPORT_C int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
01203 IMPORT_C int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
01204                           int lastpos);
01205 IMPORT_C int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
01206                           int lastpos);
01207 IMPORT_C X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
01208 IMPORT_C X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
01209 IMPORT_C int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
01210 IMPORT_C int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
01211                         const ASN1_OBJECT *obj, int type,
01212                         const unsigned char *bytes, int len);
01213 IMPORT_C int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
01214                         int nid, int type,
01215                         const unsigned char *bytes, int len);
01216 IMPORT_C int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
01217                         const char *attrname, int type,
01218                         const unsigned char *bytes, int len);
01219 
01220 IMPORT_C int            X509_verify_cert(X509_STORE_CTX *ctx);
01221 
01222 /* lookup a cert from a X509 STACK */
01223 IMPORT_C X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
01224                                      ASN1_INTEGER *serial);
01225 IMPORT_C X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
01226 
01227 DECLARE_ASN1_FUNCTIONS(PBEPARAM)
01228 DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
01229 DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
01230 
01231 IMPORT_C X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen);
01232 IMPORT_C X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
01233                                          unsigned char *salt, int saltlen);
01234 
01235 /* PKCS#8 utilities */
01236 
01237 DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
01238 
01239 IMPORT_C EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
01240 IMPORT_C PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
01241 IMPORT_C PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
01242 IMPORT_C PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
01243 
01244 IMPORT_C int X509_check_trust(X509 *x, int id, int flags);
01245 IMPORT_C int X509_TRUST_get_count(void);
01246 IMPORT_C X509_TRUST * X509_TRUST_get0(int idx);
01247 IMPORT_C int X509_TRUST_get_by_id(int id);
01248 IMPORT_C int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
01249                                         char *name, int arg1, void *arg2);
01250 IMPORT_C void X509_TRUST_cleanup(void);
01251 IMPORT_C int X509_TRUST_get_flags(X509_TRUST *xp);
01252 IMPORT_C char *X509_TRUST_get0_name(X509_TRUST *xp);
01253 IMPORT_C int X509_TRUST_get_trust(X509_TRUST *xp);
01254 
01255 /* BEGIN ERROR CODES */
01256 /* The following lines are auto generated by the script mkerr.pl. Any changes
01257  * made after this point may be overwritten when the script is next run.
01258  */
01259 IMPORT_C void ERR_load_X509_strings(void);
01260 
01261 /* Error codes for the X509 functions. */
01262 
01263 /* Function codes. */
01264 #define X509_F_ADD_CERT_DIR                              100
01265 #define X509_F_BY_FILE_CTRL                              101
01266 #define X509_F_CHECK_POLICY                              145
01267 #define X509_F_DIR_CTRL                                  102
01268 #define X509_F_GET_CERT_BY_SUBJECT                       103
01269 #define X509_F_NETSCAPE_SPKI_B64_DECODE                  129
01270 #define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130
01271 #define X509_F_X509AT_ADD1_ATTR                          135
01272 #define X509_F_X509V3_ADD_EXT                            104
01273 #define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136
01274 #define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137
01275 #define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140
01276 #define X509_F_X509_ATTRIBUTE_GET0_DATA                  139
01277 #define X509_F_X509_ATTRIBUTE_SET1_DATA                  138
01278 #define X509_F_X509_CHECK_PRIVATE_KEY                    128
01279 #define X509_F_X509_CRL_PRINT_FP                         147
01280 #define X509_F_X509_EXTENSION_CREATE_BY_NID              108
01281 #define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109
01282 #define X509_F_X509_GET_PUBKEY_PARAMETERS                110
01283 #define X509_F_X509_LOAD_CERT_CRL_FILE                   132
01284 #define X509_F_X509_LOAD_CERT_FILE                       111
01285 #define X509_F_X509_LOAD_CRL_FILE                        112
01286 #define X509_F_X509_NAME_ADD_ENTRY                       113
01287 #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114
01288 #define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131
01289 #define X509_F_X509_NAME_ENTRY_SET_OBJECT                115
01290 #define X509_F_X509_NAME_ONELINE                         116
01291 #define X509_F_X509_NAME_PRINT                           117
01292 #define X509_F_X509_PRINT_EX_FP                          118
01293 #define X509_F_X509_PUBKEY_GET                           119
01294 #define X509_F_X509_PUBKEY_SET                           120
01295 #define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144
01296 #define X509_F_X509_REQ_PRINT_EX                         121
01297 #define X509_F_X509_REQ_PRINT_FP                         122
01298 #define X509_F_X509_REQ_TO_X509                          123
01299 #define X509_F_X509_STORE_ADD_CERT                       124
01300 #define X509_F_X509_STORE_ADD_CRL                        125
01301 #define X509_F_X509_STORE_CTX_GET1_ISSUER                146
01302 #define X509_F_X509_STORE_CTX_INIT                       143
01303 #define X509_F_X509_STORE_CTX_NEW                        142
01304 #define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134
01305 #define X509_F_X509_TO_X509_REQ                          126
01306 #define X509_F_X509_TRUST_ADD                            133
01307 #define X509_F_X509_TRUST_SET                            141
01308 #define X509_F_X509_VERIFY_CERT                          127
01309 
01310 /* Reason codes. */
01311 #define X509_R_BAD_X509_FILETYPE                         100
01312 #define X509_R_BASE64_DECODE_ERROR                       118
01313 #define X509_R_CANT_CHECK_DH_KEY                         114
01314 #define X509_R_CERT_ALREADY_IN_HASH_TABLE                101
01315 #define X509_R_ERR_ASN1_LIB                              102
01316 #define X509_R_INVALID_DIRECTORY                         113
01317 #define X509_R_INVALID_FIELD_NAME                        119
01318 #define X509_R_INVALID_TRUST                             123
01319 #define X509_R_KEY_TYPE_MISMATCH                         115
01320 #define X509_R_KEY_VALUES_MISMATCH                       116
01321 #define X509_R_LOADING_CERT_DIR                          103
01322 #define X509_R_LOADING_DEFAULTS                          104
01323 #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105
01324 #define X509_R_SHOULD_RETRY                              106
01325 #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107
01326 #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108
01327 #define X509_R_UNKNOWN_KEY_TYPE                          117
01328 #define X509_R_UNKNOWN_NID                               109
01329 #define X509_R_UNKNOWN_PURPOSE_ID                        121
01330 #define X509_R_UNKNOWN_TRUST_ID                          120
01331 #define X509_R_UNSUPPORTED_ALGORITHM                     111
01332 #define X509_R_WRONG_LOOKUP_TYPE                         112
01333 #define X509_R_WRONG_TYPE                                122
01334 
01335 #ifdef  __cplusplus
01336 }
01337 #endif
01338 #endif

Copyright © Nokia Corporation 2001-2008
Back to top