summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2020-07-23 17:34:53 +0000
committerschwarze <>2020-07-23 17:34:53 +0000
commit7df61e79b329ba8e55819ef265e5777895818e4b (patch)
tree83f13dff95bedcb0a38d8cee8e603a9eefa0743c /src
parent006d896f4376dbbbff0a958d5fe8639ab0c070d5 (diff)
downloadopenbsd-7df61e79b329ba8e55819ef265e5777895818e4b.tar.gz
openbsd-7df61e79b329ba8e55819ef265e5777895818e4b.tar.bz2
openbsd-7df61e79b329ba8e55819ef265e5777895818e4b.zip
document PEM_X509_INFO_read(3) and PEM_X509_INFO_read_bio(3)
OK tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/Makefile3
-rw-r--r--src/lib/libcrypto/man/PEM_ASN1_read.37
-rw-r--r--src/lib/libcrypto/man/PEM_X509_INFO_read.3187
-rw-r--r--src/lib/libcrypto/man/PEM_bytes_read_bio.37
-rw-r--r--src/lib/libcrypto/man/PEM_read.37
-rw-r--r--src/lib/libcrypto/man/PEM_read_bio_PrivateKey.35
-rw-r--r--src/lib/libcrypto/man/X509_INFO_new.35
7 files changed, 207 insertions, 14 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 8114f5b96b..0d39580971 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.170 2020/06/24 17:00:38 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.171 2020/07/23 17:34:53 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -206,6 +206,7 @@ MAN= \
206 OPENSSL_sk_new.3 \ 206 OPENSSL_sk_new.3 \
207 OpenSSL_add_all_algorithms.3 \ 207 OpenSSL_add_all_algorithms.3 \
208 PEM_ASN1_read.3 \ 208 PEM_ASN1_read.3 \
209 PEM_X509_INFO_read.3 \
209 PEM_bytes_read_bio.3 \ 210 PEM_bytes_read_bio.3 \
210 PEM_read.3 \ 211 PEM_read.3 \
211 PEM_read_bio_PrivateKey.3 \ 212 PEM_read_bio_PrivateKey.3 \
diff --git a/src/lib/libcrypto/man/PEM_ASN1_read.3 b/src/lib/libcrypto/man/PEM_ASN1_read.3
index cea0c2df68..53ebe5ada4 100644
--- a/src/lib/libcrypto/man/PEM_ASN1_read.3
+++ b/src/lib/libcrypto/man/PEM_ASN1_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_ASN1_read.3,v 1.1 2020/06/12 11:37:42 schwarze Exp $ 1.\" $OpenBSD: PEM_ASN1_read.3,v 1.2 2020/07/23 17:34:53 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2020 $ 17.Dd $Mdocdate: July 23 2020 $
18.Dt PEM_ASN1_READ 3 18.Dt PEM_ASN1_READ 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -164,7 +164,8 @@ Additional types of errors can result from
164.Xr PEM_bytes_read_bio 3 , 164.Xr PEM_bytes_read_bio 3 ,
165.Xr PEM_read 3 , 165.Xr PEM_read 3 ,
166.Xr PEM_read_bio_PrivateKey 3 , 166.Xr PEM_read_bio_PrivateKey 3 ,
167.Xr PEM_read_SSL_SESSION 3 167.Xr PEM_read_SSL_SESSION 3 ,
168.Xr PEM_X509_INFO_read 3
168.Sh HISTORY 169.Sh HISTORY
169These functions first appeared in SSLeay 0.5.1 170These functions first appeared in SSLeay 0.5.1
170and have been available since 171and have been available since
diff --git a/src/lib/libcrypto/man/PEM_X509_INFO_read.3 b/src/lib/libcrypto/man/PEM_X509_INFO_read.3
new file mode 100644
index 0000000000..72658e2b61
--- /dev/null
+++ b/src/lib/libcrypto/man/PEM_X509_INFO_read.3
@@ -0,0 +1,187 @@
1.\" $OpenBSD: PEM_X509_INFO_read.3,v 1.1 2020/07/23 17:34:53 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 23 2020 $
18.Dt PEM_X509_INFO_READ 3
19.Os
20.Sh NAME
21.Nm PEM_X509_INFO_read ,
22.Nm PEM_X509_INFO_read_bio
23.Nd PEM and DER decode X.509 certificates, private keys, and revocation lists
24.Sh SYNOPSIS
25.In openssl/pem.h
26.Ft STACK_OF(X509_INFO) *
27.Fo PEM_X509_INFO_read
28.Fa "FILE *in_fp"
29.Fa "STACK_OF(X509_INFO) *sk"
30.Fa "pem_password_cb *cb"
31.Fa "void *u"
32.Fc
33.Ft STACK_OF(X509_INFO) *
34.Fo PEM_X509_INFO_read_bio
35.Fa "BIO *in_bp"
36.Fa "STACK_OF(X509_INFO) *sk"
37.Fa "pem_password_cb *cb"
38.Fa "void *u"
39.Fc
40.Sh DESCRIPTION
41These functions read zero or more objects
42releated to X.509 certificates from
43.Fa in_fp
44or
45.Fa in_bp ,
46perform both PEM and DER decoding,
47and wrap the resulting objects in newly allocated
48.Vt X509_INFO
49containers.
50.Pp
51Setting
52.Fa sk
53to
54.Dv NULL
55is recommended, in which case
56a new stack is allocated, populated, and returned.
57If an existing
58.Fa sk
59is passed in, the created
60.Vt X509_INFO
61objects are pushed onto that stack.
62.Pp
63For PEM decoding,
64.Xr PEM_read_bio 3
65is used internally, implying that any non-PEM data
66before, between, and after the objects is silently discarded.
67.Pp
68For subsequent DER decoding,
69the decoding function and the field of the
70.Vt X509_INFO
71structure to store the new object in
72are selected according to the PEM type name:
73.Bl -column "TRUSTED CERTIFICATE" "d2i_PrivateKey()" "revocation list"
74.It PEM type name Ta decoder Ta Vt X509_INFO No field
75.It CERTIFICATE Ta Xr d2i_X509 3 Ta certificate
76.It X509 CERTIFICATE Ta Xr d2i_X509 3 Ta certificate
77.It TRUSTED CERTIFICATE Ta Xr d2i_X509_AUX 3 Ta certificate
78.It X509 CRL Ta Xr d2i_X509_CRL 3 Ta revocation list
79.It RSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
80.It DSA PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
81.It EC PRIVATE KEY Ta Xr d2i_PrivateKey 3 Ta private key
82.El
83.Pp
84Whenever the selected field is already occupied, another new
85.Vt X509_INFO
86container is allocated and pushed onto the stack.
87Depending on the sequence of objects in the input, this can result
88in several partially populated
89.Vt X509_INFO
90containers being pushed onto the stack.
91.Pp
92PEM objects of types not listed in the above table are silently skipped.
93.Pp
94Encrypted certificates and revocation lists are decrypted by calling
95.Xr PEM_do_header 3
96internally, passing through the optional arguments
97.Fa cb
98and
99.Fa u .
100Encrypted private keys are not decrypted.
101Instead, the encrypted form is stored as read.
102All the same,
103.Xr PEM_get_EVP_CIPHER_INFO 3
104is called internally to check that PEM headers, if there are any,
105are valid and specify an encryption the library is prepared to handle.
106.Pp
107If any error occurs, objects that had already been read
108during the same call are deleted again and
109.Fa sk
110is left unchanged.
111.Sh RETURN VALUES
112These functions return a pointer to the stack
113the objects read were pushed onto or
114.Dv NULL
115if an error occurs.
116They fail if
117.Xr PEM_read_bio 3 ,
118.Xr PEM_get_EVP_CIPHER_INFO 3 ,
119.Xr PEM_do_header 3 ,
120or DER decoding fails or if memory is exhausted.
121.Sh ERRORS
122Diagnostics that can be retrieved with
123.Xr ERR_get_error 3 ,
124.Xr ERR_GET_REASON 3 ,
125and
126.Xr ERR_reason_error_string 3
127include:
128.Bl -tag -width Ds
129.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
130DER decoding of a PEM object failed.
131.It Dv ERR_R_BUF_LIB Qq BUF lib
132.Fn PEM_X509_INFO_read
133failed to set up a temporary BIO, for example because memory was exhausted.
134.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
135.Fn PEM_X509_INFO_read_bio
136failed to allocate a new
137.Vt X509_INFO ,
138.Vt STACK_OF(X509_INFO) ,
139or
140.Vt X509_PKEY
141object.
142.El
143.Pp
144Additional types of errors can result from
145.Xr PEM_read_bio 3 ,
146.Xr PEM_get_EVP_CIPHER_INFO 3 ,
147and
148.Xr PEM_do_header 3 .
149.Pp
150After these functions failed due to memory exhaustion,
151.Xr ERR_get_error 3
152may sometimes return 0 anyway.
153.Sh SEE ALSO
154.Xr BIO_new 3 ,
155.Xr d2i_PrivateKey 3 ,
156.Xr d2i_X509 3 ,
157.Xr d2i_X509_CRL 3 ,
158.Xr EVP_PKEY_new 3 ,
159.Xr PEM_read 3 ,
160.Xr PEM_read_bio_PrivateKey 3 ,
161.Xr STACK_OF 3 ,
162.Xr X509_CRL_new 3 ,
163.Xr X509_INFO_new 3 ,
164.Xr X509_new 3
165.Sh HISTORY
166.Fn PEM_X509_INFO_read
167first appeared in SSLeay 0.5.1 and
168.Fn PEM_X509_INFO_read_bio
169in SSLeay 0.6.0.
170Both functions have been available since
171.Ox 2.4 .
172.Sh CAVEATS
173It is not an error
174if the input does not contain any objects of the desired types.
175In that case, nothing is added to
176.Fa sk ,
177or if
178.Fa sk
179is
180.Dv NULL ,
181a newly allocated, empty stack is returned.
182The only way to detect this situation is by comparing
183the number of objects on the stack before and after the call.
184.Sh BUGS
185When reaching the end of the input, these functions call
186.Xr ERR_clear_error 3 ,
187which may hide errors that occurred before calling these functions.
diff --git a/src/lib/libcrypto/man/PEM_bytes_read_bio.3 b/src/lib/libcrypto/man/PEM_bytes_read_bio.3
index d1148edfe0..20ad6b8a4d 100644
--- a/src/lib/libcrypto/man/PEM_bytes_read_bio.3
+++ b/src/lib/libcrypto/man/PEM_bytes_read_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_bytes_read_bio.3,v 1.5 2020/06/15 14:13:14 schwarze Exp $ 1.\" $OpenBSD: PEM_bytes_read_bio.3,v 1.6 2020/07/23 17:34:53 schwarze Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600 3.\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600
4.\" 4.\"
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: June 15 2020 $ 68.Dd $Mdocdate: July 23 2020 $
69.Dt PEM_BYTES_READ_BIO 3 69.Dt PEM_BYTES_READ_BIO 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -174,7 +174,8 @@ Additional types of errors can result from
174.Sh SEE ALSO 174.Sh SEE ALSO
175.Xr PEM_ASN1_read 3 , 175.Xr PEM_ASN1_read 3 ,
176.Xr PEM_read 3 , 176.Xr PEM_read 3 ,
177.Xr PEM_read_bio_PrivateKey 3 177.Xr PEM_read_bio_PrivateKey 3 ,
178.Xr PEM_X509_INFO_read 3
178.Sh STANDARDS 179.Sh STANDARDS
179RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I 180RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I
180.Sh HISTORY 181.Sh HISTORY
diff --git a/src/lib/libcrypto/man/PEM_read.3 b/src/lib/libcrypto/man/PEM_read.3
index 49cdd0f3c5..bbe2b77bd7 100644
--- a/src/lib/libcrypto/man/PEM_read.3
+++ b/src/lib/libcrypto/man/PEM_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_read.3,v 1.11 2020/06/15 14:13:14 schwarze Exp $ 1.\" $OpenBSD: PEM_read.3,v 1.12 2020/07/23 17:34:53 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: June 15 2020 $ 69.Dd $Mdocdate: July 23 2020 $
70.Dt PEM_READ 3 70.Dt PEM_READ 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -388,7 +388,8 @@ to fail may differ.
388.Xr PEM_read_bio_PrivateKey 3 , 388.Xr PEM_read_bio_PrivateKey 3 ,
389.Xr PEM_read_SSL_SESSION 3 , 389.Xr PEM_read_SSL_SESSION 3 ,
390.Xr PEM_write_bio_CMS_stream 3 , 390.Xr PEM_write_bio_CMS_stream 3 ,
391.Xr PEM_write_bio_PKCS7_stream 3 391.Xr PEM_write_bio_PKCS7_stream 3 ,
392.Xr PEM_X509_INFO_read 3
392.Sh HISTORY 393.Sh HISTORY
393.Fn PEM_write , 394.Fn PEM_write ,
394.Fn PEM_read , 395.Fn PEM_read ,
diff --git a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
index cc58640b1c..89677a7cb3 100644
--- a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
+++ b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.18 2020/06/15 14:13:14 schwarze Exp $ 1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.19 2020/07/23 17:34:53 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100 3.\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100
4.\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100 4.\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: June 15 2020 $ 54.Dd $Mdocdate: July 23 2020 $
55.Dt PEM_READ_BIO_PRIVATEKEY 3 55.Dt PEM_READ_BIO_PRIVATEKEY 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -1217,6 +1217,7 @@ pass_cb(char *buf, int size, int rwflag, void *u)
1217.Xr PEM_read_SSL_SESSION 3 , 1217.Xr PEM_read_SSL_SESSION 3 ,
1218.Xr PEM_write_bio_CMS_stream 3 , 1218.Xr PEM_write_bio_CMS_stream 3 ,
1219.Xr PEM_write_bio_PKCS7_stream 3 , 1219.Xr PEM_write_bio_PKCS7_stream 3 ,
1220.Xr PEM_X509_INFO_read 3 ,
1220.Xr RSA_new 3 , 1221.Xr RSA_new 3 ,
1221.Xr X509_CRL_new 3 , 1222.Xr X509_CRL_new 3 ,
1222.Xr X509_REQ_new 3 , 1223.Xr X509_REQ_new 3 ,
diff --git a/src/lib/libcrypto/man/X509_INFO_new.3 b/src/lib/libcrypto/man/X509_INFO_new.3
index 545480e050..9c601ccb03 100644
--- a/src/lib/libcrypto/man/X509_INFO_new.3
+++ b/src/lib/libcrypto/man/X509_INFO_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_INFO_new.3,v 1.1 2019/08/19 13:52:53 schwarze Exp $ 1.\" $OpenBSD: X509_INFO_new.3,v 1.2 2020/07/23 17:34:53 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: August 19 2019 $ 16.Dd $Mdocdate: July 23 2020 $
17.Dt X509_INFO_NEW 3 17.Dt X509_INFO_NEW 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -60,6 +60,7 @@ object or
60.Dv NULL 60.Dv NULL
61if an error occurs. 61if an error occurs.
62.Sh SEE ALSO 62.Sh SEE ALSO
63.Xr PEM_X509_INFO_read 3 ,
63.Xr X509_CRL_new 3 , 64.Xr X509_CRL_new 3 ,
64.Xr X509_new 3 65.Xr X509_new 3
65.Sh HISTORY 66.Sh HISTORY