pem.h

Go to the documentation of this file.
00001 /* crypto/pem/pem.h */
00002 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
00003  * All rights reserved.
00004  *
00005  * This package is an SSL implementation written
00006  * by Eric Young (eay@cryptsoft.com).
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 (tjh@cryptsoft.com).
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 (eay@cryptsoft.com)"
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 (tjh@cryptsoft.com)"
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 #ifndef HEADER_PEM_H
00060 #define HEADER_PEM_H
00061 
00062 #include <openssl/e_os2.h>
00063 #ifndef OPENSSL_NO_BIO
00064 #include <openssl/bio.h>
00065 #endif
00066 #ifndef OPENSSL_NO_STACK
00067 #include <openssl/stack.h>
00068 #endif
00069 #include <openssl/evp.h>
00070 #include <openssl/x509.h>
00071 #include <openssl/pem2.h>
00072 
00073 #ifdef  __cplusplus
00074 extern "C" {
00075 #endif
00076 
00077 #define PEM_BUFSIZE     1024
00078 
00079 #define PEM_OBJ_UNDEF      0
00080 #define PEM_OBJ_X509    1
00081 #define PEM_OBJ_X509_REQ   2
00082 #define PEM_OBJ_CRL     3
00083 #define PEM_OBJ_SSL_SESSION   4
00084 #define PEM_OBJ_PRIV_KEY   10
00085 #define PEM_OBJ_PRIV_RSA   11
00086 #define PEM_OBJ_PRIV_DSA   12
00087 #define PEM_OBJ_PRIV_DH    13
00088 #define PEM_OBJ_PUB_RSA    14
00089 #define PEM_OBJ_PUB_DSA    15
00090 #define PEM_OBJ_PUB_DH     16
00091 #define PEM_OBJ_DHPARAMS   17
00092 #define PEM_OBJ_DSAPARAMS  18
00093 #define PEM_OBJ_PRIV_RSA_PUBLIC  19
00094 #define PEM_OBJ_PRIV_ECDSA 20
00095 #define PEM_OBJ_PUB_ECDSA  21
00096 #define PEM_OBJ_ECPARAMETERS  22
00097 
00098 #define PEM_ERROR    30
00099 #define PEM_DEK_DES_CBC         40
00100 #define PEM_DEK_IDEA_CBC        45
00101 #define PEM_DEK_DES_EDE         50
00102 #define PEM_DEK_DES_ECB         60
00103 #define PEM_DEK_RSA             70
00104 #define PEM_DEK_RSA_MD2         80
00105 #define PEM_DEK_RSA_MD5         90
00106 
00107 #define PEM_MD_MD2      NID_md2
00108 #define PEM_MD_MD5      NID_md5
00109 #define PEM_MD_SHA      NID_sha
00110 #define PEM_MD_MD2_RSA     NID_md2WithRSAEncryption
00111 #define PEM_MD_MD5_RSA     NID_md5WithRSAEncryption
00112 #define PEM_MD_SHA_RSA     NID_sha1WithRSAEncryption
00113 
00114 #define PEM_STRING_X509_OLD   "X509 CERTIFICATE"
00115 #define PEM_STRING_X509    "CERTIFICATE"
00116 #define PEM_STRING_X509_PAIR  "CERTIFICATE PAIR"
00117 #define PEM_STRING_X509_TRUSTED  "TRUSTED CERTIFICATE"
00118 #define PEM_STRING_X509_REQ_OLD  "NEW CERTIFICATE REQUEST"
00119 #define PEM_STRING_X509_REQ   "CERTIFICATE REQUEST"
00120 #define PEM_STRING_X509_CRL   "X509 CRL"
00121 #define PEM_STRING_EVP_PKEY   "ANY PRIVATE KEY"
00122 #define PEM_STRING_PUBLIC  "PUBLIC KEY"
00123 #define PEM_STRING_RSA     "RSA PRIVATE KEY"
00124 #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
00125 #define PEM_STRING_DSA     "DSA PRIVATE KEY"
00126 #define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
00127 #define PEM_STRING_PKCS7   "PKCS7"
00128 #define PEM_STRING_PKCS8   "ENCRYPTED PRIVATE KEY"
00129 #define PEM_STRING_PKCS8INF   "PRIVATE KEY"
00130 #define PEM_STRING_DHPARAMS   "DH PARAMETERS"
00131 #define PEM_STRING_SSL_SESSION   "SSL SESSION PARAMETERS"
00132 #define PEM_STRING_DSAPARAMS  "DSA PARAMETERS"
00133 #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
00134 #define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
00135 #define PEM_STRING_ECPRIVATEKEY  "EC PRIVATE KEY"
00136 
00137   /* Note that this structure is initialised by PEM_SealInit and cleaned up
00138      by PEM_SealFinal (at least for now) */
00139 typedef struct PEM_Encode_Seal_st
00140    {
00141    EVP_ENCODE_CTX encode;
00142    EVP_MD_CTX md;
00143    EVP_CIPHER_CTX cipher;
00144    } PEM_ENCODE_SEAL_CTX;
00145 
00146 /* enc_type is one off */
00147 #define PEM_TYPE_ENCRYPTED      10
00148 #define PEM_TYPE_MIC_ONLY       20
00149 #define PEM_TYPE_MIC_CLEAR      30
00150 #define PEM_TYPE_CLEAR     40
00151 
00152 typedef struct pem_recip_st
00153    {
00154    char *name;
00155    X509_NAME *dn;
00156 
00157    int cipher;
00158    int key_enc;
00159    /* char iv[8]; unused and wrong size */
00160    } PEM_USER;
00161 
00162 typedef struct pem_ctx_st
00163    {
00164    int type;      /* what type of object */
00165 
00166    struct   {
00167       int version;
00168       int mode;
00169       } proc_type;
00170 
00171    char *domain;
00172 
00173    struct   {
00174       int cipher;
00175    /* unused, and wrong size
00176       unsigned char iv[8]; */
00177       } DEK_info;
00178 
00179    PEM_USER *originator;
00180 
00181    int num_recipient;
00182    PEM_USER **recipient;
00183 
00184 #ifndef OPENSSL_NO_STACK
00185    STACK *x509_chain;   /* certificate chain */
00186 #else
00187    char *x509_chain; /* certificate chain */
00188 #endif
00189    EVP_MD *md;    /* signature type */
00190 
00191    int md_enc;    /* is the md encrypted or not? */
00192    int md_len;    /* length of md_data */
00193    char *md_data;    /* message digest, could be pkey encrypted */
00194 
00195    EVP_CIPHER *dec;  /* date encryption cipher */
00196    int key_len;      /* key length */
00197    unsigned char *key;  /* key */
00198    /* unused, and wrong size
00199       unsigned char iv[8]; */
00200 
00201 
00202    int  data_enc;    /* is the data encrypted */
00203    int data_len;
00204    unsigned char *data;
00205    } PEM_CTX;
00206 
00207 /* These macros make the PEM_read/PEM_write functions easier to maintain and
00208  * write. Now they are all implemented with either:
00209  * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
00210  */
00211 
00212 #ifdef OPENSSL_NO_FP_API
00213 
00214 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) 
00215 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) 
00216 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 
00217 
00218 #else
00219 
00220 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
00221 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
00222 { \
00223 return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \
00224 }
00225 
00226 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
00227 int PEM_write_##name(FILE *fp, type *x) \
00228 { \
00229 return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
00230 }
00231 
00232 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
00233 int PEM_write_##name(FILE *fp, const type *x) \
00234 { \
00235 return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
00236 }
00237 
00238 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
00239 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
00240         unsigned char *kstr, int klen, pem_password_cb *cb, \
00241         void *u) \
00242    { \
00243    return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
00244    }
00245 
00246 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
00247 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
00248         unsigned char *kstr, int klen, pem_password_cb *cb, \
00249         void *u) \
00250    { \
00251    return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
00252    }
00253 
00254 #endif
00255 
00256 #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
00257 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
00258 { \
00259 return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \
00260 }
00261 
00262 #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
00263 int PEM_write_bio_##name(BIO *bp, type *x) \
00264 { \
00265 return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
00266 }
00267 
00268 #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
00269 int PEM_write_bio_##name(BIO *bp, const type *x) \
00270 { \
00271 return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
00272 }
00273 
00274 #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
00275 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
00276         unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
00277    { \
00278    return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
00279    }
00280 
00281 #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
00282 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
00283         unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
00284    { \
00285    return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
00286    }
00287 
00288 #define IMPLEMENT_PEM_write(name, type, str, asn1) \
00289    IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
00290    IMPLEMENT_PEM_write_fp(name, type, str, asn1)
00291 
00292 #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
00293    IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
00294    IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
00295 
00296 #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
00297    IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
00298    IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
00299 
00300 #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
00301    IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
00302    IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
00303 
00304 #define IMPLEMENT_PEM_read(name, type, str, asn1) \
00305    IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
00306    IMPLEMENT_PEM_read_fp(name, type, str, asn1)
00307 
00308 #define IMPLEMENT_PEM_rw(name, type, str, asn1) \
00309    IMPLEMENT_PEM_read(name, type, str, asn1) \
00310    IMPLEMENT_PEM_write(name, type, str, asn1)
00311 
00312 #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
00313    IMPLEMENT_PEM_read(name, type, str, asn1) \
00314    IMPLEMENT_PEM_write_const(name, type, str, asn1)
00315 
00316 #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
00317    IMPLEMENT_PEM_read(name, type, str, asn1) \
00318    IMPLEMENT_PEM_write_cb(name, type, str, asn1)
00319 
00320 /* These are the same except they are for the declarations */
00321 
00322 #if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API)
00323 
00324 #define DECLARE_PEM_read_fp(name, type) 
00325 #define DECLARE_PEM_write_fp(name, type) 
00326 #define DECLARE_PEM_write_cb_fp(name, type) 
00327 
00328 #else
00329 
00330 #define DECLARE_PEM_read_fp(name, type) \
00331    type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
00332 
00333 #define DECLARE_PEM_write_fp(name, type) \
00334    int PEM_write_##name(FILE *fp, type *x);
00335 
00336 #define DECLARE_PEM_write_fp_const(name, type) \
00337    int PEM_write_##name(FILE *fp, const type *x);
00338 
00339 #define DECLARE_PEM_write_cb_fp(name, type) \
00340    int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
00341         unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
00342 
00343 #endif
00344 
00345 #ifndef OPENSSL_NO_BIO
00346 #define DECLARE_PEM_read_bio(name, type) \
00347    type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
00348 
00349 #define DECLARE_PEM_write_bio(name, type) \
00350    int PEM_write_bio_##name(BIO *bp, type *x);
00351 
00352 #define DECLARE_PEM_write_bio_const(name, type) \
00353    int PEM_write_bio_##name(BIO *bp, const type *x);
00354 
00355 #define DECLARE_PEM_write_cb_bio(name, type) \
00356    int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
00357         unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
00358 
00359 #else
00360 
00361 #define DECLARE_PEM_read_bio(name, type) 
00362 #define DECLARE_PEM_write_bio(name, type) 
00363 #define DECLARE_PEM_write_cb_bio(name, type) 
00364 
00365 #endif
00366 
00367 #define DECLARE_PEM_write(name, type) \
00368    DECLARE_PEM_write_bio(name, type) \
00369    DECLARE_PEM_write_fp(name, type)
00370 
00371 #define DECLARE_PEM_write_const(name, type) \
00372    DECLARE_PEM_write_bio_const(name, type) \
00373    DECLARE_PEM_write_fp_const(name, type)
00374 
00375 #define DECLARE_PEM_write_cb(name, type) \
00376    DECLARE_PEM_write_cb_bio(name, type) \
00377    DECLARE_PEM_write_cb_fp(name, type)
00378 
00379 #define DECLARE_PEM_read(name, type) \
00380    DECLARE_PEM_read_bio(name, type) \
00381    DECLARE_PEM_read_fp(name, type)
00382 
00383 #define DECLARE_PEM_rw(name, type) \
00384    DECLARE_PEM_read(name, type) \
00385    DECLARE_PEM_write(name, type)
00386 
00387 #define DECLARE_PEM_rw_const(name, type) \
00388    DECLARE_PEM_read(name, type) \
00389    DECLARE_PEM_write_const(name, type)
00390 
00391 #define DECLARE_PEM_rw_cb(name, type) \
00392    DECLARE_PEM_read(name, type) \
00393    DECLARE_PEM_write_cb(name, type)
00394 
00395 #ifdef SSLEAY_MACROS
00396 
00397 #define PEM_write_SSL_SESSION(fp,x) \
00398       PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
00399          PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
00400 #define PEM_write_X509(fp,x) \
00401       PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
00402          (char *)x, NULL,NULL,0,NULL,NULL)
00403 #define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
00404       (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
00405          NULL,NULL,0,NULL,NULL)
00406 #define PEM_write_X509_CRL(fp,x) \
00407       PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
00408          fp,(char *)x, NULL,NULL,0,NULL,NULL)
00409 #define  PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
00410       PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
00411          (char *)x,enc,kstr,klen,cb,u)
00412 #define  PEM_write_RSAPublicKey(fp,x) \
00413       PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
00414          PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
00415 #define  PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
00416       PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
00417          (char *)x,enc,kstr,klen,cb,u)
00418 #define  PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
00419       PEM_ASN1_write((int (*)())i2d_PrivateKey,\
00420       (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
00421          bp,(char *)x,enc,kstr,klen,cb,u)
00422 #define PEM_write_PKCS7(fp,x) \
00423       PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
00424          (char *)x, NULL,NULL,0,NULL,NULL)
00425 #define PEM_write_DHparams(fp,x) \
00426       PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
00427          (char *)x,NULL,NULL,0,NULL,NULL)
00428 
00429 #define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
00430                 PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
00431          PEM_STRING_X509,fp, \
00432                         (char *)x, NULL,NULL,0,NULL,NULL)
00433 
00434 #define  PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
00435    (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
00436 #define  PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \
00437    (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u)
00438 #define  PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \
00439    (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u)
00440 #define  PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \
00441    (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u)
00442 #define  PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
00443    (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u)
00444 #define  PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
00445    (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u)
00446 #define  PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
00447    (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u)
00448 #define  PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \
00449    (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u)
00450 #define  PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \
00451    (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u)
00452 #define  PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \
00453    (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u)
00454 
00455 #define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \
00456       (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
00457         (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
00458                      (char **)x,cb,u)
00459 
00460 #define PEM_write_bio_X509(bp,x) \
00461       PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
00462          (char *)x, NULL,NULL,0,NULL,NULL)
00463 #define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
00464       (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
00465          NULL,NULL,0,NULL,NULL)
00466 #define PEM_write_bio_X509_CRL(bp,x) \
00467       PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
00468          bp,(char *)x, NULL,NULL,0,NULL,NULL)
00469 #define  PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
00470       PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
00471          bp,(char *)x,enc,kstr,klen,cb,u)
00472 #define  PEM_write_bio_RSAPublicKey(bp,x) \
00473       PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
00474          PEM_STRING_RSA_PUBLIC,\
00475          bp,(char *)x,NULL,NULL,0,NULL,NULL)
00476 #define  PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
00477       PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
00478          bp,(char *)x,enc,kstr,klen,cb,u)
00479 #define  PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
00480       PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
00481       (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
00482          bp,(char *)x,enc,kstr,klen,cb,u)
00483 #define PEM_write_bio_PKCS7(bp,x) \
00484       PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
00485          (char *)x, NULL,NULL,0,NULL,NULL)
00486 #define PEM_write_bio_DHparams(bp,x) \
00487       PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
00488          bp,(char *)x,NULL,NULL,0,NULL,NULL)
00489 #define PEM_write_bio_DSAparams(bp,x) \
00490       PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
00491          PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL)
00492 
00493 #define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
00494                 PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
00495          PEM_STRING_X509,bp, \
00496                         (char *)x, NULL,NULL,0,NULL,NULL)
00497 
00498 #define  PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
00499    (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
00500 #define  PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
00501    (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u)
00502 #define  PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \
00503    (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u)
00504 #define  PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
00505    (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u)
00506 #define  PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
00507    (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u)
00508 #define  PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
00509    (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u)
00510 #define  PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \
00511    (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u)
00512 
00513 #define  PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \
00514    (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u)
00515 #define  PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \
00516    (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u)
00517 #define  PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
00518    (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u)
00519 
00520 #define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \
00521       (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
00522         (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
00523                      (char **)x,cb,u)
00524 
00525 #endif
00526 
00527 #if 1
00528 /* "userdata": new with OpenSSL 0.9.4 */
00529 typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
00530 #else
00531 /* OpenSSL 0.9.3, 0.9.3a */
00532 typedef int pem_password_cb(char *buf, int size, int rwflag);
00533 #endif
00534 
00535 int   PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
00536 int   PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
00537    pem_password_cb *callback,void *u);
00538 
00539 #ifndef OPENSSL_NO_BIO
00540 int   PEM_read_bio(BIO *bp, char **name, char **header,
00541       unsigned char **data,long *len);
00542 int   PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
00543       long len);
00544 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
00545         pem_password_cb *cb, void *u);
00546 void *   PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
00547            void **x, pem_password_cb *cb, void *u);
00548 #define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
00549 ((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u)
00550 int   PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
00551             const EVP_CIPHER *enc,unsigned char *kstr,int klen,
00552             pem_password_cb *cb, void *u);
00553 #define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
00554    ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u)
00555 
00556 STACK_OF(X509_INFO) *   PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
00557 int   PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
00558       unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
00559 #endif
00560 
00561 #ifndef OPENSSL_SYS_WIN16
00562 int   PEM_read(FILE *fp, char **name, char **header,
00563       unsigned char **data,long *len);
00564 int   PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
00565 void *  PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
00566             pem_password_cb *cb, void *u);
00567 int   PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
00568              char *x,const EVP_CIPHER *enc,unsigned char *kstr,
00569              int klen,pem_password_cb *callback, void *u);
00570 STACK_OF(X509_INFO) *   PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
00571    pem_password_cb *cb, void *u);
00572 #endif
00573 
00574 int   PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
00575       EVP_MD *md_type, unsigned char **ek, int *ekl,
00576       unsigned char *iv, EVP_PKEY **pubk, int npubk);
00577 void  PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
00578       unsigned char *in, int inl);
00579 int   PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
00580       unsigned char *out, int *outl, EVP_PKEY *priv);
00581 
00582 void    PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
00583 void    PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
00584 int   PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
00585       unsigned int *siglen, EVP_PKEY *pkey);
00586 
00587 int   PEM_def_callback(char *buf, int num, int w, void *key);
00588 void  PEM_proc_type(char *buf, int type);
00589 void  PEM_dek_info(char *buf, const char *type, int len, char *str);
00590 
00591 #ifndef SSLEAY_MACROS
00592 
00593 #include <openssl/symhacks.h>
00594 
00595 DECLARE_PEM_rw(X509, X509)
00596 
00597 DECLARE_PEM_rw(X509_AUX, X509)
00598 
00599 DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)
00600 
00601 DECLARE_PEM_rw(X509_REQ, X509_REQ)
00602 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
00603 
00604 DECLARE_PEM_rw(X509_CRL, X509_CRL)
00605 
00606 DECLARE_PEM_rw(PKCS7, PKCS7)
00607 
00608 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
00609 
00610 DECLARE_PEM_rw(PKCS8, X509_SIG)
00611 
00612 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
00613 
00614 #ifndef OPENSSL_NO_RSA
00615 
00616 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
00617 
00618 DECLARE_PEM_rw_const(RSAPublicKey, RSA)
00619 DECLARE_PEM_rw(RSA_PUBKEY, RSA)
00620 
00621 #endif
00622 
00623 #ifndef OPENSSL_NO_DSA
00624 
00625 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
00626 
00627 DECLARE_PEM_rw(DSA_PUBKEY, DSA)
00628 
00629 DECLARE_PEM_rw_const(DSAparams, DSA)
00630 
00631 #endif
00632 
00633 #ifndef OPENSSL_NO_EC
00634 DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
00635 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
00636 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
00637 #endif
00638 
00639 #ifndef OPENSSL_NO_DH
00640 
00641 DECLARE_PEM_rw_const(DHparams, DH)
00642 
00643 #endif
00644 
00645 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
00646 
00647 DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
00648 
00649 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
00650               char *kstr, int klen,
00651               pem_password_cb *cb, void *u);
00652 int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
00653                                   char *, int, pem_password_cb *, void *);
00654 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
00655               char *kstr, int klen,
00656               pem_password_cb *cb, void *u);
00657 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
00658               char *kstr, int klen,
00659               pem_password_cb *cb, void *u);
00660 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
00661 
00662 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
00663               char *kstr, int klen,
00664               pem_password_cb *cb, void *u);
00665 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
00666               char *kstr, int klen,
00667               pem_password_cb *cb, void *u);
00668 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
00669               char *kstr, int klen,
00670               pem_password_cb *cb, void *u);
00671 
00672 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
00673 
00674 int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
00675                char *kstr,int klen, pem_password_cb *cd, void *u);
00676 
00677 #endif /* SSLEAY_MACROS */
00678 
00679 
00680 /* BEGIN ERROR CODES */
00681 /* The following lines are auto generated by the script mkerr.pl. Any changes
00682  * made after this point may be overwritten when the script is next run.
00683  */
00684 void ERR_load_PEM_strings(void);
00685 
00686 /* Error codes for the PEM functions. */
00687 
00688 /* Function codes. */
00689 #define PEM_F_D2I_PKCS8PRIVATEKEY_BIO         120
00690 #define PEM_F_D2I_PKCS8PRIVATEKEY_FP          121
00691 #define PEM_F_DO_PK8PKEY             126
00692 #define PEM_F_DO_PK8PKEY_FP             125
00693 #define PEM_F_LOAD_IV                101
00694 #define PEM_F_PEM_ASN1_READ             102
00695 #define PEM_F_PEM_ASN1_READ_BIO            103
00696 #define PEM_F_PEM_ASN1_WRITE            104
00697 #define PEM_F_PEM_ASN1_WRITE_BIO        105
00698 #define PEM_F_PEM_DEF_CALLBACK             100
00699 #define PEM_F_PEM_DO_HEADER             106
00700 #define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY       118
00701 #define PEM_F_PEM_GET_EVP_CIPHER_INFO         107
00702 #define PEM_F_PEM_PK8PKEY            119
00703 #define PEM_F_PEM_READ               108
00704 #define PEM_F_PEM_READ_BIO           109
00705 #define PEM_F_PEM_READ_BIO_PRIVATEKEY         123
00706 #define PEM_F_PEM_READ_PRIVATEKEY          124
00707 #define PEM_F_PEM_SEALFINAL             110
00708 #define PEM_F_PEM_SEALINIT           111
00709 #define PEM_F_PEM_SIGNFINAL             112
00710 #define PEM_F_PEM_WRITE              113
00711 #define PEM_F_PEM_WRITE_BIO             114
00712 #define PEM_F_PEM_X509_INFO_READ        115
00713 #define PEM_F_PEM_X509_INFO_READ_BIO          116
00714 #define PEM_F_PEM_X509_INFO_WRITE_BIO         117
00715 
00716 /* Reason codes. */
00717 #define PEM_R_BAD_BASE64_DECODE            100
00718 #define PEM_R_BAD_DECRYPT            101
00719 #define PEM_R_BAD_END_LINE           102
00720 #define PEM_R_BAD_IV_CHARS           103
00721 #define PEM_R_BAD_PASSWORD_READ            104
00722 #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY       115
00723 #define PEM_R_NOT_DEK_INFO           105
00724 #define PEM_R_NOT_ENCRYPTED             106
00725 #define PEM_R_NOT_PROC_TYPE             107
00726 #define PEM_R_NO_START_LINE             108
00727 #define PEM_R_PROBLEMS_GETTING_PASSWORD          109
00728 #define PEM_R_PUBLIC_KEY_NO_RSA            110
00729 #define PEM_R_READ_KEY               111
00730 #define PEM_R_SHORT_HEADER           112
00731 #define PEM_R_UNSUPPORTED_CIPHER        113
00732 #define PEM_R_UNSUPPORTED_ENCRYPTION          114
00733 
00734 #ifdef  __cplusplus
00735 }
00736 #endif
00737 #endif

Generated on Thu Aug 20 22:33:05 2009 for OpenXDAS by  doxygen 1.5.6