diff options
author | schwarze <> | 2019-09-01 09:10:09 +0000 |
---|---|---|
committer | schwarze <> | 2019-09-01 09:10:09 +0000 |
commit | ff57b9764545ea9d58b1f7eb642e5974b8728f92 (patch) | |
tree | 1d01aeb2131cedfb82de5490ddfdb9aca79e174b /src/lib/libcrypto | |
parent | b26264425b0ecfdcb8abaa73f71a63d26d930b0f (diff) | |
download | openbsd-ff57b9764545ea9d58b1f7eb642e5974b8728f92.tar.gz openbsd-ff57b9764545ea9d58b1f7eb642e5974b8728f92.tar.bz2 openbsd-ff57b9764545ea9d58b1f7eb642e5974b8728f92.zip |
Document EVP_PKEY_get0(3), EVP_PKEY_assign_GOST(3), EVP_PKEY_assign(3),
and EVP_PKEY_set_type(3). While here, clarify a few points regarding
reference count and type checking.
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_asn1_new.3 | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 | 139 |
2 files changed, 116 insertions, 31 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_asn1_new.3 b/src/lib/libcrypto/man/EVP_PKEY_asn1_new.3 index 5cb53772b6..5d915d0183 100644 --- a/src/lib/libcrypto/man/EVP_PKEY_asn1_new.3 +++ b/src/lib/libcrypto/man/EVP_PKEY_asn1_new.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $ | 1 | .\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.5 2019/09/01 09:10:09 schwarze Exp $ |
2 | .\" selective merge up to: | 2 | .\" selective merge up to: |
3 | .\" OpenSSL man3/EVP_PKEY_ASN1_METHOD b0004708 Nov 1 00:45:24 2017 +0800 | 3 | .\" OpenSSL man3/EVP_PKEY_ASN1_METHOD b0004708 Nov 1 00:45:24 2017 +0800 |
4 | .\" | 4 | .\" |
@@ -49,7 +49,7 @@ | |||
49 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 49 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
51 | .\" | 51 | .\" |
52 | .Dd $Mdocdate: June 6 2019 $ | 52 | .Dd $Mdocdate: September 1 2019 $ |
53 | .Dt EVP_PKEY_ASN1_METHOD 3 | 53 | .Dt EVP_PKEY_ASN1_METHOD 3 |
54 | .Os | 54 | .Os |
55 | .Sh NAME | 55 | .Sh NAME |
@@ -344,10 +344,10 @@ method helps freeing the internals of | |||
344 | .Fa pkey . | 344 | .Fa pkey . |
345 | It is called by | 345 | It is called by |
346 | .Xr EVP_PKEY_free 3 , | 346 | .Xr EVP_PKEY_free 3 , |
347 | .Fn EVP_PKEY_set_type , | 347 | .Xr EVP_PKEY_set_type 3 , |
348 | .Fn EVP_PKEY_set_type_str , | 348 | .Fn EVP_PKEY_set_type_str , |
349 | and | 349 | and |
350 | .Fn EVP_PKEY_assign . | 350 | .Xr EVP_PKEY_assign 3 . |
351 | .Bd -unfilled | 351 | .Bd -unfilled |
352 | .Ft int Fo (*pkey_ctrl) | 352 | .Ft int Fo (*pkey_ctrl) |
353 | .Fa "EVP_PKEY *pkey" | 353 | .Fa "EVP_PKEY *pkey" |
diff --git a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 b/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 index 948bec4fb3..9851538c41 100644 --- a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 +++ b/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 | |||
@@ -1,8 +1,24 @@ | |||
1 | .\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.15 2019/03/18 04:01:53 schwarze Exp $ | 1 | .\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.16 2019/09/01 09:10:09 schwarze Exp $ |
2 | .\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 | 2 | .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 |
3 | .\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 | ||
4 | .\" | 3 | .\" |
5 | .\" This file was written by Dr. Stephen Henson <steve@openssl.org>. | 4 | .\" This file is a derived work. |
5 | .\" The changes are covered by the following Copyright and license: | ||
6 | .\" | ||
7 | .\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> | ||
8 | .\" | ||
9 | .\" Permission to use, copy, modify, and distribute this software for any | ||
10 | .\" purpose with or without fee is hereby granted, provided that the above | ||
11 | .\" copyright notice and this permission notice appear in all copies. | ||
12 | .\" | ||
13 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
15 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
16 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
17 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
18 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
19 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
20 | .\" | ||
21 | .\" The original file was written by by Dr. Stephen Henson <steve@openssl.org>. | ||
6 | .\" Copyright (c) 2002, 2015, 2016 The OpenSSL Project. All rights reserved. | 22 | .\" Copyright (c) 2002, 2015, 2016 The OpenSSL Project. All rights reserved. |
7 | .\" | 23 | .\" |
8 | .\" Redistribution and use in source and binary forms, with or without | 24 | .\" Redistribution and use in source and binary forms, with or without |
@@ -49,7 +65,7 @@ | |||
49 | .\" 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 |
50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 66 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
51 | .\" | 67 | .\" |
52 | .Dd $Mdocdate: March 18 2019 $ | 68 | .Dd $Mdocdate: September 1 2019 $ |
53 | .Dt EVP_PKEY_SET1_RSA 3 | 69 | .Dt EVP_PKEY_SET1_RSA 3 |
54 | .Os | 70 | .Os |
55 | .Sh NAME | 71 | .Sh NAME |
@@ -66,10 +82,14 @@ | |||
66 | .Nm EVP_PKEY_get0_DH , | 82 | .Nm EVP_PKEY_get0_DH , |
67 | .Nm EVP_PKEY_get0_EC_KEY , | 83 | .Nm EVP_PKEY_get0_EC_KEY , |
68 | .Nm EVP_PKEY_get0_hmac , | 84 | .Nm EVP_PKEY_get0_hmac , |
85 | .Nm EVP_PKEY_get0 , | ||
69 | .Nm EVP_PKEY_assign_RSA , | 86 | .Nm EVP_PKEY_assign_RSA , |
70 | .Nm EVP_PKEY_assign_DSA , | 87 | .Nm EVP_PKEY_assign_DSA , |
71 | .Nm EVP_PKEY_assign_DH , | 88 | .Nm EVP_PKEY_assign_DH , |
72 | .Nm EVP_PKEY_assign_EC_KEY , | 89 | .Nm EVP_PKEY_assign_EC_KEY , |
90 | .Nm EVP_PKEY_assign_GOST , | ||
91 | .Nm EVP_PKEY_assign , | ||
92 | .Nm EVP_PKEY_set_type , | ||
73 | .Nm EVP_PKEY_base_id , | 93 | .Nm EVP_PKEY_base_id , |
74 | .Nm EVP_PKEY_id , | 94 | .Nm EVP_PKEY_id , |
75 | .Nm EVP_PKEY_type | 95 | .Nm EVP_PKEY_type |
@@ -133,6 +153,10 @@ | |||
133 | .Fa "const EVP_PKEY *pkey" | 153 | .Fa "const EVP_PKEY *pkey" |
134 | .Fa "size_t *len" | 154 | .Fa "size_t *len" |
135 | .Fc | 155 | .Fc |
156 | .Ft void * | ||
157 | .Fo EVP_PKEY_get0 | ||
158 | .Fa "const EVP_PKEY *pkey" | ||
159 | .Fc | ||
136 | .Ft int | 160 | .Ft int |
137 | .Fo EVP_PKEY_assign_RSA | 161 | .Fo EVP_PKEY_assign_RSA |
138 | .Fa "EVP_PKEY *pkey" | 162 | .Fa "EVP_PKEY *pkey" |
@@ -154,6 +178,22 @@ | |||
154 | .Fa "EC_KEY *key" | 178 | .Fa "EC_KEY *key" |
155 | .Fc | 179 | .Fc |
156 | .Ft int | 180 | .Ft int |
181 | .Fo EVP_PKEY_assign_GOST | ||
182 | .Fa "EVP_PKEY *pkey" | ||
183 | .Fa "GOST_KEY *key" | ||
184 | .Fc | ||
185 | .Ft int | ||
186 | .Fo EVP_PKEY_assign | ||
187 | .Fa "EVP_PKEY *pkey" | ||
188 | .Fa "int type" | ||
189 | .Fa "void *key" | ||
190 | .Fc | ||
191 | .Ft int | ||
192 | .Fo EVP_PKEY_set_type | ||
193 | .Fa "EVP_PKEY *pkey" | ||
194 | .Fa "int type" | ||
195 | .Fc | ||
196 | .Ft int | ||
157 | .Fo EVP_PKEY_base_id | 197 | .Fo EVP_PKEY_base_id |
158 | .Fa "EVP_PKEY *pkey" | 198 | .Fa "EVP_PKEY *pkey" |
159 | .Fc | 199 | .Fc |
@@ -174,7 +214,10 @@ and | |||
174 | set the key referenced by | 214 | set the key referenced by |
175 | .Fa pkey | 215 | .Fa pkey |
176 | to | 216 | to |
177 | .Fa key . | 217 | .Fa key |
218 | and increment the reference count of | ||
219 | .Fa key | ||
220 | by 1 in case of success. | ||
178 | .Pp | 221 | .Pp |
179 | .Fn EVP_PKEY_get1_RSA , | 222 | .Fn EVP_PKEY_get1_RSA , |
180 | .Fn EVP_PKEY_get1_DSA , | 223 | .Fn EVP_PKEY_get1_DSA , |
@@ -190,8 +233,9 @@ if the key is not of the correct type. | |||
190 | .Fn EVP_PKEY_get0_RSA , | 233 | .Fn EVP_PKEY_get0_RSA , |
191 | .Fn EVP_PKEY_get0_DSA , | 234 | .Fn EVP_PKEY_get0_DSA , |
192 | .Fn EVP_PKEY_get0_DH , | 235 | .Fn EVP_PKEY_get0_DH , |
236 | .Fn EVP_PKEY_get0_EC_KEY , | ||
193 | and | 237 | and |
194 | .Fn EVP_PKEY_get0_EC_KEY | 238 | .Fn EVP_PKEY_get0 |
195 | are identical except that they do not increment the reference count. | 239 | are identical except that they do not increment the reference count. |
196 | Consequently, the returned key must not be freed by the caller. | 240 | Consequently, the returned key must not be freed by the caller. |
197 | .Pp | 241 | .Pp |
@@ -213,17 +257,45 @@ becomes unspecified. | |||
213 | .Fn EVP_PKEY_assign_RSA , | 257 | .Fn EVP_PKEY_assign_RSA , |
214 | .Fn EVP_PKEY_assign_DSA , | 258 | .Fn EVP_PKEY_assign_DSA , |
215 | .Fn EVP_PKEY_assign_DH , | 259 | .Fn EVP_PKEY_assign_DH , |
260 | .Fn EVP_PKEY_assign_EC_KEY , | ||
261 | .Fn EVP_PKEY_assign_GOST , | ||
216 | and | 262 | and |
217 | .Fn EVP_PKEY_assign_EC_KEY | 263 | .Fn EVP_PKEY_assign |
218 | also set the referenced key to | 264 | also set the referenced key to |
219 | .Fa key ; | 265 | .Fa key ; |
220 | however these use the supplied | 266 | however these use the supplied |
221 | .Fa key | 267 | .Fa key |
222 | internally and so | 268 | internally without incrementing its reference count, such that |
223 | .Fa key | 269 | .Fa key |
224 | will be freed when the parent | 270 | will be freed when the parent |
225 | .Fa pkey | 271 | .Fa pkey |
226 | is freed. | 272 | is freed. |
273 | If the | ||
274 | .Fa key | ||
275 | is of the wrong type, these functions report success even though | ||
276 | .Fa pkey | ||
277 | ends up in a corrupted state. | ||
278 | Even the functions explicitly containing the type in their name are | ||
279 | .Em not | ||
280 | type safe because they are implemented as macros. | ||
281 | The following types are supported: | ||
282 | .Dv EVP_PKEY_RSA , | ||
283 | .Dv EVP_PKEY_DSA , | ||
284 | .Dv EVP_PKEY_DH , | ||
285 | .Dv EVP_PKEY_EC , | ||
286 | and | ||
287 | .Dv EVP_PKEY_GOSTR01 . | ||
288 | .Pp | ||
289 | .Fn EVP_PKEY_set_type | ||
290 | frees the key referenced in | ||
291 | .Fa pkey , | ||
292 | if any, and sets the key type of | ||
293 | .Fa pkey | ||
294 | to | ||
295 | .Fa type | ||
296 | without referencing a new key from | ||
297 | .Fa pkey | ||
298 | yet. | ||
227 | .Pp | 299 | .Pp |
228 | .Fn EVP_PKEY_base_id | 300 | .Fn EVP_PKEY_base_id |
229 | returns the type of | 301 | returns the type of |
@@ -267,19 +339,19 @@ using the | |||
267 | .Sy 1 | 339 | .Sy 1 |
268 | functions must be freed as well as | 340 | functions must be freed as well as |
269 | .Fa pkey . | 341 | .Fa pkey . |
270 | .Pp | ||
271 | .Fn EVP_PKEY_assign_RSA , | ||
272 | .Fn EVP_PKEY_assign_DSA , | ||
273 | .Fn EVP_PKEY_assign_DH , | ||
274 | and | ||
275 | .Fn EVP_PKEY_assign_EC_KEY | ||
276 | are implemented as macros. | ||
277 | .Sh RETURN VALUES | 342 | .Sh RETURN VALUES |
278 | .Fn EVP_PKEY_set1_RSA , | 343 | .Fn EVP_PKEY_set1_RSA , |
279 | .Fn EVP_PKEY_set1_DSA , | 344 | .Fn EVP_PKEY_set1_DSA , |
280 | .Fn EVP_PKEY_set1_DH , | 345 | .Fn EVP_PKEY_set1_DH , |
346 | .Fn EVP_PKEY_set1_EC_KEY , | ||
347 | .Fn EVP_PKEY_assign_RSA , | ||
348 | .Fn EVP_PKEY_assign_DSA , | ||
349 | .Fn EVP_PKEY_assign_DH , | ||
350 | .Fn EVP_PKEY_assign_EC_KEY , | ||
351 | .Fn EVP_PKEY_assign_GOST , | ||
352 | .Fn EVP_PKEY_assign , | ||
281 | and | 353 | and |
282 | .Fn EVP_PKEY_set1_EC_KEY | 354 | .Fn EVP_PKEY_set_type |
283 | return 1 for success or 0 for failure. | 355 | return 1 for success or 0 for failure. |
284 | .Pp | 356 | .Pp |
285 | .Fn EVP_PKEY_get1_RSA , | 357 | .Fn EVP_PKEY_get1_RSA , |
@@ -290,18 +362,24 @@ return 1 for success or 0 for failure. | |||
290 | .Fn EVP_PKEY_get0_DSA , | 362 | .Fn EVP_PKEY_get0_DSA , |
291 | .Fn EVP_PKEY_get0_DH , | 363 | .Fn EVP_PKEY_get0_DH , |
292 | .Fn EVP_PKEY_get0_EC_KEY , | 364 | .Fn EVP_PKEY_get0_EC_KEY , |
365 | .Fn EVP_PKEY_get0_hmac , | ||
293 | and | 366 | and |
294 | .Fn EVP_PKEY_get0_hmac | 367 | .Fn EVP_PKEY_get0 |
295 | return the referenced key or | 368 | return the referenced key or |
296 | .Dv NULL | 369 | .Dv NULL |
297 | if an error occurred. | 370 | if an error occurred. |
298 | .Pp | 371 | For |
299 | .Fn EVP_PKEY_assign_RSA , | 372 | .Fn EVP_PKEY_get0 , |
300 | .Fn EVP_PKEY_assign_DSA , | 373 | the return value points to an |
301 | .Fn EVP_PKEY_assign_DH , | 374 | .Vt RSA , |
302 | and | 375 | .Vt DSA , |
303 | .Fn EVP_PKEY_assign_EC_KEY | 376 | .Vt DH , |
304 | return 1 for success and 0 for failure. | 377 | .Vt EC_KEY , |
378 | .Vt GOST_KEY , | ||
379 | or | ||
380 | .Vt ASN1_OCTET_STRING | ||
381 | object depending on the type of | ||
382 | .Fa pkey . | ||
305 | .Pp | 383 | .Pp |
306 | .Fn EVP_PKEY_base_id , | 384 | .Fn EVP_PKEY_base_id , |
307 | .Fn EVP_PKEY_id , | 385 | .Fn EVP_PKEY_id , |
@@ -323,6 +401,7 @@ on error. | |||
323 | .Fn EVP_PKEY_assign_RSA , | 401 | .Fn EVP_PKEY_assign_RSA , |
324 | .Fn EVP_PKEY_assign_DSA , | 402 | .Fn EVP_PKEY_assign_DSA , |
325 | .Fn EVP_PKEY_assign_DH , | 403 | .Fn EVP_PKEY_assign_DH , |
404 | .Fn EVP_PKEY_assign , | ||
326 | and | 405 | and |
327 | .Fn EVP_PKEY_type | 406 | .Fn EVP_PKEY_type |
328 | first appeared in SSLeay 0.8.0 and have been available since | 407 | first appeared in SSLeay 0.8.0 and have been available since |
@@ -345,12 +424,18 @@ and | |||
345 | first appeared in OpenSSL 0.9.8 and have been available since | 424 | first appeared in OpenSSL 0.9.8 and have been available since |
346 | .Ox 4.5 . | 425 | .Ox 4.5 . |
347 | .Pp | 426 | .Pp |
348 | .Fn EVP_PKEY_id | 427 | .Fn EVP_PKEY_get0 , |
428 | .Fn EVP_PKEY_set_type , | ||
429 | .Fn EVP_PKEY_base_id , | ||
349 | and | 430 | and |
350 | .Fn EVP_PKEY_base_id | 431 | .Fn EVP_PKEY_id |
351 | first appeared in OpenSSL 1.0.0 and have been available since | 432 | first appeared in OpenSSL 1.0.0 and have been available since |
352 | .Ox 4.9 . | 433 | .Ox 4.9 . |
353 | .Pp | 434 | .Pp |
435 | .Fn EVP_PKEY_assign_GOST | ||
436 | first appeared in | ||
437 | .Ox 5.7 . | ||
438 | .Pp | ||
354 | .Fn EVP_PKEY_get0_RSA , | 439 | .Fn EVP_PKEY_get0_RSA , |
355 | .Fn EVP_PKEY_get0_DSA , | 440 | .Fn EVP_PKEY_get0_DSA , |
356 | .Fn EVP_PKEY_get0_DH , | 441 | .Fn EVP_PKEY_get0_DH , |