Fix up error codes after splitting up tls_construct_key_exchange()
[openssl.git] / include / openssl / pem.h
1 /*
2  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (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 HEADER_PEM_H
11 # define HEADER_PEM_H
12
13 # include <openssl/e_os2.h>
14 # include <openssl/bio.h>
15 # include <openssl/stack.h>
16 # include <openssl/evp.h>
17 # include <openssl/x509.h>
18 # include <openssl/pem2.h>
19
20 #ifdef  __cplusplus
21 extern "C" {
22 #endif
23
24 # define PEM_BUFSIZE             1024
25
26 # define PEM_STRING_X509_OLD     "X509 CERTIFICATE"
27 # define PEM_STRING_X509         "CERTIFICATE"
28 # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
29 # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
30 # define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"
31 # define PEM_STRING_X509_CRL     "X509 CRL"
32 # define PEM_STRING_EVP_PKEY     "ANY PRIVATE KEY"
33 # define PEM_STRING_PUBLIC       "PUBLIC KEY"
34 # define PEM_STRING_RSA          "RSA PRIVATE KEY"
35 # define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"
36 # define PEM_STRING_DSA          "DSA PRIVATE KEY"
37 # define PEM_STRING_DSA_PUBLIC   "DSA PUBLIC KEY"
38 # define PEM_STRING_PKCS7        "PKCS7"
39 # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
40 # define PEM_STRING_PKCS8        "ENCRYPTED PRIVATE KEY"
41 # define PEM_STRING_PKCS8INF     "PRIVATE KEY"
42 # define PEM_STRING_DHPARAMS     "DH PARAMETERS"
43 # define PEM_STRING_DHXPARAMS    "X9.42 DH PARAMETERS"
44 # define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"
45 # define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"
46 # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
47 # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
48 # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
49 # define PEM_STRING_PARAMETERS   "PARAMETERS"
50 # define PEM_STRING_CMS          "CMS"
51
52 # define PEM_TYPE_ENCRYPTED      10
53 # define PEM_TYPE_MIC_ONLY       20
54 # define PEM_TYPE_MIC_CLEAR      30
55 # define PEM_TYPE_CLEAR          40
56
57 typedef struct pem_recip_st {
58     char *name;
59     X509_NAME *dn;
60     int cipher;
61     int key_enc;
62     /*      char iv[8]; unused and wrong size */
63 } PEM_USER;
64
65 typedef struct pem_ctx_st {
66     int type;                   /* what type of object */
67     struct {
68         int version;
69         int mode;
70     } proc_type;
71
72     char *domain;
73
74     struct {
75         int cipher;
76         /*-
77         unused, and wrong size
78         unsigned char iv[8]; */
79     } DEK_info;
80
81     PEM_USER *originator;
82
83     int num_recipient;
84     PEM_USER **recipient;
85
86 /*-
87     XXX(ben): don#t think this is used!
88         STACK *x509_chain;      / * certificate chain */
89     EVP_MD *md;                 /* signature type */
90
91     int md_enc;                 /* is the md encrypted or not? */
92     int md_len;                 /* length of md_data */
93     char *md_data;              /* message digest, could be pkey encrypted */
94
95     EVP_CIPHER *dec;            /* date encryption cipher */
96     int key_len;                /* key length */
97     unsigned char *key;         /* key */
98   /*-
99     unused, and wrong size
100     unsigned char iv[8]; */
101
102     int data_enc;               /* is the data encrypted */
103     int data_len;
104     unsigned char *data;
105 } PEM_CTX;
106
107 /*
108  * These macros make the PEM_read/PEM_write functions easier to maintain and
109  * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or
110  * IMPLEMENT_PEM_rw_cb(...)
111  */
112
113 # ifdef OPENSSL_NO_STDIO
114
115 #  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
116 #  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
117 #  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
118 #  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
119 #  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
120 # else
121
122 #  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
123 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
124 { \
125 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
126 }
127
128 #  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
129 int PEM_write_##name(FILE *fp, type *x) \
130 { \
131 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
132 }
133
134 #  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
135 int PEM_write_##name(FILE *fp, const type *x) \
136 { \
137 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
138 }
139
140 #  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
141 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
142              unsigned char *kstr, int klen, pem_password_cb *cb, \
143                   void *u) \
144         { \
145         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
146         }
147
148 #  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
149 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
150              unsigned char *kstr, int klen, pem_password_cb *cb, \
151                   void *u) \
152         { \
153         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
154         }
155
156 # endif
157
158 # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
159 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
160 { \
161 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
162 }
163
164 # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
165 int PEM_write_bio_##name(BIO *bp, type *x) \
166 { \
167 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
168 }
169
170 # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
171 int PEM_write_bio_##name(BIO *bp, const type *x) \
172 { \
173 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
174 }
175
176 # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
177 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
178              unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
179         { \
180         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
181         }
182
183 # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
184 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
185              unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
186         { \
187         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
188         }
189
190 # define IMPLEMENT_PEM_write(name, type, str, asn1) \
191         IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
192         IMPLEMENT_PEM_write_fp(name, type, str, asn1)
193
194 # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
195         IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
196         IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
197
198 # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
199         IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
200         IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
201
202 # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
203         IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
204         IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
205
206 # define IMPLEMENT_PEM_read(name, type, str, asn1) \
207         IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
208         IMPLEMENT_PEM_read_fp(name, type, str, asn1)
209
210 # define IMPLEMENT_PEM_rw(name, type, str, asn1) \
211         IMPLEMENT_PEM_read(name, type, str, asn1) \
212         IMPLEMENT_PEM_write(name, type, str, asn1)
213
214 # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
215         IMPLEMENT_PEM_read(name, type, str, asn1) \
216         IMPLEMENT_PEM_write_const(name, type, str, asn1)
217
218 # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
219         IMPLEMENT_PEM_read(name, type, str, asn1) \
220         IMPLEMENT_PEM_write_cb(name, type, str, asn1)
221
222 /* These are the same except they are for the declarations */
223
224 # if defined(OPENSSL_NO_STDIO)
225
226 #  define DECLARE_PEM_read_fp(name, type) /**/
227 #  define DECLARE_PEM_write_fp(name, type) /**/
228 #  define DECLARE_PEM_write_fp_const(name, type) /**/
229 #  define DECLARE_PEM_write_cb_fp(name, type) /**/
230 # else
231
232 #  define DECLARE_PEM_read_fp(name, type) \
233         type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
234
235 #  define DECLARE_PEM_write_fp(name, type) \
236         int PEM_write_##name(FILE *fp, type *x);
237
238 #  define DECLARE_PEM_write_fp_const(name, type) \
239         int PEM_write_##name(FILE *fp, const type *x);
240
241 #  define DECLARE_PEM_write_cb_fp(name, type) \
242         int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
243              unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
244
245 # endif
246
247 #  define DECLARE_PEM_read_bio(name, type) \
248         type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
249
250 #  define DECLARE_PEM_write_bio(name, type) \
251         int PEM_write_bio_##name(BIO *bp, type *x);
252
253 #  define DECLARE_PEM_write_bio_const(name, type) \
254         int PEM_write_bio_##name(BIO *bp, const type *x);
255
256 #  define DECLARE_PEM_write_cb_bio(name, type) \
257         int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
258              unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
259
260 # define DECLARE_PEM_write(name, type) \
261         DECLARE_PEM_write_bio(name, type) \
262         DECLARE_PEM_write_fp(name, type)
263 # define DECLARE_PEM_write_const(name, type) \
264         DECLARE_PEM_write_bio_const(name, type) \
265         DECLARE_PEM_write_fp_const(name, type)
266 # define DECLARE_PEM_write_cb(name, type) \
267         DECLARE_PEM_write_cb_bio(name, type) \
268         DECLARE_PEM_write_cb_fp(name, type)
269 # define DECLARE_PEM_read(name, type) \
270         DECLARE_PEM_read_bio(name, type) \
271         DECLARE_PEM_read_fp(name, type)
272 # define DECLARE_PEM_rw(name, type) \
273         DECLARE_PEM_read(name, type) \
274         DECLARE_PEM_write(name, type)
275 # define DECLARE_PEM_rw_const(name, type) \
276         DECLARE_PEM_read(name, type) \
277         DECLARE_PEM_write_const(name, type)
278 # define DECLARE_PEM_rw_cb(name, type) \
279         DECLARE_PEM_read(name, type) \
280         DECLARE_PEM_write_cb(name, type)
281 typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);
282
283 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
284 int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
285                   pem_password_cb *callback, void *u);
286
287 int PEM_read_bio(BIO *bp, char **name, char **header,
288                  unsigned char **data, long *len);
289 int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
290                   const unsigned char *data, long len);
291 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
292                        const char *name, BIO *bp, pem_password_cb *cb,
293                        void *u);
294 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
295                         pem_password_cb *cb, void *u);
296 int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
297                        const EVP_CIPHER *enc, unsigned char *kstr, int klen,
298                        pem_password_cb *cb, void *u);
299
300 STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
301                                             pem_password_cb *cb, void *u);
302 int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
303                             unsigned char *kstr, int klen,
304                             pem_password_cb *cd, void *u);
305
306 #ifndef OPENSSL_NO_STDIO
307 int PEM_read(FILE *fp, char **name, char **header,
308              unsigned char **data, long *len);
309 int PEM_write(FILE *fp, const char *name, const char *hdr,
310               const unsigned char *data, long len);
311 void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
312                     pem_password_cb *cb, void *u);
313 int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
314                    void *x, const EVP_CIPHER *enc, unsigned char *kstr,
315                    int klen, pem_password_cb *callback, void *u);
316 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
317                                         pem_password_cb *cb, void *u);
318 #endif
319
320 int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
321 int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
322 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
323                   unsigned int *siglen, EVP_PKEY *pkey);
324
325 int PEM_def_callback(char *buf, int num, int w, void *key);
326 void PEM_proc_type(char *buf, int type);
327 void PEM_dek_info(char *buf, const char *type, int len, char *str);
328
329 # include <openssl/symhacks.h>
330
331 DECLARE_PEM_rw(X509, X509)
332 DECLARE_PEM_rw(X509_AUX, X509)
333 DECLARE_PEM_rw(X509_REQ, X509_REQ)
334 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
335 DECLARE_PEM_rw(X509_CRL, X509_CRL)
336 DECLARE_PEM_rw(PKCS7, PKCS7)
337 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
338 DECLARE_PEM_rw(PKCS8, X509_SIG)
339 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
340 # ifndef OPENSSL_NO_RSA
341 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
342 DECLARE_PEM_rw_const(RSAPublicKey, RSA)
343 DECLARE_PEM_rw(RSA_PUBKEY, RSA)
344 # endif
345 # ifndef OPENSSL_NO_DSA
346 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
347 DECLARE_PEM_rw(DSA_PUBKEY, DSA)
348 DECLARE_PEM_rw_const(DSAparams, DSA)
349 # endif
350 # ifndef OPENSSL_NO_EC
351 DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
352 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
353 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
354 # endif
355 # ifndef OPENSSL_NO_DH
356 DECLARE_PEM_rw_const(DHparams, DH)
357 DECLARE_PEM_write_const(DHxparams, DH)
358 # endif
359 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
360 DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
361
362 int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,
363                                          const EVP_CIPHER *enc,
364                                          unsigned char *kstr, int klen,
365                                          pem_password_cb *cb, void *u);
366
367 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
368                                       char *kstr, int klen,
369                                       pem_password_cb *cb, void *u);
370 int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
371                                   char *, int, pem_password_cb *, void *);
372 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
373                             char *kstr, int klen,
374                             pem_password_cb *cb, void *u);
375 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
376                                 char *kstr, int klen,
377                                 pem_password_cb *cb, void *u);
378 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
379                                   void *u);
380
381 # ifndef OPENSSL_NO_STDIO
382 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
383                            char *kstr, int klen,
384                            pem_password_cb *cb, void *u);
385 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
386                                char *kstr, int klen,
387                                pem_password_cb *cb, void *u);
388 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
389                                   char *kstr, int klen,
390                                   pem_password_cb *cb, void *u);
391
392 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
393                                  void *u);
394
395 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
396                               char *kstr, int klen, pem_password_cb *cd,
397                               void *u);
398 # endif
399 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
400 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
401
402 # ifndef OPENSSL_NO_DSA
403 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
404 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
405 EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
406 EVP_PKEY *b2i_PublicKey_bio(BIO *in);
407 int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
408 int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
409 #  ifndef OPENSSL_NO_RC4
410 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
411 int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
412                 pem_password_cb *cb, void *u);
413 #  endif
414 # endif
415
416 /* BEGIN ERROR CODES */
417 /*
418  * The following lines are auto generated by the script mkerr.pl. Any changes
419  * made after this point may be overwritten when the script is next run.
420  */
421
422 void ERR_load_PEM_strings(void);
423
424 /* Error codes for the PEM functions. */
425
426 /* Function codes. */
427 # define PEM_F_B2I_DSS                                    127
428 # define PEM_F_B2I_PVK_BIO                                128
429 # define PEM_F_B2I_RSA                                    129
430 # define PEM_F_CHECK_BITLEN_DSA                           130
431 # define PEM_F_CHECK_BITLEN_RSA                           131
432 # define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120
433 # define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121
434 # define PEM_F_DO_B2I                                     132
435 # define PEM_F_DO_B2I_BIO                                 133
436 # define PEM_F_DO_BLOB_HEADER                             134
437 # define PEM_F_DO_PK8PKEY                                 126
438 # define PEM_F_DO_PK8PKEY_FP                              125
439 # define PEM_F_DO_PVK_BODY                                135
440 # define PEM_F_DO_PVK_HEADER                              136
441 # define PEM_F_I2B_PVK                                    137
442 # define PEM_F_I2B_PVK_BIO                                138
443 # define PEM_F_LOAD_IV                                    101
444 # define PEM_F_PEM_ASN1_READ                              102
445 # define PEM_F_PEM_ASN1_READ_BIO                          103
446 # define PEM_F_PEM_ASN1_WRITE                             104
447 # define PEM_F_PEM_ASN1_WRITE_BIO                         105
448 # define PEM_F_PEM_DEF_CALLBACK                           100
449 # define PEM_F_PEM_DO_HEADER                              106
450 # define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107
451 # define PEM_F_PEM_READ                                   108
452 # define PEM_F_PEM_READ_BIO                               109
453 # define PEM_F_PEM_READ_BIO_DHPARAMS                      141
454 # define PEM_F_PEM_READ_BIO_PARAMETERS                    140
455 # define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123
456 # define PEM_F_PEM_READ_DHPARAMS                          142
457 # define PEM_F_PEM_READ_PRIVATEKEY                        124
458 # define PEM_F_PEM_SIGNFINAL                              112
459 # define PEM_F_PEM_WRITE                                  113
460 # define PEM_F_PEM_WRITE_BIO                              114
461 # define PEM_F_PEM_WRITE_PRIVATEKEY                       139
462 # define PEM_F_PEM_X509_INFO_READ                         115
463 # define PEM_F_PEM_X509_INFO_READ_BIO                     116
464 # define PEM_F_PEM_X509_INFO_WRITE_BIO                    117
465
466 /* Reason codes. */
467 # define PEM_R_BAD_BASE64_DECODE                          100
468 # define PEM_R_BAD_DECRYPT                                101
469 # define PEM_R_BAD_END_LINE                               102
470 # define PEM_R_BAD_IV_CHARS                               103
471 # define PEM_R_BAD_MAGIC_NUMBER                           116
472 # define PEM_R_BAD_PASSWORD_READ                          104
473 # define PEM_R_BAD_VERSION_NUMBER                         117
474 # define PEM_R_BIO_WRITE_FAILURE                          118
475 # define PEM_R_CIPHER_IS_NULL                             127
476 # define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115
477 # define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119
478 # define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120
479 # define PEM_R_HEADER_TOO_LONG                            128
480 # define PEM_R_INCONSISTENT_HEADER                        121
481 # define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122
482 # define PEM_R_KEYBLOB_TOO_SHORT                          123
483 # define PEM_R_MISSING_DEK_IV                             129
484 # define PEM_R_NOT_DEK_INFO                               105
485 # define PEM_R_NOT_ENCRYPTED                              106
486 # define PEM_R_NOT_PROC_TYPE                              107
487 # define PEM_R_NO_START_LINE                              108
488 # define PEM_R_PROBLEMS_GETTING_PASSWORD                  109
489 # define PEM_R_PVK_DATA_TOO_SHORT                         124
490 # define PEM_R_PVK_TOO_SHORT                              125
491 # define PEM_R_READ_KEY                                   111
492 # define PEM_R_SHORT_HEADER                               112
493 # define PEM_R_UNEXPECTED_DEK_IV                          130
494 # define PEM_R_UNSUPPORTED_CIPHER                         113
495 # define PEM_R_UNSUPPORTED_ENCRYPTION                     114
496 # define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126
497
498 # ifdef  __cplusplus
499 }
500 # endif
501 #endif