~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to crypto/pem/pem.h

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-01 23:51:53 UTC
  • mfrom: (11.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110501235153-bjcxitndquaezb68
Tags: 1.0.0d-2ubuntu1
* Resynchronise with Debian (LP: #675566).  Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification bubble on libssl1.0.0
      upgrade.
    + Use a different priority for libssl1.0.0/restart-services depending
      on whether a desktop, or server dist-upgrade is being performed.
  - debian/{libssl1.0.0-udeb.dirs, control, rules}: Create
    libssl1.0.0-udeb, for the benefit of wget-udeb (no wget-udeb package
    in Debian).
  - debian/{libcrypto1.0.0-udeb.dirs, libssl1.0.0.dirs, libssl1.0.0.files,
    rules}: Move runtime libraries to /lib, for the benefit of
    wpasupplicant.
  - debian/patches/aesni.patch: Backport Intel AES-NI support, now from
    http://rt.openssl.org/Ticket/Display.html?id=2065 rather than the
    0.9.8 variant.
  - debian/patches/Bsymbolic-functions.patch: Link using
    -Bsymbolic-functions.
  - debian/patches/perlpath-quilt.patch: Don't change perl #! paths under
    .pc.
  - debian/rules:
    + Don't run 'make test' when cross-building.
    + Use host compiler when cross-building.  Patch from Neil Williams.
    + Don't build for processors no longer supported: i486, i586 (on
      i386), v8 (on sparc).
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
* Update architectures affected by Bsymbolic-functions.patch.
* Drop debian/patches/no-sslv2.patch; Debian now adds the 'no-ssl2'
  configure option, which compiles out SSLv2 support entirely, so this is
  no longer needed.
* Drop openssl-doc in favour of the libssl-doc package introduced by
  Debian.  Add Conflicts/Replaces until the next LTS release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
135
135
#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
136
136
#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
 
137
#define PEM_STRING_PARAMETERS   "PARAMETERS"
137
138
#define PEM_STRING_CMS          "CMS"
138
139
 
139
140
  /* Note that this structure is initialised by PEM_SealInit and cleaned up
183
184
        int num_recipient;
184
185
        PEM_USER **recipient;
185
186
 
186
 
#ifndef OPENSSL_NO_STACK
187
 
        STACK *x509_chain;      /* certificate chain */
188
 
#else
189
 
        char *x509_chain;       /* certificate chain */
190
 
#endif
 
187
        /* XXX(ben): don#t think this is used! 
 
188
                STACK *x509_chain;      / * certificate chain */
191
189
        EVP_MD *md;             /* signature type */
192
190
 
193
191
        int md_enc;             /* is the md encrypted or not? */
224
222
#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
225
223
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
226
224
{ \
227
 
    return (type*)PEM_ASN1_read(CHECKED_D2I_OF(type, d2i_##asn1), \
228
 
                                str, fp, \
229
 
                                CHECKED_PPTR_OF(type, x), \
230
 
                                cb, u); \
 
225
return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
231
226
232
227
 
233
228
#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
234
229
int PEM_write_##name(FILE *fp, type *x) \
235
230
{ \
236
 
    return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
237
 
                          str, fp, \
238
 
                          CHECKED_PTR_OF(type, x), \
239
 
                          NULL, NULL, 0, NULL, NULL); \
 
231
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
240
232
}
241
233
 
242
234
#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
243
235
int PEM_write_##name(FILE *fp, const type *x) \
244
236
{ \
245
 
    return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
246
 
                          str, fp, \
247
 
                          CHECKED_PTR_OF(const type, x), \
248
 
                          NULL, NULL, 0, NULL, NULL); \
 
237
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
249
238
}
250
239
 
251
240
#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
253
242
             unsigned char *kstr, int klen, pem_password_cb *cb, \
254
243
                  void *u) \
255
244
        { \
256
 
            return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
257
 
                                  str, fp, \
258
 
                                  CHECKED_PTR_OF(type, x), \
259
 
                                  enc, kstr, klen, cb, u); \
 
245
        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
260
246
        }
261
247
 
262
248
#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
264
250
             unsigned char *kstr, int klen, pem_password_cb *cb, \
265
251
                  void *u) \
266
252
        { \
267
 
            return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
268
 
                                  str, fp, \
269
 
                                  CHECKED_PTR_OF(const type, x), \
270
 
                                  enc, kstr, klen, cb, u); \
 
253
        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
271
254
        }
272
255
 
