Blame doc/man3/PEM_bytes_read_bio.pod

Packit Service 084de1
=pod
Packit Service 084de1
Packit Service 084de1
=head1 NAME
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio, PEM_bytes_read_bio_secmem - read a PEM-encoded data structure from a BIO
Packit Service 084de1
Packit Service 084de1
=head1 SYNOPSIS
Packit Service 084de1
Packit Service 084de1
 #include <openssl/pem.h>
Packit Service 084de1
Packit Service 084de1
 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
Packit Service 084de1
                        const char *name, BIO *bp, pem_password_cb *cb,
Packit Service 084de1
                        void *u);
Packit Service 084de1
 int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
Packit Service 084de1
                               const char *name, BIO *bp, pem_password_cb *cb,
Packit Service 084de1
                               void *u);
Packit Service 084de1
Packit Service 084de1
=head1 DESCRIPTION
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio() reads PEM-formatted (IETF RFC 1421 and IETF RFC 7468)
Packit Service 084de1
data from the BIO
Packit Service 084de1
I<bp> for the data type given in I<name> (RSA PRIVATE KEY, CERTIFICATE,
Packit Service 084de1
etc.).  If multiple PEM-encoded data structures are present in the same
Packit Service 084de1
stream, PEM_bytes_read_bio() will skip non-matching data types and
Packit Service 084de1
continue reading.  Non-PEM data present in the stream may cause an
Packit Service 084de1
error.
Packit Service 084de1
Packit Service 084de1
The PEM header may indicate that the following data is encrypted; if so,
Packit Service 084de1
the data will be decrypted, waiting on user input to supply a passphrase
Packit Service 084de1
if needed.  The password callback I<cb> and rock I<u> are used to obtain
Packit Service 084de1
the decryption passphrase, if applicable.
Packit Service 084de1
Packit Service 084de1
Some data types have compatibility aliases, such as a file containing
Packit Service 084de1
X509 CERTIFICATE matching a request for the deprecated type CERTIFICATE.
Packit Service 084de1
The actual type indicated by the file is returned in I<*pnm> if I<pnm> is
Packit Service 084de1
non-NULL.  The caller must free the storage pointed to by I<*pnm>.
Packit Service 084de1
Packit Service 084de1
The returned data is the DER-encoded form of the requested type, in
Packit Service 084de1
I<*pdata> with length I<*plen>.  The caller must free the storage pointed
Packit Service 084de1
to by I<*pdata>.
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio_secmem() is similar to PEM_bytes_read_bio(), but uses
Packit Service 084de1
memory from the secure heap for its temporary buffers and the storage
Packit Service 084de1
returned in I<*pdata> and I<*pnm>.  Accordingly, the caller must use
Packit Service 084de1
OPENSSL_secure_free() to free that storage.
Packit Service 084de1
Packit Service 084de1
=head1 NOTES
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio_secmem() only enforces that the secure heap is used for
Packit Service 084de1
storage allocated within the PEM processing stack.  The BIO stack from
Packit Service 084de1
which input is read may also use temporary buffers, which are not necessarily
Packit Service 084de1
allocated from the secure heap.  In cases where it is desirable to ensure
Packit Service 084de1
that the contents of the PEM file only appears in memory from the secure heap,
Packit Service 084de1
care is needed in generating the BIO passed as I<bp>.  In particular, the
Packit Service 084de1
use of BIO_s_file() indicates the use of the operating system stdio
Packit Service 084de1
functionality, which includes buffering as a feature; BIO_s_fd() is likely
Packit Service 084de1
to be more appropriate in such cases.
Packit Service 084de1
Packit Service 084de1
These functions make no assumption regarding the pass phrase received from the
Packit Service 084de1
password callback.
Packit Service 084de1
It will simply be treated as a byte sequence.
Packit Service 084de1
Packit Service 084de1
=head1 RETURN VALUES
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio() and PEM_bytes_read_bio_secmem() return 1 for success or
Packit Service 084de1
0 for failure.
Packit Service 084de1
Packit Service 084de1
=head1 SEE ALSO
Packit Service 084de1
Packit Service 084de1
L<PEM_read_bio_ex(3)>,
Packit Service 084de1
L<passphrase-encoding(7)>
Packit Service 084de1
Packit Service 084de1
=head1 HISTORY
Packit Service 084de1
Packit Service 084de1
PEM_bytes_read_bio_secmem() was introduced in OpenSSL 1.1.1
Packit Service 084de1
Packit Service 084de1
=head1 COPYRIGHT
Packit Service 084de1
Packit Service 084de1
Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
Packit Service 084de1
Licensed under the OpenSSL license (the "License").  You may not use
Packit Service 084de1
this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
in the file LICENSE in the source distribution or at
Packit Service 084de1
L<https://www.openssl.org/source/license.html>.
Packit Service 084de1
Packit Service 084de1
=cut