/src/openssl31/include/openssl/pem.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.  | 
3  |  |  *  | 
4  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use  | 
5  |  |  * this file except in compliance with the License.  You can obtain a copy  | 
6  |  |  * in the file LICENSE in the source distribution or at  | 
7  |  |  * https://www.openssl.org/source/license.html  | 
8  |  |  */  | 
9  |  |  | 
10  |  | #ifndef OPENSSL_PEM_H  | 
11  |  | # define OPENSSL_PEM_H  | 
12  |  | # pragma once  | 
13  |  |  | 
14  |  | # include <openssl/macros.h>  | 
15  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
16  |  | #  define HEADER_PEM_H  | 
17  |  | # endif  | 
18  |  |  | 
19  |  | # include <openssl/e_os2.h>  | 
20  |  | # include <openssl/bio.h>  | 
21  |  | # include <openssl/safestack.h>  | 
22  |  | # include <openssl/evp.h>  | 
23  |  | # include <openssl/x509.h>  | 
24  |  | # include <openssl/pemerr.h>  | 
25  |  | # ifndef OPENSSL_NO_STDIO  | 
26  |  | #  include <stdio.h>  | 
27  |  | # endif  | 
28  |  |  | 
29  |  | #ifdef  __cplusplus  | 
30  |  | extern "C" { | 
31  |  | #endif  | 
32  |  |  | 
33  | 12  | # define PEM_BUFSIZE             1024  | 
34  |  |  | 
35  | 39.0k  | # define PEM_STRING_X509_OLD     "X509 CERTIFICATE"  | 
36  | 39.0k  | # define PEM_STRING_X509         "CERTIFICATE"  | 
37  | 39.0k  | # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"  | 
38  | 0  | # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"  | 
39  | 0  | # define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"  | 
40  | 39.0k  | # define PEM_STRING_X509_CRL     "X509 CRL"  | 
41  | 0  | # define PEM_STRING_EVP_PKEY     "ANY PRIVATE KEY"  | 
42  | 39.0k  | # define PEM_STRING_PUBLIC       "PUBLIC KEY"  | 
43  | 39.0k  | # define PEM_STRING_RSA          "RSA PRIVATE KEY"  | 
44  | 39.0k  | # define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"  | 
45  | 39.0k  | # define PEM_STRING_DSA          "DSA PRIVATE KEY"  | 
46  | 39.0k  | # define PEM_STRING_DSA_PUBLIC   "DSA PUBLIC KEY"  | 
47  | 0  | # define PEM_STRING_PKCS7        "PKCS7"  | 
48  | 0  | # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"  | 
49  | 39.0k  | # define PEM_STRING_PKCS8        "ENCRYPTED PRIVATE KEY"  | 
50  | 39.0k  | # define PEM_STRING_PKCS8INF     "PRIVATE KEY"  | 
51  | 39.0k  | # define PEM_STRING_DHPARAMS     "DH PARAMETERS"  | 
52  | 39.0k  | # define PEM_STRING_DHXPARAMS    "X9.42 DH PARAMETERS"  | 
53  |  | # define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"  | 
54  | 39.0k  | # define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"  | 
55  |  | # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"  | 
56  | 39.0k  | # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"  | 
57  | 39.0k  | # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"  | 
58  | 0  | # define PEM_STRING_PARAMETERS   "PARAMETERS"  | 
59  | 0  | # define PEM_STRING_CMS          "CMS"  | 
60  |  |  | 
61  | 0  | # define PEM_TYPE_ENCRYPTED      10  | 
62  | 0  | # define PEM_TYPE_MIC_ONLY       20  | 
63  | 0  | # define PEM_TYPE_MIC_CLEAR      30  | 
64  |  | # define PEM_TYPE_CLEAR          40  | 
65  |  |  | 
66  |  | /*  | 
67  |  |  * These macros make the PEM_read/PEM_write functions easier to maintain and  | 
68  |  |  * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or  | 
69  |  |  * IMPLEMENT_PEM_rw_cb(...)  | 
70  |  |  */  | 
71  |  |  | 
72  |  | # define PEM_read_cb_fnsig(name, type, INTYPE, readname)                \  | 
73  |  |     type *PEM_##readname##_##name(INTYPE *out, type **x,                \  | 
74  |  |                                  pem_password_cb *cb, void *u)  | 
75  |  | # define PEM_read_cb_ex_fnsig(name, type, INTYPE, readname)             \  | 
76  |  |     type *PEM_##readname##_##name##_ex(INTYPE *out, type **x,           \  | 
77  |  |                                        pem_password_cb *cb, void *u,    \  | 
78  |  |                                        OSSL_LIB_CTX *libctx,            \  | 
79  |  |                                        const char *propq)  | 
80  |  |  | 
81  |  | # define PEM_write_fnsig(name, type, OUTTYPE, writename)                \  | 
82  |  |     int PEM_##writename##_##name(OUTTYPE *out, const type *x)  | 
83  |  | # define PEM_write_cb_fnsig(name, type, OUTTYPE, writename)             \  | 
84  |  |     int PEM_##writename##_##name(OUTTYPE *out, const type *x,           \  | 
85  |  |                                  const EVP_CIPHER *enc,                 \  | 
86  |  |                                  const unsigned char *kstr, int klen,   \  | 
87  |  |                                  pem_password_cb *cb, void *u)  | 
88  |  | # define PEM_write_ex_fnsig(name, type, OUTTYPE, writename)             \  | 
89  |  |     int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x,      \  | 
90  |  |                                       OSSL_LIB_CTX *libctx,             \  | 
91  |  |                                       const char *propq)  | 
92  |  | # define PEM_write_cb_ex_fnsig(name, type, OUTTYPE, writename)          \  | 
93  |  |     int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x,      \  | 
94  |  |                                       const EVP_CIPHER *enc,            \  | 
95  |  |                                       const unsigned char *kstr, int klen, \  | 
96  |  |                                       pem_password_cb *cb, void *u,     \  | 
97  |  |                                       OSSL_LIB_CTX *libctx,             \  | 
98  |  |                                       const char *propq)  | 
99  |  |  | 
100  |  | # ifdef OPENSSL_NO_STDIO  | 
101  |  |  | 
102  |  | #  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/  | 
103  |  | #  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/  | 
104  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
105  |  | #   define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/  | 
106  |  | #  endif  | 
107  |  | #  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/  | 
108  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
109  |  | #   define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/  | 
110  |  | #  endif  | 
111  |  | # else  | 
112  |  |  | 
113  |  | #  define IMPLEMENT_PEM_read_fp(name, type, str, asn1)                  \  | 
114  |  |     type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \  | 
115  | 0  |     {                                                                   \ | 
116  | 0  |         return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp,        \  | 
117  | 0  |                              (void **)x, cb, u);                        \  | 
118  | 0  |     } Unexecuted instantiation: PEM_read_SSL_SESSION Unexecuted instantiation: PEM_read_X509_REQ Unexecuted instantiation: PEM_read_X509_CRL Unexecuted instantiation: PEM_read_X509_PUBKEY Unexecuted instantiation: PEM_read_PKCS7 Unexecuted instantiation: PEM_read_NETSCAPE_CERT_SEQUENCE Unexecuted instantiation: PEM_read_RSAPublicKey Unexecuted instantiation: PEM_read_RSA_PUBKEY Unexecuted instantiation: PEM_read_DSA_PUBKEY Unexecuted instantiation: PEM_read_DSAparams Unexecuted instantiation: PEM_read_ECPKParameters Unexecuted instantiation: PEM_read_EC_PUBKEY Unexecuted instantiation: PEM_read_X509 Unexecuted instantiation: PEM_read_X509_AUX Unexecuted instantiation: PEM_read_PKCS8 Unexecuted instantiation: PEM_read_PKCS8_PRIV_KEY_INFO Unexecuted instantiation: PEM_read_CMS  | 
119  |  |  | 
120  |  | #  define IMPLEMENT_PEM_write_fp(name, type, str, asn1)                 \  | 
121  |  |     PEM_write_fnsig(name, type, FILE, write)                            \  | 
122  | 0  |     {                                                                   \ | 
123  | 0  |         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out,      \  | 
124  | 0  |                               x, NULL, NULL, 0, NULL, NULL);            \  | 
125  | 0  |     } Unexecuted instantiation: PEM_write_SSL_SESSION Unexecuted instantiation: PEM_write_X509_REQ Unexecuted instantiation: PEM_write_X509_REQ_NEW Unexecuted instantiation: PEM_write_X509_CRL Unexecuted instantiation: PEM_write_X509_PUBKEY Unexecuted instantiation: PEM_write_PKCS7 Unexecuted instantiation: PEM_write_NETSCAPE_CERT_SEQUENCE Unexecuted instantiation: PEM_write_RSAPublicKey Unexecuted instantiation: PEM_write_RSA_PUBKEY Unexecuted instantiation: PEM_write_DSA_PUBKEY Unexecuted instantiation: PEM_write_DSAparams Unexecuted instantiation: PEM_write_ECPKParameters Unexecuted instantiation: PEM_write_EC_PUBKEY Unexecuted instantiation: PEM_write_DHparams Unexecuted instantiation: PEM_write_DHxparams Unexecuted instantiation: PEM_write_X509 Unexecuted instantiation: PEM_write_X509_AUX Unexecuted instantiation: PEM_write_PKCS8 Unexecuted instantiation: PEM_write_PKCS8_PRIV_KEY_INFO Unexecuted instantiation: PEM_write_CMS  | 
126  |  |  | 
127  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
128  |  | #   define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)  \  | 
129  |  |     IMPLEMENT_PEM_write_fp(name, type, str, asn1)  | 
130  |  | #  endif  | 
131  |  |  | 
132  |  | #  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)              \  | 
133  |  |     PEM_write_cb_fnsig(name, type, FILE, write)                         \  | 
134  | 0  |     {                                                                   \ | 
135  | 0  |         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out,      \  | 
136  | 0  |                               x, enc, kstr, klen, cb, u);               \  | 
137  | 0  |     } Unexecuted instantiation: PEM_write_RSAPrivateKey Unexecuted instantiation: PEM_write_DSAPrivateKey Unexecuted instantiation: PEM_write_ECPrivateKey  | 
138  |  |  | 
139  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
140  |  | #   define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)       \  | 
141  |  |     IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)  | 
142  |  | #  endif  | 
143  |  | # endif  | 
144  |  |  | 
145  |  | # define IMPLEMENT_PEM_read_bio(name, type, str, asn1)                  \  | 
146  |  |     type *PEM_read_bio_##name(BIO *bp, type **x,                        \  | 
147  |  |                               pem_password_cb *cb, void *u)             \  | 
148  | 55.4k  |     {                                                                   \ | 
149  | 55.4k  |         return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp,    \  | 
150  | 55.4k  |                                  (void **)x, cb, u);                    \  | 
151  | 55.4k  |     } Unexecuted instantiation: PEM_read_bio_SSL_SESSION Unexecuted instantiation: PEM_read_bio_X509_REQ Unexecuted instantiation: PEM_read_bio_X509_CRL Unexecuted instantiation: PEM_read_bio_X509_PUBKEY Unexecuted instantiation: PEM_read_bio_PKCS7 Unexecuted instantiation: PEM_read_bio_NETSCAPE_CERT_SEQUENCE Unexecuted instantiation: PEM_read_bio_RSAPublicKey Unexecuted instantiation: PEM_read_bio_RSA_PUBKEY Unexecuted instantiation: PEM_read_bio_DSA_PUBKEY Unexecuted instantiation: PEM_read_bio_DSAparams Unexecuted instantiation: PEM_read_bio_ECPKParameters Unexecuted instantiation: PEM_read_bio_EC_PUBKEY Line  | Count  | Source  |  148  | 55.4k  |     {                                                                   \ |  149  | 55.4k  |         return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp,    \  |  150  | 55.4k  |                                  (void **)x, cb, u);                    \  |  151  | 55.4k  |     }  |  
 Unexecuted instantiation: PEM_read_bio_X509_AUX Unexecuted instantiation: PEM_read_bio_PKCS8 Unexecuted instantiation: PEM_read_bio_PKCS8_PRIV_KEY_INFO Unexecuted instantiation: PEM_read_bio_CMS  | 
