PEM_bytes_read_bio.pod 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. =pod
  2. =head1 NAME
  3. PEM_bytes_read_bio, PEM_bytes_read_bio_secmem - read a PEM-encoded data structure from a BIO
  4. =head1 SYNOPSIS
  5. #include <openssl/pem.h>
  6. int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
  7. const char *name, BIO *bp, pem_password_cb *cb,
  8. void *u);
  9. int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
  10. const char *name, BIO *bp, pem_password_cb *cb,
  11. void *u);
  12. =head1 DESCRIPTION
  13. PEM_bytes_read_bio() reads PEM-formatted (IETF RFC 1421 and IETF RFC 7468)
  14. data from the BIO
  15. I<bp> for the data type given in I<name> (RSA PRIVATE KEY, CERTIFICATE,
  16. etc.). If multiple PEM-encoded data structures are present in the same
  17. stream, PEM_bytes_read_bio() will skip non-matching data types and
  18. continue reading. Non-PEM data present in the stream may cause an
  19. error.
  20. The PEM header may indicate that the following data is encrypted; if so,
  21. the data will be decrypted, waiting on user input to supply a passphrase
  22. if needed. The password callback I<cb> and rock I<u> are used to obtain
  23. the decryption passphrase, if applicable.
  24. Some data types have compatibility aliases, such as a file containing
  25. X509 CERTIFICATE matching a request for the deprecated type CERTIFICATE.
  26. The actual type indicated by the file is returned in I<*pnm> if I<pnm> is
  27. non-NULL. The caller must free the storage pointed to by I<*pnm>.
  28. The returned data is the DER-encoded form of the requested type, in
  29. I<*pdata> with length I<*plen>. The caller must free the storage pointed
  30. to by I<*pdata>.
  31. PEM_bytes_read_bio_secmem() is similar to PEM_bytes_read_bio(), but uses
  32. memory from the secure heap for its temporary buffers and the storage
  33. returned in I<*pdata> and I<*pnm>. Accordingly, the caller must use
  34. OPENSSL_secure_free() to free that storage.
  35. =head1 NOTES
  36. PEM_bytes_read_bio_secmem() only enforces that the secure heap is used for
  37. storage allocated within the PEM processing stack. The BIO stack from
  38. which input is read may also use temporary buffers, which are not necessarily
  39. allocated from the secure heap. In cases where it is desirable to ensure
  40. that the contents of the PEM file only appears in memory from the secure heap,
  41. care is needed in generating the BIO passed as I<bp>. In particular, the
  42. use of BIO_s_file() indicates the use of the operating system stdio
  43. functionality, which includes buffering as a feature; BIO_s_fd() is likely
  44. to be more appropriate in such cases.
  45. These functions make no assumption regarding the pass phrase received from the
  46. password callback.
  47. It will simply be treated as a byte sequence.
  48. =head1 RETURN VALUES
  49. PEM_bytes_read_bio() and PEM_bytes_read_bio_secmem() return 1 for success or
  50. 0 for failure.
  51. =head1 SEE ALSO
  52. L<PEM_read_bio_ex(3)>,
  53. L<passphrase-encoding(7)>
  54. =head1 HISTORY
  55. PEM_bytes_read_bio_secmem() was introduced in OpenSSL 1.1.1
  56. =head1 COPYRIGHT
  57. Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  58. Licensed under the Apache License 2.0 (the "License"). You may not use
  59. this file except in compliance with the License. You can obtain a copy
  60. in the file LICENSE in the source distribution or at
  61. L<https://www.openssl.org/source/license.html>.
  62. =cut