File indexing completed on 2026-04-02 08:13:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef OPENSSL_PEM_H
0011 # define OPENSSL_PEM_H
0012 # pragma once
0013
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 # define HEADER_PEM_H
0017 # endif
0018
0019 # include <openssl/e_os2.h>
0020 # include <openssl/bio.h>
0021 # include <openssl/safestack.h>
0022 # include <openssl/evp.h>
0023 # include <openssl/x509.h>
0024 # include <openssl/pemerr.h>
0025 # ifndef OPENSSL_NO_STDIO
0026 # include <stdio.h>
0027 # endif
0028
0029 #ifdef __cplusplus
0030 extern "C" {
0031 #endif
0032
0033 # define PEM_BUFSIZE 1024
0034
0035 # define PEM_STRING_X509_OLD "X509 CERTIFICATE"
0036 # define PEM_STRING_X509 "CERTIFICATE"
0037 # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
0038 # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
0039 # define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
0040 # define PEM_STRING_X509_CRL "X509 CRL"
0041 # define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
0042 # define PEM_STRING_PUBLIC "PUBLIC KEY"
0043 # define PEM_STRING_RSA "RSA PRIVATE KEY"
0044 # define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
0045 # define PEM_STRING_DSA "DSA PRIVATE KEY"
0046 # define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
0047 # define PEM_STRING_PKCS7 "PKCS7"
0048 # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
0049 # define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
0050 # define PEM_STRING_PKCS8INF "PRIVATE KEY"
0051 # define PEM_STRING_DHPARAMS "DH PARAMETERS"
0052 # define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
0053 # define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
0054 # define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
0055 # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
0056 # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
0057 # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
0058 # define PEM_STRING_PARAMETERS "PARAMETERS"
0059 # define PEM_STRING_CMS "CMS"
0060 # define PEM_STRING_SM2PRIVATEKEY "SM2 PRIVATE KEY"
0061 # define PEM_STRING_SM2PARAMETERS "SM2 PARAMETERS"
0062 # define PEM_STRING_ACERT "ATTRIBUTE CERTIFICATE"
0063
0064 # define PEM_TYPE_ENCRYPTED 10
0065 # define PEM_TYPE_MIC_ONLY 20
0066 # define PEM_TYPE_MIC_CLEAR 30
0067 # define PEM_TYPE_CLEAR 40
0068
0069
0070
0071
0072
0073
0074
0075 # define PEM_read_cb_fnsig(name, type, INTYPE, readname) \
0076 type *PEM_##readname##_##name(INTYPE *out, type **x, \
0077 pem_password_cb *cb, void *u)
0078 # define PEM_read_cb_ex_fnsig(name, type, INTYPE, readname) \
0079 type *PEM_##readname##_##name##_ex(INTYPE *out, type **x, \
0080 pem_password_cb *cb, void *u, \
0081 OSSL_LIB_CTX *libctx, \
0082 const char *propq)
0083
0084 # define PEM_write_fnsig(name, type, OUTTYPE, writename) \
0085 int PEM_##writename##_##name(OUTTYPE *out, const type *x)
0086 # define PEM_write_cb_fnsig(name, type, OUTTYPE, writename) \
0087 int PEM_##writename##_##name(OUTTYPE *out, const type *x, \
0088 const EVP_CIPHER *enc, \
0089 const unsigned char *kstr, int klen, \
0090 pem_password_cb *cb, void *u)
0091 # define PEM_write_ex_fnsig(name, type, OUTTYPE, writename) \
0092 int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, \
0093 OSSL_LIB_CTX *libctx, \
0094 const char *propq)
0095 # define PEM_write_cb_ex_fnsig(name, type, OUTTYPE, writename) \
0096 int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, \
0097 const EVP_CIPHER *enc, \
0098 const unsigned char *kstr, int klen, \
0099 pem_password_cb *cb, void *u, \
0100 OSSL_LIB_CTX *libctx, \
0101 const char *propq)
0102
0103 # ifdef OPENSSL_NO_STDIO
0104
0105 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1)
0106 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1)
0107 # ifndef OPENSSL_NO_DEPRECATED_3_0
0108 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
0109 # endif
0110 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
0111 # ifndef OPENSSL_NO_DEPRECATED_3_0
0112 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
0113 # endif
0114 # else
0115
0116 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
0117 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \
0118 { \
0119 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp, \
0120 (void **)x, cb, u); \
0121 }
0122
0123 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
0124 PEM_write_fnsig(name, type, FILE, write) \
0125 { \
0126 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \
0127 x, NULL, NULL, 0, NULL, NULL); \
0128 }
0129
0130 # ifndef OPENSSL_NO_DEPRECATED_3_0
0131 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
0132 IMPLEMENT_PEM_write_fp(name, type, str, asn1)
0133 # endif
0134
0135 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
0136 PEM_write_cb_fnsig(name, type, FILE, write) \
0137 { \
0138 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \
0139 x, enc, kstr, klen, cb, u); \
0140 }
0141
0142 # ifndef OPENSSL_NO_DEPRECATED_3_0
0143 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
0144 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
0145 # endif
0146 # endif
0147
0148 # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
0149 type *PEM_read_bio_##name(BIO *bp, type **x, \
0150 pem_password_cb *cb, void *u) \
0151 { \
0152 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp, \
0153 (void **)x, cb, u); \
0154 }
0155
0156 # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
0157 PEM_write_fnsig(name, type, BIO, write_bio) \
0158 { \
0159 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \
0160 x, NULL,NULL,0,NULL,NULL); \
0161 }
0162
0163 # ifndef OPENSSL_NO_DEPRECATED_3_0
0164 # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
0165 IMPLEMENT_PEM_write_bio(name, type, str, asn1)
0166 # endif
0167
0168 # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
0169 PEM_write_cb_fnsig(name, type, BIO, write_bio) \
0170 { \
0171 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \
0172 x, enc, kstr, klen, cb, u); \
0173 }
0174
0175 # ifndef OPENSSL_NO_DEPRECATED_3_0
0176 # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
0177 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1)
0178 # endif
0179
0180 # define IMPLEMENT_PEM_write(name, type, str, asn1) \
0181 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
0182 IMPLEMENT_PEM_write_fp(name, type, str, asn1)
0183
0184 # ifndef OPENSSL_NO_DEPRECATED_3_0
0185 # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
0186 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
0187 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
0188 # endif
0189
0190 # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
0191 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
0192 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
0193
0194 # ifndef OPENSSL_NO_DEPRECATED_3_0
0195 # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
0196 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
0197 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
0198 # endif
0199
0200 # define IMPLEMENT_PEM_read(name, type, str, asn1) \
0201 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
0202 IMPLEMENT_PEM_read_fp(name, type, str, asn1)
0203
0204 # define IMPLEMENT_PEM_rw(name, type, str, asn1) \
0205 IMPLEMENT_PEM_read(name, type, str, asn1) \
0206 IMPLEMENT_PEM_write(name, type, str, asn1)
0207
0208 # ifndef OPENSSL_NO_DEPRECATED_3_0
0209 # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
0210 IMPLEMENT_PEM_read(name, type, str, asn1) \
0211 IMPLEMENT_PEM_write_const(name, type, str, asn1)
0212 # endif
0213
0214 # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
0215 IMPLEMENT_PEM_read(name, type, str, asn1) \
0216 IMPLEMENT_PEM_write_cb(name, type, str, asn1)
0217
0218
0219
0220
0221
0222
0223
0224
0225 # if defined(OPENSSL_NO_STDIO)
0226
0227 # define DECLARE_PEM_read_fp_attr(attr, name, type)
0228 # define DECLARE_PEM_read_fp_ex_attr(attr, name, type)
0229 # define DECLARE_PEM_write_fp_attr(attr, name, type)
0230 # define DECLARE_PEM_write_fp_ex_attr(attr, name, type)
0231 # ifndef OPENSSL_NO_DEPRECATED_3_0
0232 # define DECLARE_PEM_write_fp_const_attr(attr, name, type)
0233 # endif
0234 # define DECLARE_PEM_write_cb_fp_attr(attr, name, type)
0235 # define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type)
0236
0237 # else
0238
0239 # define DECLARE_PEM_read_fp_attr(attr, name, type) \
0240 attr PEM_read_cb_fnsig(name, type, FILE, read);
0241 # define DECLARE_PEM_read_fp_ex_attr(attr, name, type) \
0242 attr PEM_read_cb_fnsig(name, type, FILE, read); \
0243 attr PEM_read_cb_ex_fnsig(name, type, FILE, read);
0244
0245 # define DECLARE_PEM_write_fp_attr(attr, name, type) \
0246 attr PEM_write_fnsig(name, type, FILE, write);
0247 # define DECLARE_PEM_write_fp_ex_attr(attr, name, type) \
0248 attr PEM_write_fnsig(name, type, FILE, write); \
0249 attr PEM_write_ex_fnsig(name, type, FILE, write);
0250 # ifndef OPENSSL_NO_DEPRECATED_3_0
0251 # define DECLARE_PEM_write_fp_const_attr(attr, name, type) \
0252 attr PEM_write_fnsig(name, type, FILE, write);
0253 # endif
0254 # define DECLARE_PEM_write_cb_fp_attr(attr, name, type) \
0255 attr PEM_write_cb_fnsig(name, type, FILE, write);
0256 # define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) \
0257 attr PEM_write_cb_fnsig(name, type, FILE, write); \
0258 attr PEM_write_cb_ex_fnsig(name, type, FILE, write);
0259
0260 # endif
0261
0262 # define DECLARE_PEM_read_fp(name, type) \
0263 DECLARE_PEM_read_fp_attr(extern, name, type)
0264 # define DECLARE_PEM_write_fp(name, type) \
0265 DECLARE_PEM_write_fp_attr(extern, name, type)
0266 # ifndef OPENSSL_NO_DEPRECATED_3_0
0267 # define DECLARE_PEM_write_fp_const(name, type) \
0268 DECLARE_PEM_write_fp_const_attr(extern, name, type)
0269 # endif
0270 # define DECLARE_PEM_write_cb_fp(name, type) \
0271 DECLARE_PEM_write_cb_fp_attr(extern, name, type)
0272
0273 # define DECLARE_PEM_read_bio_attr(attr, name, type) \
0274 attr PEM_read_cb_fnsig(name, type, BIO, read_bio);
0275 # define DECLARE_PEM_read_bio_ex_attr(attr, name, type) \
0276 attr PEM_read_cb_fnsig(name, type, BIO, read_bio); \
0277 attr PEM_read_cb_ex_fnsig(name, type, BIO, read_bio);
0278 # define DECLARE_PEM_read_bio(name, type) \
0279 DECLARE_PEM_read_bio_attr(extern, name, type)
0280 # define DECLARE_PEM_read_bio_ex(name, type) \
0281 DECLARE_PEM_read_bio_ex_attr(extern, name, type)
0282
0283 # define DECLARE_PEM_write_bio_attr(attr, name, type) \
0284 attr PEM_write_fnsig(name, type, BIO, write_bio);
0285 # define DECLARE_PEM_write_bio_ex_attr(attr, name, type) \
0286 attr PEM_write_fnsig(name, type, BIO, write_bio); \
0287 attr PEM_write_ex_fnsig(name, type, BIO, write_bio);
0288 # define DECLARE_PEM_write_bio(name, type) \
0289 DECLARE_PEM_write_bio_attr(extern, name, type)
0290 # define DECLARE_PEM_write_bio_ex(name, type) \
0291 DECLARE_PEM_write_bio_ex_attr(extern, name, type)
0292
0293 # ifndef OPENSSL_NO_DEPRECATED_3_0
0294 # define DECLARE_PEM_write_bio_const_attr(attr, name, type) \
0295 attr PEM_write_fnsig(name, type, BIO, write_bio);
0296 # define DECLARE_PEM_write_bio_const(name, type) \
0297 DECLARE_PEM_write_bio_const_attr(extern, name, type)
0298 # endif
0299
0300 # define DECLARE_PEM_write_cb_bio_attr(attr, name, type) \
0301 attr PEM_write_cb_fnsig(name, type, BIO, write_bio);
0302 # define DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \
0303 attr PEM_write_cb_fnsig(name, type, BIO, write_bio); \
0304 attr PEM_write_cb_ex_fnsig(name, type, BIO, write_bio);
0305 # define DECLARE_PEM_write_cb_bio(name, type) \
0306 DECLARE_PEM_write_cb_bio_attr(extern, name, type)
0307 # define DECLARE_PEM_write_cb_ex_bio(name, type) \
0308 DECLARE_PEM_write_cb_bio_ex_attr(extern, name, type)
0309
0310 # define DECLARE_PEM_write_attr(attr, name, type) \
0311 DECLARE_PEM_write_bio_attr(attr, name, type) \
0312 DECLARE_PEM_write_fp_attr(attr, name, type)
0313 # define DECLARE_PEM_write_ex_attr(attr, name, type) \
0314 DECLARE_PEM_write_bio_ex_attr(attr, name, type) \
0315 DECLARE_PEM_write_fp_ex_attr(attr, name, type)
0316 # define DECLARE_PEM_write(name, type) \
0317 DECLARE_PEM_write_attr(extern, name, type)
0318 # define DECLARE_PEM_write_ex(name, type) \
0319 DECLARE_PEM_write_ex_attr(extern, name, type)
0320 # ifndef OPENSSL_NO_DEPRECATED_3_0
0321 # define DECLARE_PEM_write_const_attr(attr, name, type) \
0322 DECLARE_PEM_write_bio_const_attr(attr, name, type) \
0323 DECLARE_PEM_write_fp_const_attr(attr, name, type)
0324 # define DECLARE_PEM_write_const(name, type) \
0325 DECLARE_PEM_write_const_attr(extern, name, type)
0326 # endif
0327 # define DECLARE_PEM_write_cb_attr(attr, name, type) \
0328 DECLARE_PEM_write_cb_bio_attr(attr, name, type) \
0329 DECLARE_PEM_write_cb_fp_attr(attr, name, type)
0330 # define DECLARE_PEM_write_cb_ex_attr(attr, name, type) \
0331 DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \
0332 DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type)
0333 # define DECLARE_PEM_write_cb(name, type) \
0334 DECLARE_PEM_write_cb_attr(extern, name, type)
0335 # define DECLARE_PEM_write_cb_ex(name, type) \
0336 DECLARE_PEM_write_cb_ex_attr(extern, name, type)
0337 # define DECLARE_PEM_read_attr(attr, name, type) \
0338 DECLARE_PEM_read_bio_attr(attr, name, type) \
0339 DECLARE_PEM_read_fp_attr(attr, name, type)
0340 # define DECLARE_PEM_read_ex_attr(attr, name, type) \
0341 DECLARE_PEM_read_bio_ex_attr(attr, name, type) \
0342 DECLARE_PEM_read_fp_ex_attr(attr, name, type)
0343 # define DECLARE_PEM_read(name, type) \
0344 DECLARE_PEM_read_attr(extern, name, type)
0345 # define DECLARE_PEM_read_ex(name, type) \
0346 DECLARE_PEM_read_ex_attr(extern, name, type)
0347 # define DECLARE_PEM_rw_attr(attr, name, type) \
0348 DECLARE_PEM_read_attr(attr, name, type) \
0349 DECLARE_PEM_write_attr(attr, name, type)
0350 # define DECLARE_PEM_rw_ex_attr(attr, name, type) \
0351 DECLARE_PEM_read_ex_attr(attr, name, type) \
0352 DECLARE_PEM_write_ex_attr(attr, name, type)
0353 # define DECLARE_PEM_rw(name, type) \
0354 DECLARE_PEM_rw_attr(extern, name, type)
0355 # define DECLARE_PEM_rw_ex(name, type) \
0356 DECLARE_PEM_rw_ex_attr(extern, name, type)
0357 # ifndef OPENSSL_NO_DEPRECATED_3_0
0358 # define DECLARE_PEM_rw_const_attr(attr, name, type) \
0359 DECLARE_PEM_read_attr(attr, name, type) \
0360 DECLARE_PEM_write_const_attr(attr, name, type)
0361 # define DECLARE_PEM_rw_const(name, type) \
0362 DECLARE_PEM_rw_const_attr(extern, name, type)
0363 # endif
0364 # define DECLARE_PEM_rw_cb_attr(attr, name, type) \
0365 DECLARE_PEM_read_attr(attr, name, type) \
0366 DECLARE_PEM_write_cb_attr(attr, name, type)
0367 # define DECLARE_PEM_rw_cb_ex_attr(attr, name, type) \
0368 DECLARE_PEM_read_ex_attr(attr, name, type) \
0369 DECLARE_PEM_write_cb_ex_attr(attr, name, type)
0370 # define DECLARE_PEM_rw_cb(name, type) \
0371 DECLARE_PEM_rw_cb_attr(extern, name, type)
0372 # define DECLARE_PEM_rw_cb_ex(name, type) \
0373 DECLARE_PEM_rw_cb_ex_attr(extern, name, type)
0374
0375 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
0376 int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
0377 pem_password_cb *callback, void *u);
0378
0379 int PEM_read_bio(BIO *bp, char **name, char **header,
0380 unsigned char **data, long *len);
0381 # define PEM_FLAG_SECURE 0x1
0382 # define PEM_FLAG_EAY_COMPATIBLE 0x2
0383 # define PEM_FLAG_ONLY_B64 0x4
0384 int PEM_read_bio_ex(BIO *bp, char **name, char **header,
0385 unsigned char **data, long *len, unsigned int flags);
0386 int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
0387 const char *name, BIO *bp, pem_password_cb *cb,
0388 void *u);
0389 int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
0390 const unsigned char *data, long len);
0391 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
0392 const char *name, BIO *bp, pem_password_cb *cb,
0393 void *u);
0394 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
0395 pem_password_cb *cb, void *u);
0396 int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
0397 const void *x, const EVP_CIPHER *enc,
0398 const unsigned char *kstr, int klen,
0399 pem_password_cb *cb, void *u);
0400 int PEM_ASN1_write_bio_ctx(OSSL_i2d_of_void_ctx *i2d, void *vctx,
0401 const char *name, BIO *bp, const void *x,
0402 const EVP_CIPHER *enc, const unsigned char *kstr,
0403 int klen, pem_password_cb *cb, void *u);
0404
0405 STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
0406 pem_password_cb *cb, void *u);
0407 STACK_OF(X509_INFO)
0408 *PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) *sk,
0409 pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx,
0410 const char *propq);
0411
0412 int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc,
0413 const unsigned char *kstr, int klen,
0414 pem_password_cb *cd, void *u);
0415
0416 #ifndef OPENSSL_NO_STDIO
0417 int PEM_read(FILE *fp, char **name, char **header,
0418 unsigned char **data, long *len);
0419 int PEM_write(FILE *fp, const char *name, const char *hdr,
0420 const unsigned char *data, long len);
0421 void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
0422 pem_password_cb *cb, void *u);
0423 int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
0424 const void *x, const EVP_CIPHER *enc,
0425 const unsigned char *kstr, int klen,
0426 pem_password_cb *callback, void *u);
0427 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
0428 pem_password_cb *cb, void *u);
0429 STACK_OF(X509_INFO)
0430 *PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb,
0431 void *u, OSSL_LIB_CTX *libctx, const char *propq);
0432 #endif
0433
0434 int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
0435 int PEM_SignUpdate(EVP_MD_CTX *ctx, const unsigned char *d, unsigned int cnt);
0436 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
0437 unsigned int *siglen, EVP_PKEY *pkey);
0438
0439
0440 int PEM_def_callback(char *buf, int num, int rwflag, void *userdata);
0441 void PEM_proc_type(char *buf, int type);
0442 void PEM_dek_info(char *buf, const char *type, int len, const char *str);
0443
0444 # include <openssl/symhacks.h>
0445
0446 DECLARE_PEM_rw(X509, X509)
0447 DECLARE_PEM_rw(X509_AUX, X509)
0448 DECLARE_PEM_rw(X509_REQ, X509_REQ)
0449 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
0450 DECLARE_PEM_rw(X509_CRL, X509_CRL)
0451 DECLARE_PEM_rw(X509_PUBKEY, X509_PUBKEY)
0452 DECLARE_PEM_rw(PKCS7, PKCS7)
0453 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
0454 DECLARE_PEM_rw(PKCS8, X509_SIG)
0455 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
0456 # ifndef OPENSSL_NO_DEPRECATED_3_0
0457 DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, RSA)
0458 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, RSA)
0459 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA)
0460 # endif
0461 # ifndef OPENSSL_NO_DEPRECATED_3_0
0462 # ifndef OPENSSL_NO_DSA
0463 DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, DSAPrivateKey, DSA)
0464 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSA_PUBKEY, DSA)
0465 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSAparams, DSA)
0466 # endif
0467 # endif
0468
0469 # ifndef OPENSSL_NO_DEPRECATED_3_0
0470 # ifndef OPENSSL_NO_EC
0471 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, ECPKParameters, EC_GROUP)
0472 DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, ECPrivateKey, EC_KEY)
0473 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, EC_PUBKEY, EC_KEY)
0474 # endif
0475 # endif
0476
0477 # ifndef OPENSSL_NO_DH
0478 # ifndef OPENSSL_NO_DEPRECATED_3_0
0479 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH)
0480 DECLARE_PEM_write_attr(OSSL_DEPRECATEDIN_3_0, DHxparams, DH)
0481 # endif
0482 # endif
0483 DECLARE_PEM_rw_cb_ex(PrivateKey, EVP_PKEY)
0484 DECLARE_PEM_rw_ex(PUBKEY, EVP_PKEY)
0485
0486 int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x,
0487 const EVP_CIPHER *enc,
0488 const unsigned char *kstr, int klen,
0489 pem_password_cb *cb, void *u);
0490
0491
0492 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid,
0493 const char *kstr, int klen,
0494 pem_password_cb *cb, void *u);
0495 int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *,
0496 const char *kstr, int klen,
0497 pem_password_cb *cb, void *u);
0498 int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc,
0499 const char *kstr, int klen,
0500 pem_password_cb *cb, void *u);
0501 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid,
0502 const char *kstr, int klen,
0503 pem_password_cb *cb, void *u);
0504 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
0505 void *u);
0506
0507 # ifndef OPENSSL_NO_STDIO
0508 int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
0509 const char *kstr, int klen,
0510 pem_password_cb *cb, void *u);
0511 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid,
0512 const char *kstr, int klen,
0513 pem_password_cb *cb, void *u);
0514 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid,
0515 const char *kstr, int klen,
0516 pem_password_cb *cb, void *u);
0517
0518 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
0519 void *u);
0520
0521 int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
0522 const char *kstr, int klen,
0523 pem_password_cb *cd, void *u);
0524 # endif
0525 EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x,
0526 OSSL_LIB_CTX *libctx, const char *propq);
0527 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
0528 int PEM_write_bio_Parameters(BIO *bp, const EVP_PKEY *x);
0529
0530 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
0531 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
0532 EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
0533 EVP_PKEY *b2i_PublicKey_bio(BIO *in);
0534 int i2b_PrivateKey_bio(BIO *out, const EVP_PKEY *pk);
0535 int i2b_PublicKey_bio(BIO *out, const EVP_PKEY *pk);
0536 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
0537 EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u,
0538 OSSL_LIB_CTX *libctx, const char *propq);
0539 int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel,
0540 pem_password_cb *cb, void *u);
0541 int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel,
0542 pem_password_cb *cb, void *u,
0543 OSSL_LIB_CTX *libctx, const char *propq);
0544
0545 # ifdef __cplusplus
0546 }
0547 # endif
0548 #endif