152  |  |  | 
153  |  | # define IMPLEMENT_PEM_write_bio(name, type, str, asn1)                 \  | 
154  |  |     PEM_write_fnsig(name, type, BIO, write_bio)                         \  | 
155  | 0  |     {                                                                   \ | 
156  | 0  |         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out,  \  | 
157  | 0  |                                   x, NULL,NULL,0,NULL,NULL);            \  | 
158  | 0  |     } Unexecuted instantiation: PEM_write_bio_SSL_SESSION Unexecuted instantiation: PEM_write_bio_X509_REQ Unexecuted instantiation: PEM_write_bio_X509_REQ_NEW Unexecuted instantiation: PEM_write_bio_X509_CRL Unexecuted instantiation: PEM_write_bio_X509_PUBKEY Unexecuted instantiation: PEM_write_bio_PKCS7 Unexecuted instantiation: PEM_write_bio_NETSCAPE_CERT_SEQUENCE Unexecuted instantiation: PEM_write_bio_RSAPublicKey Unexecuted instantiation: PEM_write_bio_RSA_PUBKEY Unexecuted instantiation: PEM_write_bio_DSA_PUBKEY Unexecuted instantiation: PEM_write_bio_DSAparams Unexecuted instantiation: PEM_write_bio_ECPKParameters Unexecuted instantiation: PEM_write_bio_EC_PUBKEY Unexecuted instantiation: PEM_write_bio_DHparams Unexecuted instantiation: PEM_write_bio_DHxparams Unexecuted instantiation: PEM_write_bio_X509 Unexecuted instantiation: PEM_write_bio_X509_AUX Unexecuted instantiation: PEM_write_bio_PKCS8 Unexecuted instantiation: PEM_write_bio_PKCS8_PRIV_KEY_INFO Unexecuted instantiation: PEM_write_bio_CMS  | 
159  |  |  | 
160  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
161  |  | #  define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1)   \  | 
162  |  |     IMPLEMENT_PEM_write_bio(name, type, str, asn1)  | 
163  |  | # endif  | 
164  |  |  | 
165  |  | # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1)              \  | 
166  |  |     PEM_write_cb_fnsig(name, type, BIO, write_bio)                      \  | 
167  | 0  |     {                                                                   \ | 
168  | 0  |         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out,  \  | 
169  | 0  |                                   x, enc, kstr, klen, cb, u);           \  | 
170  | 0  |     } Unexecuted instantiation: PEM_write_bio_RSAPrivateKey Unexecuted instantiation: PEM_write_bio_DSAPrivateKey Unexecuted instantiation: PEM_write_bio_ECPrivateKey  | 
171  |  |  | 
172  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
173  |  | #  define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1)  \  | 
174  |  |     IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1)  | 
175  |  | # endif  | 
176  |  |  | 
177  |  | # define IMPLEMENT_PEM_write(name, type, str, asn1) \  | 
178  |  |         IMPLEMENT_PEM_write_bio(name, type, str, asn1) \  | 
179  |  |         IMPLEMENT_PEM_write_fp(name, type, str, asn1)  | 
180  |  |  | 
181  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
182  |  | #  define IMPLEMENT_PEM_write_const(name, type, str, asn1) \  | 
183  |  |         IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \  | 
184  |  |         IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)  | 
185  |  | # endif  | 
186  |  |  | 
187  |  | # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \  | 
188  |  |         IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \  | 
189  |  |         IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)  | 
190  |  |  | 
191  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
192  |  | #  define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \  | 
193  |  |         IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \  | 
194  |  |         IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)  | 
195  |  | # endif  | 
196  |  |  | 
197  |  | # define IMPLEMENT_PEM_read(name, type, str, asn1) \  | 
198  |  |         IMPLEMENT_PEM_read_bio(name, type, str, asn1) \  | 
199  |  |         IMPLEMENT_PEM_read_fp(name, type, str, asn1)  | 
200  |  |  | 
201  |  | # define IMPLEMENT_PEM_rw(name, type, str, asn1) \  | 
202  |  |         IMPLEMENT_PEM_read(name, type, str, asn1) \  | 
203  |  |         IMPLEMENT_PEM_write(name, type, str, asn1)  | 
204  |  |  | 
205  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
206  |  | #  define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \  | 
207  |  |         IMPLEMENT_PEM_read(name, type, str, asn1) \  | 
208  |  |         IMPLEMENT_PEM_write_const(name, type, str, asn1)  | 
209  |  | # endif  | 
210  |  |  | 
211  |  | # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \  | 
212  |  |         IMPLEMENT_PEM_read(name, type, str, asn1) \  | 
213  |  |         IMPLEMENT_PEM_write_cb(name, type, str, asn1)  | 
214  |  |  | 
215  |  | /* These are the same except they are for the declarations */  | 
216  |  |  | 
217  |  | /*  | 
218  |  |  * The mysterious 'extern' that's passed to some macros is innocuous,  | 
219  |  |  * and is there to quiet pre-C99 compilers that may complain about empty  | 
220  |  |  * arguments in macro calls.  | 
221  |  |  */  | 
222  |  | # if defined(OPENSSL_NO_STDIO)  | 
223  |  |  | 
224  |  | #  define DECLARE_PEM_read_fp_attr(attr, name, type) /**/  | 
225  |  | #  define DECLARE_PEM_read_fp_ex_attr(attr, name, type) /**/  | 
226  |  | #  define DECLARE_PEM_write_fp_attr(attr, name, type) /**/  | 
227  |  | #  define DECLARE_PEM_write_fp_ex_attr(attr, name, type) /**/  | 
228  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
229  |  | #   define DECLARE_PEM_write_fp_const_attr(attr, name, type) /**/  | 
230  |  | #  endif  | 
231  |  | #  define DECLARE_PEM_write_cb_fp_attr(attr, name, type) /**/  | 
232  |  | #  define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) /**/  | 
233  |  |  | 
234  |  | # else  | 
235  |  |  | 
236  |  | #  define DECLARE_PEM_read_fp_attr(attr, name, type)                        \  | 
237  |  |     attr PEM_read_cb_fnsig(name, type, FILE, read);  | 
238  |  | #  define DECLARE_PEM_read_fp_ex_attr(attr, name, type)                     \  | 
239  |  |     attr PEM_read_cb_fnsig(name, type, FILE, read);                         \  | 
240  |  |     attr PEM_read_cb_ex_fnsig(name, type, FILE, read);  | 
241  |  |  | 
242  |  | #  define DECLARE_PEM_write_fp_attr(attr, name, type)                       \  | 
243  |  |     attr PEM_write_fnsig(name, type, FILE, write);  | 
244  |  | #  define DECLARE_PEM_write_fp_ex_attr(attr, name, type)                    \  | 
245  |  |     attr PEM_write_fnsig(name, type, FILE, write);                          \  | 
246  |  |     attr PEM_write_ex_fnsig(name, type, FILE, write);  | 
247  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
248  |  | #   define DECLARE_PEM_write_fp_const_attr(attr, name, type)                \  | 
249  |  |     attr PEM_write_fnsig(name, type, FILE, write);  | 
250  |  | #  endif  | 
251  |  | #  define DECLARE_PEM_write_cb_fp_attr(attr, name, type)                    \  | 
252  |  |     attr PEM_write_cb_fnsig(name, type, FILE, write);  | 
253  |  | #  define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type)                 \  | 
254  |  |     attr PEM_write_cb_fnsig(name, type, FILE, write);                       \  | 
255  |  |     attr PEM_write_cb_ex_fnsig(name, type, FILE, write);  | 
256  |  |  | 
257  |  | # endif  | 
258  |  |  | 
259  |  | # define DECLARE_PEM_read_fp(name, type)                                    \  | 
260  |  |     DECLARE_PEM_read_fp_attr(extern, name, type)  | 
261  |  | # define DECLARE_PEM_write_fp(name, type)                                   \  | 
262  |  |     DECLARE_PEM_write_fp_attr(extern, name, type)  | 
263  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
264  |  | #   define DECLARE_PEM_write_fp_const(name, type)                           \  | 
265  |  |     DECLARE_PEM_write_fp_const_attr(extern, name, type)  | 
266  |  | # endif  | 
267  |  | # define DECLARE_PEM_write_cb_fp(name, type)                                \  | 
268  |  |     DECLARE_PEM_write_cb_fp_attr(extern, name, type)  | 
269  |  |  | 
270  |  | #  define DECLARE_PEM_read_bio_attr(attr, name, type)                       \  | 
271  |  |     attr PEM_read_cb_fnsig(name, type, BIO, read_bio);  | 
272  |  | #  define DECLARE_PEM_read_bio_ex_attr(attr, name, type)                    \  | 
273  |  |     attr PEM_read_cb_fnsig(name, type, BIO, read_bio);                      \  | 
274  |  |     attr PEM_read_cb_ex_fnsig(name, type, BIO, read_bio);  | 
275  |  | # define DECLARE_PEM_read_bio(name, type)                                   \  | 
276  |  |     DECLARE_PEM_read_bio_attr(extern, name, type)  | 
277  |  | # define DECLARE_PEM_read_bio_ex(name, type)                                \  | 
278  |  |     DECLARE_PEM_read_bio_ex_attr(extern, name, type)  | 
279  |  |  | 
280  |  | # define DECLARE_PEM_write_bio_attr(attr, name, type)                       \  | 
281  |  |     attr PEM_write_fnsig(name, type, BIO, write_bio);  | 
282  |  | # define DECLARE_PEM_write_bio_ex_attr(attr, name, type)                    \  | 
283  |  |     attr PEM_write_fnsig(name, type, BIO, write_bio);                       \  | 
284  |  |     attr PEM_write_ex_fnsig(name, type, BIO, write_bio);  | 
285  |  | # define DECLARE_PEM_write_bio(name, type)                                  \  | 
286  |  |     DECLARE_PEM_write_bio_attr(extern, name, type)  | 
287  |  | # define DECLARE_PEM_write_bio_ex(name, type)                               \  | 
288  |  |     DECLARE_PEM_write_bio_ex_attr(extern, name, type)  | 
289  |  |  | 
290  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
291  |  | #  define DECLARE_PEM_write_bio_const_attr(attr, name, type)                \  | 
292  |  |     attr PEM_write_fnsig(name, type, BIO, write_bio);  | 
293  |  | #  define DECLARE_PEM_write_bio_const(name, type)      \  | 
294  |  |     DECLARE_PEM_write_bio_const_attr(extern, name, type)  | 
295  |  | # endif  | 
296  |  |  | 
297  |  | # define DECLARE_PEM_write_cb_bio_attr(attr, name, type)                    \  | 
298  |  |     attr PEM_write_cb_fnsig(name, type, BIO, write_bio);  | 
299  |  | # define DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type)                 \  | 
300  |  |     attr PEM_write_cb_fnsig(name, type, BIO, write_bio);                    \  | 
301  |  |     attr PEM_write_cb_ex_fnsig(name, type, BIO, write_bio);  | 
302  |  | # define DECLARE_PEM_write_cb_bio(name, type)                               \  | 
303  |  |     DECLARE_PEM_write_cb_bio_attr(extern, name, type)  | 
304  |  | # define DECLARE_PEM_write_cb_ex_bio(name, type)                            \  | 
305  |  |     DECLARE_PEM_write_cb_bio_ex_attr(extern, name, type)  | 
306  |  |  | 
307  |  | # define DECLARE_PEM_write_attr(attr, name, type)                           \  | 
308  |  |     DECLARE_PEM_write_bio_attr(attr, name, type)                            \  | 
309  |  |     DECLARE_PEM_write_fp_attr(attr, name, type)  | 
310  |  | # define DECLARE_PEM_write_ex_attr(attr, name, type)                        \  | 
311  |  |     DECLARE_PEM_write_bio_ex_attr(attr, name, type)                         \  | 
312  |  |     DECLARE_PEM_write_fp_ex_attr(attr, name, type)  | 
313  |  | # define DECLARE_PEM_write(name, type) \  | 
314  |  |     DECLARE_PEM_write_attr(extern, name, type)  | 
315  |  | # define DECLARE_PEM_write_ex(name, type) \  | 
316  |  |     DECLARE_PEM_write_ex_attr(extern, name, type)  | 
317  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
318  |  | #  define DECLARE_PEM_write_const_attr(attr, name, type)                    \  | 
319  |  |     DECLARE_PEM_write_bio_const_attr(attr, name, type)                      \  | 
320  |  |     DECLARE_PEM_write_fp_const_attr(attr, name, type)  | 
321  |  | #  define DECLARE_PEM_write_const(name, type)                               \  | 
322  |  |     DECLARE_PEM_write_const_attr(extern, name, type)  | 
323  |  | # endif  | 
324  |  | # define DECLARE_PEM_write_cb_attr(attr, name, type)                        \  | 
325  |  |     DECLARE_PEM_write_cb_bio_attr(attr, name, type)                         \  | 
326  |  |     DECLARE_PEM_write_cb_fp_attr(attr, name, type)  | 
327  |  | # define DECLARE_PEM_write_cb_ex_attr(attr, name, type)                     \  | 
328  |  |     DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type)                      \  | 
329  |  |     DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type)  | 
330  |  | # define DECLARE_PEM_write_cb(name, type)                                   \  | 
331  |  |     DECLARE_PEM_write_cb_attr(extern, name, type)  | 
332  |  | # define DECLARE_PEM_write_cb_ex(name, type)                                \  | 
333  |  |     DECLARE_PEM_write_cb_ex_attr(extern, name, type)  | 
334  |  | # define DECLARE_PEM_read_attr(attr, name, type)                            \  | 
335  |  |     DECLARE_PEM_read_bio_attr(attr, name, type)                             \  | 
336  |  |     DECLARE_PEM_read_fp_attr(attr, name, type)  | 
337  |  | # define DECLARE_PEM_read_ex_attr(attr, name, type)                         \  | 
338  |  |     DECLARE_PEM_read_bio_ex_attr(attr, name, type)                          \  | 
339  |  |     DECLARE_PEM_read_fp_ex_attr(attr, name, type)  | 
340  |  | # define DECLARE_PEM_read(name, type)                                       \  | 
341  |  |     DECLARE_PEM_read_attr(extern, name, type)  | 
342  |  | # define DECLARE_PEM_read_ex(name, type)                                    \  | 
343  |  |     DECLARE_PEM_read_ex_attr(extern, name, type)  | 
344  |  | # define DECLARE_PEM_rw_attr(attr, name, type)                              \  | 
345  |  |     DECLARE_PEM_read_attr(attr, name, type)                                 \  | 
346  |  |     DECLARE_PEM_write_attr(attr, name, type)  | 
347  |  | # define DECLARE_PEM_rw_ex_attr(attr, name, type)                           \  | 
348  |  |     DECLARE_PEM_read_ex_attr(attr, name, type)                              \  | 
349  |  |     DECLARE_PEM_write_ex_attr(attr, name, type)  | 
350  |  | # define DECLARE_PEM_rw(name, type) \  | 
351  |  |     DECLARE_PEM_rw_attr(extern, name, type)  | 
352  |  | # define DECLARE_PEM_rw_ex(name, type) \  | 
353  |  |     DECLARE_PEM_rw_ex_attr(extern, name, type)  | 
354  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
355  |  | #  define DECLARE_PEM_rw_const_attr(attr, name, type)                       \  | 
356  |  |     DECLARE_PEM_read_attr(attr, name, type)                                 \  | 
357  |  |     DECLARE_PEM_write_const_attr(attr, name, type)  | 
358  |  | #  define DECLARE_PEM_rw_const(name, type) \  | 
359  |  |     DECLARE_PEM_rw_const_attr(extern, name, type)  | 
360  |  | # endif  | 
361  |  | # define DECLARE_PEM_rw_cb_attr(attr, name, type)                           \  | 
362  |  |     DECLARE_PEM_read_attr(attr, name, type)                                 \  | 
363  |  |     DECLARE_PEM_write_cb_attr(attr, name, type)  | 
364  |  | # define DECLARE_PEM_rw_cb_ex_attr(attr, name, type)                        \  | 
365  |  |     DECLARE_PEM_read_ex_attr(attr, name, type)                              \  | 
366  |  |     DECLARE_PEM_write_cb_ex_attr(attr, name, type)  | 
367  |  | # define DECLARE_PEM_rw_cb(name, type) \  | 
368  |  |     DECLARE_PEM_rw_cb_attr(extern, name, type)  | 
369  |  | # define DECLARE_PEM_rw_cb_ex(name, type) \  | 
370  |  |     DECLARE_PEM_rw_cb_ex_attr(extern, name, type)  | 
371  |  |  | 
372  |  | int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);  | 
373  |  | int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,  | 
374  |  |                   pem_password_cb *callback, void *u);  | 
375  |  |  | 
376  |  | int PEM_read_bio(BIO *bp, char **name, char **header,  | 
377  |  |                  unsigned char **data, long *len);  | 
378  | 1.36M  | #   define PEM_FLAG_SECURE             0x1  | 
379  | 5.34M  | #   define PEM_FLAG_EAY_COMPATIBLE     0x2  | 
380  | 744k  | #   define PEM_FLAG_ONLY_B64           0x4  | 
381  |  | int PEM_read_bio_ex(BIO *bp, char **name, char **header,  | 
382  |  |                     unsigned char **data, long *len, unsigned int flags);  | 
383  |  | int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,  | 
384  |  |                               const char *name, BIO *bp, pem_password_cb *cb,  | 
385  |  |                               void *u);  | 
386  |  | int PEM_write_bio(BIO *bp, const char *name, const char *hdr,  | 
387  |  |                   const unsigned char *data, long len);  | 
388  |  | int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,  | 
389  |  |                        const char *name, BIO *bp, pem_password_cb *cb,  | 
390  |  |                        void *u);  | 
391  |  | void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,  | 
392  |  |                         pem_password_cb *cb, void *u);  | 
393  |  | int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,  | 
394  |  |                        const void *x, const EVP_CIPHER *enc,  | 
395  |  |                        const unsigned char *kstr, int klen,  | 
396  |  |                        pem_password_cb *cb, void *u);  | 
397  |  |  | 
398  |  | STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,  | 
399  |  |                                             pem_password_cb *cb, void *u);  | 
400  |  | STACK_OF(X509_INFO)  | 
401  |  | *PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) *sk,  | 
402  |  |                            pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx,  | 
403  |  |                            const char *propq);  | 
404  |  |  | 
405  |  | int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc,  | 
406  |  |                             const unsigned char *kstr, int klen,  | 
407  |  |                             pem_password_cb *cd, void *u);  | 
408  |  |  | 
409  |  | #ifndef OPENSSL_NO_STDIO  | 
410  |  | int PEM_read(FILE *fp, char **name, char **header,  | 
411  |  |              unsigned char **data, long *len);  | 
412  |  | int PEM_write(FILE *fp, const char *name, const char *hdr,  | 
413  |  |               const unsigned char *data, long len);  | 
414  |  | void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,  | 
415  |  |                     pem_password_cb *cb, void *u);  | 
416  |  | int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,  | 
417  |  |                    const void *x, const EVP_CIPHER *enc,  | 
418  |  |                    const unsigned char *kstr, int klen,  | 
419  |  |                    pem_password_cb *callback, void *u);  | 
420  |  | STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,  | 
421  |  |                                         pem_password_cb *cb, void *u);  | 
422  |  | STACK_OF(X509_INFO)  | 
423  |  | *PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb,  | 
424  |  |                        void *u, OSSL_LIB_CTX *libctx, const char *propq);  | 
425  |  | #endif  | 
426  |  |  | 
427  |  | int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);  | 
428  |  | int PEM_SignUpdate(EVP_MD_CTX *ctx, const unsigned char *d, unsigned int cnt);  | 
429  |  | int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,  | 
430  |  |                   unsigned int *siglen, EVP_PKEY *pkey);  | 
431  |  |  | 
432  |  | /* The default pem_password_cb that's used internally */  | 
433  |  | int PEM_def_callback(char *buf, int num, int rwflag, void *userdata);  | 
434  |  | void PEM_proc_type(char *buf, int type);  | 
435  |  | void PEM_dek_info(char *buf, const char *type, int len, const char *str);  | 
436  |  |  | 
437  |  | # include <openssl/symhacks.h>  | 
438  |  |  | 
439  |  | DECLARE_PEM_rw(X509, X509)  | 
440  |  | DECLARE_PEM_rw(X509_AUX, X509)  | 
441  |  | DECLARE_PEM_rw(X509_REQ, X509_REQ)  | 
442  |  | DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)  | 
443  |  | DECLARE_PEM_rw(X509_CRL, X509_CRL)  | 
444  |  | DECLARE_PEM_rw(X509_PUBKEY, X509_PUBKEY)  | 
445  |  | DECLARE_PEM_rw(PKCS7, PKCS7)  | 
446  |  | DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)  | 
447  |  | DECLARE_PEM_rw(PKCS8, X509_SIG)  | 
448  |  | DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)  | 
449  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
450  |  | DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, RSA)  | 
451  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, RSA)  | 
452  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA)  | 
453  |  | # endif  | 
454  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
455  |  | #  ifndef OPENSSL_NO_DSA  | 
456  |  | DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, DSAPrivateKey, DSA)  | 
457  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSA_PUBKEY, DSA)  | 
458  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSAparams, DSA)  | 
459  |  | #  endif  | 
460  |  | # endif  | 
461  |  |  | 
462  |  | # ifndef OPENSSL_NO_DEPRECATED_3_0  | 
463  |  | #  ifndef OPENSSL_NO_EC  | 
464  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, ECPKParameters, EC_GROUP)  | 
465  |  | DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, ECPrivateKey, EC_KEY)  | 
466  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, EC_PUBKEY, EC_KEY)  | 
467  |  | #  endif  | 
468  |  | # endif  | 
469  |  |  | 
470  |  | # ifndef OPENSSL_NO_DH  | 
471  |  | #  ifndef OPENSSL_NO_DEPRECATED_3_0  | 
472  |  | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH)  | 
473  |  | DECLARE_PEM_write_attr(OSSL_DEPRECATEDIN_3_0, DHxparams, DH)  | 
474  |  | #  endif  | 
475  |  | # endif  | 
476  |  | DECLARE_PEM_rw_cb_ex(PrivateKey, EVP_PKEY)  | 
477  |  | DECLARE_PEM_rw_ex(PUBKEY, EVP_PKEY)  | 
478  |  |  | 
479  |  | int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x,  | 
480  |  |                                          const EVP_CIPHER *enc,  | 
481  |  |                                          const unsigned char *kstr, int klen,  | 
482  |  |                                          pem_password_cb *cb, void *u);  | 
483  |  |  | 
484  |  | /* Why do these take a signed char *kstr? */  | 
485  |  | int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid,  | 
486  |  |                                       const char *kstr, int klen,  | 
487  |  |                                       pem_password_cb *cb, void *u);  | 
488  |  | int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *,  | 
489  |  |                                   const char *kstr, int klen,  | 
490  |  |                                   pem_password_cb *cb, void *u);  | 
491  |  | int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc,  | 
492  |  |                             const char *kstr, int klen,  | 
493  |  |                             pem_password_cb *cb, void *u);  | 
494  |  | int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid,  | 
495  |  |                                 const char *kstr, int klen,  | 
496  |  |                                 pem_password_cb *cb, void *u);  | 
497  |  | EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,  | 
498  |  |                                   void *u);  | 
499  |  |  | 
500  |  | # ifndef OPENSSL_NO_STDIO  | 
501  |  | int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,  | 
502  |  |                            const char *kstr, int klen,  | 
503  |  |                            pem_password_cb *cb, void *u);  | 
504  |  | int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid,  | 
505  |  |                                const char *kstr, int klen,  | 
506  |  |                                pem_password_cb *cb, void *u);  | 
507  |  | int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid,  | 
508  |  |                                   const char *kstr, int klen,  | 
509  |  |                                   pem_password_cb *cb, void *u);  | 
510  |  |  | 
511  |  | EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,  | 
512  |  |                                  void *u);  | 
513  |  |  | 
514  |  | int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,  | 
515  |  |                               const char *kstr, int klen,  | 
516  |  |                               pem_password_cb *cd, void *u);  | 
517  |  | # endif  | 
518  |  | EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x,  | 
519  |  |                                      OSSL_LIB_CTX *libctx, const char *propq);  | 
520  |  | EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);  | 
521  |  | int PEM_write_bio_Parameters(BIO *bp, const EVP_PKEY *x);  | 
522  |  |  | 
523  |  | EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);  | 
524  |  | EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);  | 
525  |  | EVP_PKEY *b2i_PrivateKey_bio(BIO *in);  | 
526  |  | EVP_PKEY *b2i_PublicKey_bio(BIO *in);  | 
527  |  | int i2b_PrivateKey_bio(BIO *out, const EVP_PKEY *pk);  | 
528  |  | int i2b_PublicKey_bio(BIO *out, const EVP_PKEY *pk);  | 
529  |  | EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);  | 
530  |  | EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u,  | 
531  |  |                          OSSL_LIB_CTX *libctx, const char *propq);  | 
532  |  | int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel,  | 
533  |  |                 pem_password_cb *cb, void *u);  | 
534  |  | int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel,  | 
535  |  |                    pem_password_cb *cb, void *u,  | 
536  |  |                    OSSL_LIB_CTX *libctx, const char *propq);  | 
537  |  |  | 
538  |  | # ifdef  __cplusplus  | 
539  |  | }  | 
540  |  | # endif  | 
541  |  | #endif  |