diff options
author | schwarze <> | 2023-09-09 14:26:35 +0000 |
---|---|---|
committer | schwarze <> | 2023-09-09 14:26:35 +0000 |
commit | 51b92f8d21cbaaec94c215308fccd3b3741f99fb (patch) | |
tree | 56c4a2145d697840513e98b0cbb30d7d53049f84 /src/lib | |
parent | e972f5da5cac1abe94d601451d52cb4f9e0118bc (diff) | |
download | openbsd-51b92f8d21cbaaec94c215308fccd3b3741f99fb.tar.gz openbsd-51b92f8d21cbaaec94c215308fccd3b3741f99fb.tar.bz2 openbsd-51b92f8d21cbaaec94c215308fccd3b3741f99fb.zip |
Document EVP_PKEY_CTX_get0_peerkey(3).
While here, also make the descriptions of the other functions more precise.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_derive.3 | 116 |
1 files changed, 97 insertions, 19 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_derive.3 b/src/lib/libcrypto/man/EVP_PKEY_derive.3 index 574b6b9b9d..c82018341d 100644 --- a/src/lib/libcrypto/man/EVP_PKEY_derive.3 +++ b/src/lib/libcrypto/man/EVP_PKEY_derive.3 | |||
@@ -1,7 +1,24 @@ | |||
1 | .\" $OpenBSD: EVP_PKEY_derive.3,v 1.8 2018/03/23 04:34:23 schwarze Exp $ | 1 | .\" $OpenBSD: EVP_PKEY_derive.3,v 1.9 2023/09/09 14:26:35 schwarze Exp $ |
2 | .\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 | 2 | .\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 |
3 | .\" | 3 | .\" |
4 | .\" 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) 2023 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 Dr. Stephen Henson <steve@openssl.org>. | ||
5 | .\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project. | 22 | .\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project. |
6 | .\" All rights reserved. | 23 | .\" All rights reserved. |
7 | .\" | 24 | .\" |
@@ -49,12 +66,13 @@ | |||
49 | .\" 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 |
50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 67 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
51 | .\" | 68 | .\" |
52 | .Dd $Mdocdate: March 23 2018 $ | 69 | .Dd $Mdocdate: September 9 2023 $ |
53 | .Dt EVP_PKEY_DERIVE 3 | 70 | .Dt EVP_PKEY_DERIVE 3 |
54 | .Os | 71 | .Os |
55 | .Sh NAME | 72 | .Sh NAME |
56 | .Nm EVP_PKEY_derive_init , | 73 | .Nm EVP_PKEY_derive_init , |
57 | .Nm EVP_PKEY_derive_set_peer , | 74 | .Nm EVP_PKEY_derive_set_peer , |
75 | .Nm EVP_PKEY_CTX_get0_peerkey , | ||
58 | .Nm EVP_PKEY_derive | 76 | .Nm EVP_PKEY_derive |
59 | .Nd derive public key algorithm shared secret | 77 | .Nd derive public key algorithm shared secret |
60 | .Sh SYNOPSIS | 78 | .Sh SYNOPSIS |
@@ -66,7 +84,11 @@ | |||
66 | .Ft int | 84 | .Ft int |
67 | .Fo EVP_PKEY_derive_set_peer | 85 | .Fo EVP_PKEY_derive_set_peer |
68 | .Fa "EVP_PKEY_CTX *ctx" | 86 | .Fa "EVP_PKEY_CTX *ctx" |
69 | .Fa "EVP_PKEY *peer" | 87 | .Fa "EVP_PKEY *peerkey" |
88 | .Fc | ||
89 | .Ft EVP_PKEY * | ||
90 | .Fo EVP_PKEY_CTX_get0_peerkey | ||
91 | .Fa "EVP_PKEY_CTX *ctx" | ||
70 | .Fc | 92 | .Fc |
71 | .Ft int | 93 | .Ft int |
72 | .Fo EVP_PKEY_derive | 94 | .Fo EVP_PKEY_derive |
@@ -75,19 +97,51 @@ | |||
75 | .Fa "size_t *keylen" | 97 | .Fa "size_t *keylen" |
76 | .Fc | 98 | .Fc |
77 | .Sh DESCRIPTION | 99 | .Sh DESCRIPTION |
78 | The | ||
79 | .Fn EVP_PKEY_derive_init | 100 | .Fn EVP_PKEY_derive_init |
80 | function initializes a public key algorithm context using key | 101 | initializes the public key algorithm context |
81 | .Fa ctx->pkey | 102 | .Fa ctx |
82 | for shared secret derivation. | 103 | for shared secret derivation using the |
104 | .Vt EVP_PKEY | ||
105 | object already stored in | ||
106 | .Fa ctx . | ||
107 | The library provides built-in support for keys with an | ||
108 | .Xr EVP_PKEY_base_id 3 | ||
109 | of | ||
110 | .Dv EVP_PKEY_DH , | ||
111 | .Dv EVP_PKEY_EC , | ||
112 | .Dv EVP_PKEY_GOSTR01 , | ||
113 | .Dv EVP_PKEY_HKDF , | ||
114 | and | ||
115 | .Dv EVP_PKEY_X25519 . | ||
116 | .Pp | ||
117 | After the call to | ||
118 | .Fn EVP_PKEY_derive_init , | ||
119 | algorithm specific control operations can optionally be performed | ||
120 | to set any appropriate parameters for the operation. | ||
83 | .Pp | 121 | .Pp |
84 | The | ||
85 | .Fn EVP_PKEY_derive_set_peer | 122 | .Fn EVP_PKEY_derive_set_peer |
86 | function sets the peer key: this will normally be a public key. | 123 | configures the |
124 | .Fa ctx , | ||
125 | which already needs to be initialized with | ||
126 | .Fn EVP_PKEY_derive_init , | ||
127 | .Xr EVP_PKEY_encrypt_init 3 , | ||
128 | or | ||
129 | .Xr EVP_PKEY_decrypt_init 3 , | ||
130 | to use the | ||
131 | .Fa peerkey , | ||
132 | which is normally a public key. | ||
133 | In case of success, the reference count of the | ||
134 | .Fa peerkey | ||
135 | is incremented by one. | ||
136 | Consequently, the caller needs to call | ||
137 | .Xr EVP_PKEY_free 3 | ||
138 | on the | ||
139 | .Fa peerkey | ||
140 | when the caller no longer needs it, even if it is still in use by | ||
141 | .Fa ctx . | ||
87 | .Pp | 142 | .Pp |
88 | The | ||
89 | .Fn EVP_PKEY_derive | 143 | .Fn EVP_PKEY_derive |
90 | function derives a shared secret using | 144 | derives a shared secret using |
91 | .Fa ctx . | 145 | .Fa ctx . |
92 | If | 146 | If |
93 | .Fa key | 147 | .Fa key |
@@ -110,22 +164,45 @@ If the call is successful, the shared secret is written to | |||
110 | and the amount of data written to | 164 | and the amount of data written to |
111 | .Fa keylen . | 165 | .Fa keylen . |
112 | .Pp | 166 | .Pp |
113 | After the call to | ||
114 | .Fn EVP_PKEY_derive_init , | ||
115 | algorithm specific control operations can be performed to set any | ||
116 | appropriate parameters for the operation. | ||
117 | .Pp | ||
118 | The function | 167 | The function |
119 | .Fn EVP_PKEY_derive | 168 | .Fn EVP_PKEY_derive |
120 | can be called more than once on the same context if several operations | 169 | can be called more than once on the same context if several operations |
121 | are performed using the same parameters. | 170 | are performed using the same parameters. |
122 | .Sh RETURN VALUES | 171 | .Sh RETURN VALUES |
123 | .Fn EVP_PKEY_derive_init | 172 | .Fn EVP_PKEY_derive_init , |
173 | .Fn EVP_PKEY_derive_set_peer , | ||
124 | and | 174 | and |
125 | .Fn EVP_PKEY_derive | 175 | .Fn EVP_PKEY_derive |
126 | return 1 for success and 0 or a negative value for failure. | 176 | return 1 for success and 0 or a negative value for failure. |
127 | In particular, a return value of -2 indicates the operation is not | 177 | In particular, a return value of \-2 indicates the operation is not |
128 | supported by the public key algorithm. | 178 | supported by the public key algorithm. |
179 | .Pp | ||
180 | For | ||
181 | .Fn EVP_PKEY_derive_set_peer , | ||
182 | a return value of \-1 can for example occur if | ||
183 | .Fa ctx | ||
184 | is not properly initialized, does not contain an | ||
185 | .Vt EVP_PKEY | ||
186 | that can be retrieved with | ||
187 | .Xr EVP_PKEY_CTX_get0_pkey 3 , | ||
188 | the | ||
189 | .Xr EVP_PKEY_id 3 | ||
190 | of both keys mismatch, or | ||
191 | .Xr EVP_PKEY_cmp_parameters 3 | ||
192 | reports mismatching key parameters. | ||
193 | .Pp | ||
194 | .Fn EVP_PKEY_derive | ||
195 | fails with a return value of \-1 for example if | ||
196 | .Fa ctx | ||
197 | has not been successfully initialized with | ||
198 | .Fn EVP_PKEY_derive_init . | ||
199 | .Pp | ||
200 | .Fn EVP_PKEY_CTX_get0_peerkey | ||
201 | returns an internal pointer to the | ||
202 | .Fa peerkey | ||
203 | used by | ||
204 | .Fa ctx | ||
205 | without incrementing its reference count. | ||
129 | .Sh EXAMPLES | 206 | .Sh EXAMPLES |
130 | Derive shared secret (for example DH or EC keys): | 207 | Derive shared secret (for example DH or EC keys): |
131 | .Bd -literal -offset indent | 208 | .Bd -literal -offset indent |
@@ -173,6 +250,7 @@ if (EVP_PKEY_derive(ctx, skey, &skeylen) <= 0) | |||
173 | .Sh HISTORY | 250 | .Sh HISTORY |
174 | .Fn EVP_PKEY_derive_init , | 251 | .Fn EVP_PKEY_derive_init , |
175 | .Fn EVP_PKEY_derive_set_peer , | 252 | .Fn EVP_PKEY_derive_set_peer , |
253 | .Fn EVP_PKEY_CTX_get0_peerkey , | ||
176 | and | 254 | and |
177 | .Fn EVP_PKEY_derive | 255 | .Fn EVP_PKEY_derive |
178 | first appeared in OpenSSL 1.0.0 and have been available since | 256 | first appeared in OpenSSL 1.0.0 and have been available since |