diff options
author | schwarze <> | 2020-05-24 12:37:30 +0000 |
---|---|---|
committer | schwarze <> | 2020-05-24 12:37:30 +0000 |
commit | 3897abf3f7fbae4cfd94912a4a3ccdcbbfe8470a (patch) | |
tree | 8698d6c7b03954fcc8dd1a11b74381f4e02b8d67 | |
parent | 8f3ed8b4747c31e8aafe844575024d46e2d682fa (diff) | |
download | openbsd-3897abf3f7fbae4cfd94912a4a3ccdcbbfe8470a.tar.gz openbsd-3897abf3f7fbae4cfd94912a4a3ccdcbbfe8470a.tar.bz2 openbsd-3897abf3f7fbae4cfd94912a4a3ccdcbbfe8470a.zip |
Minimally document PKCS7_dataInit(3).
No comment when shown around among LibreSSL devs
except "very very strange function" from beck@
and "cannot say much about it" from tb@.
If needed, this can be further polished in the tree,
review is still welcome.
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/man/PKCS7_dataInit.3 | 207 | ||||
-rw-r--r-- | src/lib/libcrypto/man/PKCS7_new.3 | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/man/PKCS7_set_content.3 | 5 |
4 files changed, 215 insertions, 5 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 1394012e9c..5468ba9869 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.162 2020/05/20 11:40:26 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.163 2020/05/24 12:37:30 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> |
4 | 4 | ||
@@ -214,6 +214,7 @@ MAN= \ | |||
214 | PKCS12_parse.3 \ | 214 | PKCS12_parse.3 \ |
215 | PKCS12_SAFEBAG_new.3 \ | 215 | PKCS12_SAFEBAG_new.3 \ |
216 | PKCS5_PBKDF2_HMAC.3 \ | 216 | PKCS5_PBKDF2_HMAC.3 \ |
217 | PKCS7_dataInit.3 \ | ||
217 | PKCS7_decrypt.3 \ | 218 | PKCS7_decrypt.3 \ |
218 | PKCS7_encrypt.3 \ | 219 | PKCS7_encrypt.3 \ |
219 | PKCS7_new.3 \ | 220 | PKCS7_new.3 \ |
diff --git a/src/lib/libcrypto/man/PKCS7_dataInit.3 b/src/lib/libcrypto/man/PKCS7_dataInit.3 new file mode 100644 index 0000000000..53090ff960 --- /dev/null +++ b/src/lib/libcrypto/man/PKCS7_dataInit.3 | |||
@@ -0,0 +1,207 @@ | |||
1 | .\" $OpenBSD: PKCS7_dataInit.3,v 1.1 2020/05/24 12:37:30 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: May 24 2020 $ | ||
18 | .Dt PKCS7_DATAINIT 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm PKCS7_dataInit | ||
22 | .Nd construct a BIO chain for adding or retrieving content | ||
23 | .Sh SYNOPSIS | ||
24 | .In openssl/pkcs7.h | ||
25 | .Ft BIO * | ||
26 | .Fo PKCS7_dataInit | ||
27 | .Fa "PKCS7 *p7" | ||
28 | .Fa "BIO *indata" | ||
29 | .Fc | ||
30 | .Sh DESCRIPTION | ||
31 | .Fn PKCS7_dataInit | ||
32 | constructs a BIO chain in preparation for putting data into | ||
33 | or retrieving data out of | ||
34 | .Fa p7 . | ||
35 | Depending on the | ||
36 | .Fa contentType | ||
37 | of | ||
38 | .Fa p7 , | ||
39 | the created chain starts with: | ||
40 | .Bl -tag -width Ds | ||
41 | .It for Vt SignedData : | ||
42 | one or more | ||
43 | .Xr BIO_f_md 3 | ||
44 | message digest filters | ||
45 | .It for Vt EnvelopedData : | ||
46 | one | ||
47 | .Xr BIO_f_cipher 3 | ||
48 | encryption filter | ||
49 | .It for Vt SignedAndEnvelopedData : | ||
50 | one or more | ||
51 | .Xr BIO_f_md 3 | ||
52 | message digest filters followed by one | ||
53 | .Xr BIO_f_cipher 3 | ||
54 | encryption filter | ||
55 | .It for Vt DigestedData : | ||
56 | one | ||
57 | .Xr BIO_f_md 3 | ||
58 | message digest filter | ||
59 | .It for arbitrary data : | ||
60 | no filter BIO | ||
61 | .El | ||
62 | .Pp | ||
63 | One additional BIO is appended to the end of the chain, | ||
64 | depending on the first condition that holds in the following list: | ||
65 | .Bl -tag -width Ds | ||
66 | .It Fa indata | ||
67 | if the | ||
68 | .Fa indata | ||
69 | argument is not | ||
70 | .Dv NULL . | ||
71 | This only makes sense while verifying a detached signature, in which case | ||
72 | .Fa indata | ||
73 | is expected to supply the content associated with the detached signature. | ||
74 | .It Xr BIO_s_null 3 | ||
75 | if the | ||
76 | .Fa contentType | ||
77 | of | ||
78 | .Fa p7 | ||
79 | is | ||
80 | .Vt SignedData | ||
81 | and it is configured to contain a detached signature. | ||
82 | This only makes sense while creating the detached signature. | ||
83 | .It Xr BIO_new_mem_buf 3 | ||
84 | when reading from a | ||
85 | .Vt SignedData | ||
86 | or | ||
87 | .Vt DigestedData | ||
88 | object. | ||
89 | .Fn PKCS7_dataInit | ||
90 | attaches the end of the chain to the nested content of | ||
91 | .Fa p7 . | ||
92 | .It Xr BIO_s_mem 3 | ||
93 | otherwise. | ||
94 | This is the most common case while writing data to | ||
95 | .Fa p7 . | ||
96 | .Xr PKCS7_dataFinal 3 | ||
97 | can later be used to transfer the data from the memory BIO into | ||
98 | .Fa p7 . | ||
99 | .El | ||
100 | .Ss Adding content | ||
101 | Before calling | ||
102 | .Fn PKCS7_dataInit | ||
103 | in order to add content, | ||
104 | .Xr PKCS7_new 3 , | ||
105 | .Xr PKCS7_set_type 3 , | ||
106 | and | ||
107 | .Xr PKCS7_content_new 3 | ||
108 | are typically required to create | ||
109 | .Fa p7 , | ||
110 | to choose its desired type, and to allocate the nested | ||
111 | .Vt ContentInfo | ||
112 | structure. | ||
113 | .Pp | ||
114 | After calling | ||
115 | .Fn PKCS7_dataInit , | ||
116 | the desired data can be written into the returned | ||
117 | .Vt BIO , | ||
118 | .Xr BIO_flush 3 | ||
119 | can be called on it, | ||
120 | .Xr PKCS7_dataFinal 3 | ||
121 | can be used to transfer the processed data | ||
122 | from the returned memory BIO to the | ||
123 | .Fa p7 | ||
124 | structure, and the chain can finally be destroyed with | ||
125 | .Xr BIO_free_all 3 . | ||
126 | .Pp | ||
127 | While | ||
128 | .Fn PKCS7_dataInit | ||
129 | does support the | ||
130 | .Vt EnvelopedData | ||
131 | and | ||
132 | .Vt SignedAndEnvelopedData | ||
133 | types, using it for these types is awkward and error prone because | ||
134 | .Xr PKCS7_content_new 3 | ||
135 | does not support these two types. | ||
136 | So in addition to creating | ||
137 | .Fa p7 | ||
138 | itself and setting its type, the nested | ||
139 | .Fa ContentInfo | ||
140 | structure also needs to be constructed with | ||
141 | .Xr PKCS7_new 3 | ||
142 | and | ||
143 | .Xr PKCS7_set_type 3 | ||
144 | and manually inserted into the correct field | ||
145 | of the respective sub-structure of | ||
146 | .Fa p7 . | ||
147 | .Ss Retrieving content | ||
148 | .Fn PKCS7_dataInit | ||
149 | can also be called on a fully populated object of type | ||
150 | .Vt SignedData | ||
151 | or | ||
152 | .Vt DigestedData . | ||
153 | After that, | ||
154 | .Xr BIO_read 3 | ||
155 | can be used to retrieve data from it. | ||
156 | In this use case, do not call | ||
157 | .Xr PKCS7_dataFinal 3 ; | ||
158 | simply proceed directly to | ||
159 | .Xr BIO_free_all 3 | ||
160 | after reading the data. | ||
161 | .Sh RETURN VALUES | ||
162 | .Fn PKCS7_dataInit | ||
163 | returns a BIO chain on success or | ||
164 | .Dv NULL | ||
165 | on failure. | ||
166 | It fails if | ||
167 | .Fa p7 | ||
168 | is | ||
169 | .Dv NULL , | ||
170 | if the | ||
171 | .Fa content | ||
172 | field of | ||
173 | .Fa p7 | ||
174 | is empty, if the | ||
175 | .Fa contentType | ||
176 | of | ||
177 | .Fa p7 | ||
178 | is unsupported, if a cipher is required but none is configured, or | ||
179 | if any required operation fails, for example due to lack of memory | ||
180 | or for various other reasons. | ||
181 | .Sh SEE ALSO | ||
182 | .Xr BIO_new 3 , | ||
183 | .Xr BIO_read 3 , | ||
184 | .Xr PKCS7_content_new 3 , | ||
185 | .Xr PKCS7_dataFinal 3 , | ||
186 | .Xr PKCS7_new 3 , | ||
187 | .Xr PKCS7_set_type 3 , | ||
188 | .Xr PKCS7_sign 3 | ||
189 | .Sh HISTORY | ||
190 | .Fn PKCS7_dataInit | ||
191 | first appeared in SSLeay 0.8.1 and has been available since | ||
192 | .Ox 2.4 . | ||
193 | .Sh CAVEATS | ||
194 | This function does not support | ||
195 | .Vt EncryptedData . | ||
196 | .Sh BUGS | ||
197 | If | ||
198 | .Fa p7 | ||
199 | is a fully populated structure containing | ||
200 | .Vt EnvelopedData , | ||
201 | .Vt SignedAndEnvelopedData , | ||
202 | or arbitrary data, | ||
203 | .Fn PKCS7_dataInit | ||
204 | returns a BIO chain that ultimately reads from an empty memory BIO, | ||
205 | so reading from it will instantly return an end-of-file indication | ||
206 | rather than reading the actual data contained in | ||
207 | .Fa p7 . | ||
diff --git a/src/lib/libcrypto/man/PKCS7_new.3 b/src/lib/libcrypto/man/PKCS7_new.3 index 56a8b566ba..c0943e021a 100644 --- a/src/lib/libcrypto/man/PKCS7_new.3 +++ b/src/lib/libcrypto/man/PKCS7_new.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: PKCS7_new.3,v 1.8 2020/05/20 11:40:26 schwarze Exp $ | 1 | .\" $OpenBSD: PKCS7_new.3,v 1.9 2020/05/24 12:37:30 schwarze Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2016 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: May 20 2020 $ | 17 | .Dd $Mdocdate: May 24 2020 $ |
18 | .Dt PKCS7_NEW 3 | 18 | .Dt PKCS7_NEW 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
@@ -246,6 +246,7 @@ frees | |||
246 | .Xr i2d_PKCS7_bio_stream 3 , | 246 | .Xr i2d_PKCS7_bio_stream 3 , |
247 | .Xr PEM_read_PKCS7 3 , | 247 | .Xr PEM_read_PKCS7 3 , |
248 | .Xr PEM_write_bio_PKCS7_stream 3 , | 248 | .Xr PEM_write_bio_PKCS7_stream 3 , |
249 | .Xr PKCS7_dataInit 3 , | ||
249 | .Xr PKCS7_decrypt 3 , | 250 | .Xr PKCS7_decrypt 3 , |
250 | .Xr PKCS7_encrypt 3 , | 251 | .Xr PKCS7_encrypt 3 , |
251 | .Xr PKCS7_ISSUER_AND_SERIAL_digest 3 , | 252 | .Xr PKCS7_ISSUER_AND_SERIAL_digest 3 , |
diff --git a/src/lib/libcrypto/man/PKCS7_set_content.3 b/src/lib/libcrypto/man/PKCS7_set_content.3 index 1f77a8042b..fa057341d5 100644 --- a/src/lib/libcrypto/man/PKCS7_set_content.3 +++ b/src/lib/libcrypto/man/PKCS7_set_content.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: PKCS7_set_content.3,v 1.1 2020/05/20 11:40:26 schwarze Exp $ | 1 | .\" $OpenBSD: PKCS7_set_content.3,v 1.2 2020/05/24 12:37:30 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: May 20 2020 $ | 17 | .Dd $Mdocdate: May 24 2020 $ |
18 | .Dt PKCS7_SET_CONTENT 3 | 18 | .Dt PKCS7_SET_CONTENT 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
@@ -89,6 +89,7 @@ In case of failure, | |||
89 | .Fa outer | 89 | .Fa outer |
90 | remains unchanged. | 90 | remains unchanged. |
91 | .Sh SEE ALSO | 91 | .Sh SEE ALSO |
92 | .Xr PKCS7_dataInit 3 , | ||
92 | .Xr PKCS7_new 3 , | 93 | .Xr PKCS7_new 3 , |
93 | .Xr PKCS7_set_type 3 , | 94 | .Xr PKCS7_set_type 3 , |
94 | .Xr PKCS7_sign 3 | 95 | .Xr PKCS7_sign 3 |