1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimPEM_read_bio_ex, PEM_FLAG_SECURE, PEM_FLAG_EAY_COMPATIBLE, 6e71b7053SJung-uk KimPEM_FLAG_ONLY_B64 - read PEM format files with custom processing 7e71b7053SJung-uk Kim 8e71b7053SJung-uk Kim=head1 SYNOPSIS 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim #include <openssl/pem.h> 11e71b7053SJung-uk Kim 12e71b7053SJung-uk Kim #define PEM_FLAG_SECURE 0x1 13e71b7053SJung-uk Kim #define PEM_FLAG_EAY_COMPATIBLE 0x2 14e71b7053SJung-uk Kim #define PEM_FLAG_ONLY_B64 0x4 15e71b7053SJung-uk Kim int PEM_read_bio_ex(BIO *in, char **name, char **header, 16e71b7053SJung-uk Kim unsigned char **data, long *len, unsigned int flags); 17e71b7053SJung-uk Kim 18e71b7053SJung-uk Kim=head1 DESCRIPTION 19e71b7053SJung-uk Kim 20e71b7053SJung-uk KimPEM_read_bio_ex() reads in PEM formatted data from an input BIO, outputting 21e71b7053SJung-uk Kimthe name of the type of contained data, the header information regarding 22e71b7053SJung-uk Kimthe possibly encrypted data, and the binary data payload (after base64 decoding). 23e71b7053SJung-uk KimIt should generally only be used to implement PEM_read_bio_-family functions 24e71b7053SJung-uk Kimfor specific data types or other usage, but is exposed to allow greater flexibility 25e71b7053SJung-uk Kimover how processing is performed, if needed. 26e71b7053SJung-uk Kim 27e71b7053SJung-uk KimIf PEM_FLAG_SECURE is set, the intermediate buffers used to read in lines of 28e71b7053SJung-uk Kiminput are allocated from the secure heap. 29e71b7053SJung-uk Kim 30e71b7053SJung-uk KimIf PEM_FLAG_EAY_COMPATIBLE is set, a simple algorithm is used to remove whitespace 31e71b7053SJung-uk Kimand control characters from the end of each line, so as to be compatible with 32e71b7053SJung-uk Kimthe historical behavior of PEM_read_bio(). 33e71b7053SJung-uk Kim 34e71b7053SJung-uk KimIf PEM_FLAG_ONLY_B64 is set, all characters are required to be valid base64 35e71b7053SJung-uk Kimcharacters (or newlines); non-base64 characters are treated as end of input. 36e71b7053SJung-uk Kim 37e71b7053SJung-uk KimIf neither PEM_FLAG_EAY_COMPATIBLE or PEM_FLAG_ONLY_B64 is set, control characters 38e71b7053SJung-uk Kimare ignored. 39e71b7053SJung-uk Kim 40e71b7053SJung-uk KimIf both PEM_FLAG_EAY_COMPATIBLE and PEM_FLAG_ONLY_B64 are set, an error is returned; 41e71b7053SJung-uk Kimthese options are not compatible with each other. 42e71b7053SJung-uk Kim 43e71b7053SJung-uk Kim=head1 NOTES 44e71b7053SJung-uk Kim 45e71b7053SJung-uk KimThe caller must release the storage allocated for *name, *header, and *data. 46e71b7053SJung-uk KimIf PEM_FLAG_SECURE was set, use OPENSSL_secure_free(); otherwise, 47e71b7053SJung-uk KimOPENSSL_free() is used. 48e71b7053SJung-uk Kim 49e71b7053SJung-uk Kim=head1 RETURN VALUES 50e71b7053SJung-uk Kim 51e71b7053SJung-uk KimPEM_read_bio_ex() returns 1 for success or 0 for failure. 52e71b7053SJung-uk Kim 53e71b7053SJung-uk Kim=head1 SEE ALSO 54e71b7053SJung-uk Kim 5517f01e99SJung-uk KimL<PEM_bytes_read_bio(3)> 56e71b7053SJung-uk Kim 57e71b7053SJung-uk Kim=head1 HISTORY 58e71b7053SJung-uk Kim 596935a639SJung-uk KimThe PEM_read_bio_ex() function was added in OpenSSL 1.1.1. 60e71b7053SJung-uk Kim 61e71b7053SJung-uk Kim=head1 COPYRIGHT 62e71b7053SJung-uk Kim 63e71b7053SJung-uk KimCopyright 2017 The OpenSSL Project Authors. All Rights Reserved. 64e71b7053SJung-uk Kim 65*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 66e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 67e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 68e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 69e71b7053SJung-uk Kim 70e71b7053SJung-uk Kim=cut 71