273
256
#endif
275
258
#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
276
259
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
277
260
{ \
278
 
    return (type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i_##asn1), \
279
 
                                    str, bp, \
280
 
                                    CHECKED_PPTR_OF(type, x), \
281
 
                                    cb, u); \
 
261
return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
282
262
}
283
263
 
284
264
#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
285
265
int PEM_write_bio_##name(BIO *bp, type *x) \
286
266
{ \
287
 
    return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
288
 
                              str, bp, \
289
 
                              CHECKED_PTR_OF(type, x), \
290
 
                              NULL, NULL, 0, NULL, NULL); \
 
267
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
291
268
}
292
269
 
293
270
#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
294
271
int PEM_write_bio_##name(BIO *bp, const type *x) \
295
272
{ \
296
 
    return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
297
 
                              str, bp, \
298
 
                              CHECKED_PTR_OF(const type, x), \
299
 
                              NULL, NULL, 0, NULL, NULL); \
 
273
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
300
274
}
301
275
 
302
276
#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
303
277
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
304
278
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
305
279
        { \
306
 
            return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
307
 
                                      str, bp, \
308
 
                                      CHECKED_PTR_OF(type, x), \
309
 
                                      enc, kstr, klen, cb, u); \
 
280
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
310
281
        }
311
282
 
312
283
#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
313
284
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
314
285
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
315
286
        { \
316
 
            return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
317
 
                                      str, bp, \
318
 
                                      CHECKED_PTR_OF(const type, x), \
319
 
                                      enc, kstr, klen, cb, u); \
 
287
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
320
288
        }
321
289
 
322
290
#define IMPLEMENT_PEM_write(name, type, str, asn1) \
353
321
 
354
322
/* These are the same except they are for the declarations */
355
323
 
356
 
#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API)
 
324
#if defined(OPENSSL_NO_FP_API)
357
325
 
358
326
#define DECLARE_PEM_read_fp(name, type) /**/
359
327
#define DECLARE_PEM_write_fp(name, type) /**/
360
 
#define DECLARE_PEM_write_fp_const(name, type) /**/
361
328
#define DECLARE_PEM_write_cb_fp(name, type) /**/
362
329
 
363
330
#else
428
395
        DECLARE_PEM_read(name, type) \
429
396
        DECLARE_PEM_write_cb(name, type)
430
397
 
431
 
#ifdef SSLEAY_MACROS
432
 
 
433
 
#define PEM_write_SSL_SESSION(fp,x) \
434
 
                PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
435
 
                        PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
436
 
#define PEM_write_X509(fp,x) \
437
 
                PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
438
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
439
 
#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
440
 
                (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
441
 
                        NULL,NULL,0,NULL,NULL)
442
 
#define PEM_write_X509_CRL(fp,x) \
443
 
                PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
444
 
                        fp,(char *)x, NULL,NULL,0,NULL,NULL)
445
 
#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
446
 
                PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
447
 
                        (char *)x,enc,kstr,klen,cb,u)
448
 
#define PEM_write_RSAPublicKey(fp,x) \
449
 
                PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
450
 
                        PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
451
 
#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
452
 
                PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
453
 
                        (char *)x,enc,kstr,klen,cb,u)
454
 
#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
455
 
                PEM_ASN1_write((int (*)())i2d_PrivateKey,\
456
 
                (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
457
 
                        bp,(char *)x,enc,kstr,klen,cb,u)
458
 
#define PEM_write_PKCS7(fp,x) \
459
 
                PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
460
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
461
 
#define PEM_write_DHparams(fp,x) \
462
 
                PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
463
 
                        (char *)x,NULL,NULL,0,NULL,NULL)
464
 
 
465
 
#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
466
 
                PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
467
 
                        PEM_STRING_X509,fp, \
468
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
469
 
 
470
 
#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
471
 
        (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
472
 
#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \
473
 
        (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u)
474
 
#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \
475
 
        (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u)
476
 
#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \
477
 
        (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u)
478
 
#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
479
 
        (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u)
480
 
#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
481
 
        (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u)
482
 
#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
483
 
        (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u)
484
 
#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \
485
 
        (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u)
486
 
#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \
487
 
        (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u)
488
 
#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \
489
 
        (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u)
490
 
 
491
 
#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \
492
 
                (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
493
 
        (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
494
 
                                                        (char **)x,cb,u)
495
 
 
496
 
#define PEM_write_bio_X509(bp,x) \
497
 
                PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
498
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
499
 
#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
500
 
                (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
501
 
                        NULL,NULL,0,NULL,NULL)
502
 
#define PEM_write_bio_X509_CRL(bp,x) \
503
 
                PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
504
 
                        bp,(char *)x, NULL,NULL,0,NULL,NULL)
505
 
#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
506
 
                PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
507
 
                        bp,(char *)x,enc,kstr,klen,cb,u)
