LTKCPP-- LLRP Toolkit C Plus Plus Library
|
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_PKCS7_SIGNED "PKCS #7 SIGNED DATA" 00129 # define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" 00130 # define PEM_STRING_PKCS8INF "PRIVATE KEY" 00131 # define PEM_STRING_DHPARAMS "DH PARAMETERS" 00132 # define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" 00133 # define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" 00134 # define PEM_STRING_DSAPARAMS "DSA PARAMETERS" 00135 # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" 00136 # define PEM_STRING_ECPARAMETERS "EC PARAMETERS" 00137 # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" 00138 # define PEM_STRING_PARAMETERS "PARAMETERS" 00139 # define PEM_STRING_CMS "CMS" 00140 00141 /* 00142 * Note that this structure is initialised by PEM_SealInit and cleaned up 00143 * by PEM_SealFinal (at least for now) 00144 */ 00145 typedef struct PEM_Encode_Seal_st { 00146 EVP_ENCODE_CTX encode; 00147 EVP_MD_CTX md; 00148 EVP_CIPHER_CTX cipher; 00149 } PEM_ENCODE_SEAL_CTX; 00150 00151 /* enc_type is one off */ 00152 # define PEM_TYPE_ENCRYPTED 10 00153 # define PEM_TYPE_MIC_ONLY 20 00154 # define PEM_TYPE_MIC_CLEAR 30 00155 # define PEM_TYPE_CLEAR 40 00156 00157 typedef struct pem_recip_st { 00158 char *name; 00159 X509_NAME *dn; 00160 int cipher; 00161 int key_enc; 00162 /* char iv[8]; unused and wrong size */ 00163 } PEM_USER; 00164 00165 typedef struct pem_ctx_st { 00166 int type; /* what type of object */ 00167 struct { 00168 int version; 00169 int mode; 00170 } proc_type; 00171 00172 char *domain; 00173 00174 struct { 00175 int cipher; 00176 /*- 00177 unused, and wrong size 00178 unsigned char iv[8]; */ 00179 } DEK_info; 00180 00181 PEM_USER *originator; 00182 00183 int num_recipient; 00184 PEM_USER **recipient; 00185 /*- 00186 XXX(ben): don#t think this is used! 00187 STACK *x509_chain; / * certificate chain */ 00188 EVP_MD *md; /* signature type */ 00189 00190 int md_enc; /* is the md encrypted or not? */ 00191 int md_len; /* length of md_data */ 00192 char *md_data; /* message digest, could be pkey encrypted */ 00193 00194 EVP_CIPHER *dec; /* date encryption cipher */ 00195 int key_len; /* key length */ 00196 unsigned char *key; /* key */ 00197 /*- 00198 unused, and wrong size 00199 unsigned char iv[8]; */ 00200 00201 int data_enc; /* is the data encrypted */ 00202 int data_len; 00203 unsigned char *data; 00204 } PEM_CTX; 00205 00206 /* 00207 * These macros make the PEM_read/PEM_write functions easier to maintain and 00208 * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or 00209 * 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_fp_const(name, type, str, asn1) 00217 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 00218 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) 00219 # else 00220 00221 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ 00222 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ 00223 { \ 00224 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ 00225 } 00226 00227 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ 00228 int PEM_write_##name(FILE *fp, type *x) \ 00229 { \ 00230 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ 00231 } 00232 00233 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ 00234 int PEM_write_##name(FILE *fp, const type *x) \ 00235 { \ 00236 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ 00237 } 00238 00239 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ 00240 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ 00241 unsigned char *kstr, int klen, pem_password_cb *cb, \ 00242 void *u) \ 00243 { \ 00244 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ 00245 } 00246 00247 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ 00248 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ 00249 unsigned char *kstr, int klen, pem_password_cb *cb, \ 00250 void *u) \ 00251 { \ 00252 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ 00253 } 00254 00255 # endif 00256 00257 # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 00258 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ 00259 { \ 00260 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ 00261 } 00262 00263 # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 00264 int PEM_write_bio_##name(BIO *bp, type *x) \ 00265 { \ 00266 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ 00267 } 00268 00269 # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 00270 int PEM_write_bio_##name(BIO *bp, const type *x) \ 00271 { \ 00272 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ 00273 } 00274 00275 # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 00276 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ 00277 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ 00278 { \ 00279 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ 00280 } 00281 00282 # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 00283 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ 00284 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ 00285 { \ 00286 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ 00287 } 00288 00289 # define IMPLEMENT_PEM_write(name, type, str, asn1) \ 00290 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 00291 IMPLEMENT_PEM_write_fp(name, type, str, asn1) 00292 00293 # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ 00294 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 00295 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) 00296 00297 # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ 00298 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 00299 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 00300 00301 # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ 00302 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 00303 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) 00304 00305 # define IMPLEMENT_PEM_read(name, type, str, asn1) \ 00306 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 00307 IMPLEMENT_PEM_read_fp(name, type, str, asn1) 00308 00309 # define IMPLEMENT_PEM_rw(name, type, str, asn1) \ 00310 IMPLEMENT_PEM_read(name, type, str, asn1) \ 00311 IMPLEMENT_PEM_write(name, type, str, asn1) 00312 00313 # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ 00314 IMPLEMENT_PEM_read(name, type, str, asn1) \ 00315 IMPLEMENT_PEM_write_const(name, type, str, asn1) 00316 00317 # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ 00318 IMPLEMENT_PEM_read(name, type, str, asn1) \ 00319 IMPLEMENT_PEM_write_cb(name, type, str, asn1) 00320 00321 /* These are the same except they are for the declarations */ 00322 00323 # if defined(OPENSSL_NO_FP_API) 00324 00325 # define DECLARE_PEM_read_fp(name, type) 00326 # define DECLARE_PEM_write_fp(name, type) 00327 # define DECLARE_PEM_write_cb_fp(name, type) 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_bio_const(name, type) 00364 # define DECLARE_PEM_write_cb_bio(name, type) 00365 # endif 00366 # define DECLARE_PEM_write(name, type) \ 00367 DECLARE_PEM_write_bio(name, type) \ 00368 DECLARE_PEM_write_fp(name, type) 00369 # define DECLARE_PEM_write_const(name, type) \ 00370 DECLARE_PEM_write_bio_const(name, type) \ 00371 DECLARE_PEM_write_fp_const(name, type) 00372 # define DECLARE_PEM_write_cb(name, type) \ 00373 DECLARE_PEM_write_cb_bio(name, type) \ 00374 DECLARE_PEM_write_cb_fp(name, type) 00375 # define DECLARE_PEM_read(name, type) \ 00376 DECLARE_PEM_read_bio(name, type) \ 00377 DECLARE_PEM_read_fp(name, type) 00378 # define DECLARE_PEM_rw(name, type) \ 00379 DECLARE_PEM_read(name, type) \ 00380 DECLARE_PEM_write(name, type) 00381 # define DECLARE_PEM_rw_const(name, type) \ 00382 DECLARE_PEM_read(name, type) \ 00383 DECLARE_PEM_write_const(name, type) 00384 # define DECLARE_PEM_rw_cb(name, type) \ 00385 DECLARE_PEM_read(name, type) \ 00386 DECLARE_PEM_write_cb(name, type) 00387 # if 1 00388 /* "userdata": new with OpenSSL 0.9.4 */ 00389 typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); 00390 # else 00391 /* OpenSSL 0.9.3, 0.9.3a */ 00392 typedef int pem_password_cb (char *buf, int size, int rwflag); 00393 # endif 00394 00395 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); 00396 int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, 00397 pem_password_cb *callback, void *u); 00398 00399 # ifndef OPENSSL_NO_BIO 00400 int PEM_read_bio(BIO *bp, char **name, char **header, 00401 unsigned char **data, long *len); 00402 int PEM_write_bio(BIO *bp, const char *name, const char *hdr, 00403 const unsigned char *data, long len); 00404 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, 00405 const char *name, BIO *bp, pem_password_cb *cb, 00406 void *u); 00407 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, 00408 pem_password_cb *cb, void *u); 00409 int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x, 00410 const EVP_CIPHER *enc, unsigned char *kstr, int klen, 00411 pem_password_cb *cb, void *u); 00412 00413 STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, 00414 pem_password_cb *cb, void *u); 00415 int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, 00416 unsigned char *kstr, int klen, 00417 pem_password_cb *cd, void *u); 00418 # endif 00419 00420 int PEM_read(FILE *fp, char **name, char **header, 00421 unsigned char **data, long *len); 00422 int PEM_write(FILE *fp, const char *name, const char *hdr, 00423 const unsigned char *data, long len); 00424 void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, 00425 pem_password_cb *cb, void *u); 00426 int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, 00427 void *x, const EVP_CIPHER *enc, unsigned char *kstr, 00428 int klen, pem_password_cb *callback, void *u); 00429 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, 00430 pem_password_cb *cb, void *u); 00431 00432 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, 00433 EVP_MD *md_type, unsigned char **ek, int *ekl, 00434 unsigned char *iv, EVP_PKEY **pubk, int npubk); 00435 void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, 00436 unsigned char *in, int inl); 00437 int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl, 00438 unsigned char *out, int *outl, EVP_PKEY *priv); 00439 00440 void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); 00441 void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); 00442 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, 00443 unsigned int *siglen, EVP_PKEY *pkey); 00444 00445 int PEM_def_callback(char *buf, int num, int w, void *key); 00446 void PEM_proc_type(char *buf, int type); 00447 void PEM_dek_info(char *buf, const char *type, int len, char *str); 00448 00449 # include <openssl/symhacks.h> 00450 00451 DECLARE_PEM_rw(X509, X509) 00452 DECLARE_PEM_rw(X509_AUX, X509) 00453 DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) 00454 DECLARE_PEM_rw(X509_REQ, X509_REQ) 00455 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) 00456 DECLARE_PEM_rw(X509_CRL, X509_CRL) 00457 DECLARE_PEM_rw(PKCS7, PKCS7) 00458 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) 00459 DECLARE_PEM_rw(PKCS8, X509_SIG) 00460 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) 00461 # ifndef OPENSSL_NO_RSA 00462 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 00463 DECLARE_PEM_rw_const(RSAPublicKey, RSA) 00464 DECLARE_PEM_rw(RSA_PUBKEY, RSA) 00465 # endif 00466 # ifndef OPENSSL_NO_DSA 00467 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 00468 DECLARE_PEM_rw(DSA_PUBKEY, DSA) 00469 DECLARE_PEM_rw_const(DSAparams, DSA) 00470 # endif 00471 # ifndef OPENSSL_NO_EC 00472 DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) 00473 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) 00474 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) 00475 # endif 00476 # ifndef OPENSSL_NO_DH 00477 DECLARE_PEM_rw_const(DHparams, DH) 00478 DECLARE_PEM_write_const(DHxparams, DH) 00479 # endif 00480 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) 00481 DECLARE_PEM_rw(PUBKEY, EVP_PKEY) 00482 00483 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, 00484 char *kstr, int klen, 00485 pem_password_cb *cb, void *u); 00486 int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, 00487 char *, int, pem_password_cb *, void *); 00488 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, 00489 char *kstr, int klen, 00490 pem_password_cb *cb, void *u); 00491 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, 00492 char *kstr, int klen, 00493 pem_password_cb *cb, void *u); 00494 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 00495 void *u); 00496 00497 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, 00498 char *kstr, int klen, 00499 pem_password_cb *cb, void *u); 00500 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, 00501 char *kstr, int klen, 00502 pem_password_cb *cb, void *u); 00503 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, 00504 char *kstr, int klen, 00505 pem_password_cb *cb, void *u); 00506 00507 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, 00508 void *u); 00509 00510 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, 00511 char *kstr, int klen, pem_password_cb *cd, 00512 void *u); 00513 00514 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); 00515 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); 00516 00517 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); 00518 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); 00519 EVP_PKEY *b2i_PrivateKey_bio(BIO *in); 00520 EVP_PKEY *b2i_PublicKey_bio(BIO *in); 00521 int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); 00522 int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); 00523 # ifndef OPENSSL_NO_RC4 00524 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); 00525 int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, 00526 pem_password_cb *cb, void *u); 00527 # endif 00528 00529 /* BEGIN ERROR CODES */ 00530 /* 00531 * The following lines are auto generated by the script mkerr.pl. Any changes 00532 * made after this point may be overwritten when the script is next run. 00533 */ 00534 void ERR_load_PEM_strings(void); 00535 00536 /* Error codes for the PEM functions. */ 00537 00538 /* Function codes. */ 00539 # define PEM_F_B2I_DSS 127 00540 # define PEM_F_B2I_PVK_BIO 128 00541 # define PEM_F_B2I_RSA 129 00542 # define PEM_F_CHECK_BITLEN_DSA 130 00543 # define PEM_F_CHECK_BITLEN_RSA 131 00544 # define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 00545 # define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 00546 # define PEM_F_DO_B2I 132 00547 # define PEM_F_DO_B2I_BIO 133 00548 # define PEM_F_DO_BLOB_HEADER 134 00549 # define PEM_F_DO_PK8PKEY 126 00550 # define PEM_F_DO_PK8PKEY_FP 125 00551 # define PEM_F_DO_PVK_BODY 135 00552 # define PEM_F_DO_PVK_HEADER 136 00553 # define PEM_F_I2B_PVK 137 00554 # define PEM_F_I2B_PVK_BIO 138 00555 # define PEM_F_LOAD_IV 101 00556 # define PEM_F_PEM_ASN1_READ 102 00557 # define PEM_F_PEM_ASN1_READ_BIO 103 00558 # define PEM_F_PEM_ASN1_WRITE 104 00559 # define PEM_F_PEM_ASN1_WRITE_BIO 105 00560 # define PEM_F_PEM_DEF_CALLBACK 100 00561 # define PEM_F_PEM_DO_HEADER 106 00562 # define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 00563 # define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 00564 # define PEM_F_PEM_PK8PKEY 119 00565 # define PEM_F_PEM_READ 108 00566 # define PEM_F_PEM_READ_BIO 109 00567 # define PEM_F_PEM_READ_BIO_DHPARAMS 141 00568 # define PEM_F_PEM_READ_BIO_PARAMETERS 140 00569 # define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 00570 # define PEM_F_PEM_READ_DHPARAMS 142 00571 # define PEM_F_PEM_READ_PRIVATEKEY 124 00572 # define PEM_F_PEM_SEALFINAL 110 00573 # define PEM_F_PEM_SEALINIT 111 00574 # define PEM_F_PEM_SIGNFINAL 112 00575 # define PEM_F_PEM_WRITE 113 00576 # define PEM_F_PEM_WRITE_BIO 114 00577 # define PEM_F_PEM_WRITE_PRIVATEKEY 139 00578 # define PEM_F_PEM_X509_INFO_READ 115 00579 # define PEM_F_PEM_X509_INFO_READ_BIO 116 00580 # define PEM_F_PEM_X509_INFO_WRITE_BIO 117 00581 00582 /* Reason codes. */ 00583 # define PEM_R_BAD_BASE64_DECODE 100 00584 # define PEM_R_BAD_DECRYPT 101 00585 # define PEM_R_BAD_END_LINE 102 00586 # define PEM_R_BAD_IV_CHARS 103 00587 # define PEM_R_BAD_MAGIC_NUMBER 116 00588 # define PEM_R_BAD_PASSWORD_READ 104 00589 # define PEM_R_BAD_VERSION_NUMBER 117 00590 # define PEM_R_BIO_WRITE_FAILURE 118 00591 # define PEM_R_CIPHER_IS_NULL 127 00592 # define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 00593 # define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 00594 # define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 00595 # define PEM_R_INCONSISTENT_HEADER 121 00596 # define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 00597 # define PEM_R_KEYBLOB_TOO_SHORT 123 00598 # define PEM_R_NOT_DEK_INFO 105 00599 # define PEM_R_NOT_ENCRYPTED 106 00600 # define PEM_R_NOT_PROC_TYPE 107 00601 # define PEM_R_NO_START_LINE 108 00602 # define PEM_R_PROBLEMS_GETTING_PASSWORD 109 00603 # define PEM_R_PUBLIC_KEY_NO_RSA 110 00604 # define PEM_R_PVK_DATA_TOO_SHORT 124 00605 # define PEM_R_PVK_TOO_SHORT 125 00606 # define PEM_R_READ_KEY 111 00607 # define PEM_R_SHORT_HEADER 112 00608 # define PEM_R_UNSUPPORTED_CIPHER 113 00609 # define PEM_R_UNSUPPORTED_ENCRYPTION 114 00610 # define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 00611 00612 #ifdef __cplusplus 00613 } 00614 #endif 00615 #endif