PEM_bytes_read_bio.3ossl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "PEM_BYTES_READ_BIO 3ossl"
  58. .TH PEM_BYTES_READ_BIO 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. PEM_bytes_read_bio, PEM_bytes_read_bio_secmem \- read a PEM\-encoded data structure from a BIO
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. .Vb 1
  68. \& #include <openssl/pem.h>
  69. \&
  70. \& int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
  71. \& const char *name, BIO *bp, pem_password_cb *cb,
  72. \& void *u);
  73. \& int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
  74. \& const char *name, BIO *bp, pem_password_cb *cb,
  75. \& void *u);
  76. .Ve
  77. .SH DESCRIPTION
  78. .IX Header "DESCRIPTION"
  79. \&\fBPEM_bytes_read_bio()\fR reads PEM-formatted (IETF RFC 1421 and IETF RFC 7468)
  80. data from the BIO
  81. \&\fIbp\fR for the data type given in \fIname\fR (RSA PRIVATE KEY, CERTIFICATE,
  82. etc.). If multiple PEM-encoded data structures are present in the same
  83. stream, \fBPEM_bytes_read_bio()\fR will skip non-matching data types and
  84. continue reading. Non-PEM data present in the stream may cause an
  85. error.
  86. .PP
  87. The PEM header may indicate that the following data is encrypted; if so,
  88. the data will be decrypted, waiting on user input to supply a passphrase
  89. if needed. The password callback \fIcb\fR and rock \fIu\fR are used to obtain
  90. the decryption passphrase, if applicable.
  91. .PP
  92. Some data types have compatibility aliases, such as a file containing
  93. X509 CERTIFICATE matching a request for the deprecated type CERTIFICATE.
  94. The actual type indicated by the file is returned in \fI*pnm\fR if \fIpnm\fR is
  95. non-NULL. The caller must free the storage pointed to by \fI*pnm\fR.
  96. .PP
  97. The returned data is the DER-encoded form of the requested type, in
  98. \&\fI*pdata\fR with length \fI*plen\fR. The caller must free the storage pointed
  99. to by \fI*pdata\fR.
  100. .PP
  101. \&\fBPEM_bytes_read_bio_secmem()\fR is similar to \fBPEM_bytes_read_bio()\fR, but uses
  102. memory from the secure heap for its temporary buffers and the storage
  103. returned in \fI*pdata\fR and \fI*pnm\fR. Accordingly, the caller must use
  104. \&\fBOPENSSL_secure_free()\fR to free that storage.
  105. .SH NOTES
  106. .IX Header "NOTES"
  107. \&\fBPEM_bytes_read_bio_secmem()\fR only enforces that the secure heap is used for
  108. storage allocated within the PEM processing stack. The BIO stack from
  109. which input is read may also use temporary buffers, which are not necessarily
  110. allocated from the secure heap. In cases where it is desirable to ensure
  111. that the contents of the PEM file only appears in memory from the secure heap,
  112. care is needed in generating the BIO passed as \fIbp\fR. In particular, the
  113. use of \fBBIO_s_file()\fR indicates the use of the operating system stdio
  114. functionality, which includes buffering as a feature; \fBBIO_s_fd()\fR is likely
  115. to be more appropriate in such cases.
  116. .PP
  117. These functions make no assumption regarding the pass phrase received from the
  118. password callback.
  119. It will simply be treated as a byte sequence.
  120. .SH "RETURN VALUES"
  121. .IX Header "RETURN VALUES"
  122. \&\fBPEM_bytes_read_bio()\fR and \fBPEM_bytes_read_bio_secmem()\fR return 1 for success or
  123. 0 for failure.
  124. .SH "SEE ALSO"
  125. .IX Header "SEE ALSO"
  126. \&\fBPEM_read_bio_ex\fR\|(3),
  127. \&\fBpassphrase\-encoding\fR\|(7)
  128. .SH HISTORY
  129. .IX Header "HISTORY"
  130. \&\fBPEM_bytes_read_bio_secmem()\fR was introduced in OpenSSL 1.1.1
  131. .SH COPYRIGHT
  132. .IX Header "COPYRIGHT"
  133. Copyright 2017\-2018 The OpenSSL Project Authors. All Rights Reserved.
  134. .PP
  135. Licensed under the Apache License 2.0 (the "License"). You may not use
  136. this file except in compliance with the License. You can obtain a copy
  137. in the file LICENSE in the source distribution or at
  138. <https://www.openssl.org/source/license.html>.