508
 
#define PEM_write_bio_RSAPublicKey(bp,x) \
509
 
                PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
510
 
                        PEM_STRING_RSA_PUBLIC,\
511
 
                        bp,(char *)x,NULL,NULL,0,NULL,NULL)
512
 
#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
513
 
                PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
514
 
                        bp,(char *)x,enc,kstr,klen,cb,u)
515
 
#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
516
 
                PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
517
 
                (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
518
 
                        bp,(char *)x,enc,kstr,klen,cb,u)
519
 
#define PEM_write_bio_PKCS7(bp,x) \
520
 
                PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
521
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
522
 
#define PEM_write_bio_DHparams(bp,x) \
523
 
                PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
524
 
                        bp,(char *)x,NULL,NULL,0,NULL,NULL)
525
 
#define PEM_write_bio_DSAparams(bp,x) \
526
 
                PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
527
 
                        PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL)
528
 
 
529
 
#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
530
 
                PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
531
 
                        PEM_STRING_X509,bp, \
532
 
                        (char *)x, NULL,NULL,0,NULL,NULL)
533
 
 
534
 
#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
535
 
        (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
536
 
#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
537
 
        (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u)
538
 
#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \
539
 
        (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u)
540
 
#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
541
 
        (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u)
542
 
#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
543
 
        (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u)
544
 
#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
545
 
        (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u)
546
 
#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \
547
 
        (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u)
548
 
 
549
 
#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \
550
 
        (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u)
551
 
#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \
552
 
        (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u)
553
 
#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
554
 
        (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u)
555
 
 
556
 
#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \
557
 
                (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
558
 
        (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
559
 
                                                        (char **)x,cb,u)
560
 
 
561
 
#endif
562
 
 
563
398
#if 1
564
399
/* "userdata": new with OpenSSL 0.9.4 */
565
400
typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
581
416
             pem_password_cb *cb, void *u);
582
417
void *  PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
583
418
                          void **x, pem_password_cb *cb, void *u);
584
 
 
585
 
#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
586
 
    ((type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i), \
587
 
                              name, bp,                 \
588
 
                              CHECKED_PPTR_OF(type, x), \
589
 
                              cb, u))
590
 
 
591
 
int     PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
 
419
int     PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x,
592
420
                           const EVP_CIPHER *enc,unsigned char *kstr,int klen,
593
421
                           pem_password_cb *cb, void *u);
594
422
 
595
 
#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
596
 
    (PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d), \
597
 
                        name, bp,                  \
598
 
                        CHECKED_PTR_OF(type, x), \
599
 
                        enc, kstr, klen, cb, u))
600
 
 
601
423
STACK_OF(X509_INFO) *   PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
602
424
int     PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
603
425
                unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
604
426
#endif
605
427
 
606
 
#ifndef OPENSSL_SYS_WIN16
607
428
int     PEM_read(FILE *fp, char **name, char **header,
608
429
                unsigned char **data,long *len);
609
430
int     PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
610
431
void *  PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
611
432
                      pem_password_cb *cb, void *u);
612
433
int     PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
613
 
                       char *x,const EVP_CIPHER *enc,unsigned char *kstr,
 
434
                       void *x,const EVP_CIPHER *enc,unsigned char *kstr,
614
435
                       int klen,pem_password_cb *callback, void *u);
615
436
STACK_OF(X509_INFO) *   PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
616
437
        pem_password_cb *cb, void *u);
617
 
#endif
618
438
 
619
439
int     PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
620
440
                EVP_MD *md_type, unsigned char **ek, int *ekl,
633
453
void    PEM_proc_type(char *buf, int type);
634
454
void    PEM_dek_info(char *buf, const char *type, int len, char *str);
635
455
 
636
 
#ifndef SSLEAY_MACROS
637
456
 
638
457
#include <openssl/symhacks.h>
639
458
 
719
538
int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
720
539
                              char *kstr,int klen, pem_password_cb *cd, void *u);
721
540
 
722
 
#endif /* SSLEAY_MACROS */
 
541
EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
 
542
int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
 
543
 
 
544
 
 
545
EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
 
546
EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
 
547
EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
 
548
EVP_PKEY *b2i_PublicKey_bio(BIO *in);
 
549
int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
 
550
int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
 
551
#ifndef OPENSSL_NO_RC4
 
552
EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
 
553
int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
 
554
                pem_password_cb *cb, void *u);
 
555
#endif
723
556
 
724
557
 
725
558
/* BEGIN ERROR CODES */
731
564
/* Error codes for the PEM functions. */
732
565
 
733
566
/* Function codes. */
 
567
#define PEM_F_B2I_DSS                                    127
 
568
#define PEM_F_B2I_PVK_BIO                                128
 
569
#define PEM_F_B2I_RSA                                    129
 
570
#define PEM_F_CHECK_BITLEN_DSA                           130
 
571
#define PEM_F_CHECK_BITLEN_RSA                           131
734
572
#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120
735
573
#define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121
 
574
#define PEM_F_DO_B2I                                     132
 
575
#define PEM_F_DO_B2I_BIO                                 133
 
576
#define PEM_F_DO_BLOB_HEADER                             134
736
577
#define PEM_F_DO_PK8PKEY                                 126
737
578
#define PEM_F_DO_PK8PKEY_FP                              125
 
579
#define PEM_F_DO_PVK_BODY                                135
 
580
#define PEM_F_DO_PVK_HEADER                              136
 
581
#define PEM_F_I2B_PVK                                    137
 
582
#define PEM_F_I2B_PVK_BIO                                138
738
583
#define PEM_F_LOAD_IV                                    101
739
584
#define PEM_F_PEM_ASN1_READ                              102
740
585
#define PEM_F_PEM_ASN1_READ_BIO                          103
747
592
#define PEM_F_PEM_PK8PKEY                                119
748
593
#define PEM_F_PEM_READ                                   108
749
594
#define PEM_F_PEM_READ_BIO                               109
 
595
#define PEM_F_PEM_READ_BIO_PARAMETERS                    140
750
596
#define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123
751
597
#define PEM_F_PEM_READ_PRIVATEKEY                        124
752
598
#define PEM_F_PEM_SEALFINAL                              110
754
600
#define PEM_F_PEM_SIGNFINAL                              112
755
601
#define PEM_F_PEM_WRITE                                  113
756
602
#define PEM_F_PEM_WRITE_BIO                              114
 
603
#define PEM_F_PEM_WRITE_PRIVATEKEY                       139
757
604
#define PEM_F_PEM_X509_INFO_READ                         115
758
605
#define PEM_F_PEM_X509_INFO_READ_BIO                     116
759
606
#define PEM_F_PEM_X509_INFO_WRITE_BIO                    117
763
610
#define PEM_R_BAD_DECRYPT                                101
764
611
#define PEM_R_BAD_END_LINE                               102
765
612
#define PEM_R_BAD_IV_CHARS                               103
 
613
#define PEM_R_BAD_MAGIC_NUMBER                           116
766
614
#define PEM_R_BAD_PASSWORD_READ                          104
 
615
#define PEM_R_BAD_VERSION_NUMBER                         117
 
616
#define PEM_R_BIO_WRITE_FAILURE                          118
 
617
#define PEM_R_CIPHER_IS_NULL                             127
767
618
#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115
 
619
#define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119
 
620
#define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120
 
621
#define PEM_R_INCONSISTENT_HEADER                        121
 
622
#define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122
 
623
#define PEM_R_KEYBLOB_TOO_SHORT                          123
768
624
#define PEM_R_NOT_DEK_INFO                               105
769
625
#define PEM_R_NOT_ENCRYPTED                              106
770
626
#define PEM_R_NOT_PROC_TYPE                              107
771
627
#define PEM_R_NO_START_LINE                              108
772
628
#define PEM_R_PROBLEMS_GETTING_PASSWORD                  109
773
629
#define PEM_R_PUBLIC_KEY_NO_RSA                          110
 
630
#define PEM_R_PVK_DATA_TOO_SHORT                         124
 
631
#define PEM_R_PVK_TOO_SHORT                              125
774
632
#define PEM_R_READ_KEY                                   111
775
633
#define PEM_R_SHORT_HEADER                               112
776
634
#define PEM_R_UNSUPPORTED_CIPHER                         113
777
635
#define PEM_R_UNSUPPORTED_ENCRYPTION                     114
 
636
#define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126
778
637
 
779
638
#ifdef  __cplusplus
780
639
}