summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2023-09-09 14:26:35 +0000
committerschwarze <>2023-09-09 14:26:35 +0000
commit51b92f8d21cbaaec94c215308fccd3b3741f99fb (patch)
tree56c4a2145d697840513e98b0cbb30d7d53049f84 /src/lib
parente972f5da5cac1abe94d601451d52cb4f9e0118bc (diff)
downloadopenbsd-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.3116
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
78The
79.Fn EVP_PKEY_derive_init 100.Fn EVP_PKEY_derive_init
80function initializes a public key algorithm context using key 101initializes the public key algorithm context
81.Fa ctx->pkey 102.Fa ctx
82for shared secret derivation. 103for shared secret derivation using the
104.Vt EVP_PKEY
105object already stored in
106.Fa ctx .
107The library provides built-in support for keys with an
108.Xr EVP_PKEY_base_id 3
109of
110.Dv EVP_PKEY_DH ,
111.Dv EVP_PKEY_EC ,
112.Dv EVP_PKEY_GOSTR01 ,
113.Dv EVP_PKEY_HKDF ,
114and
115.Dv EVP_PKEY_X25519 .
116.Pp
117After the call to
118.Fn EVP_PKEY_derive_init ,
119algorithm specific control operations can optionally be performed
120to set any appropriate parameters for the operation.
83.Pp 121.Pp
84The
85.Fn EVP_PKEY_derive_set_peer 122.Fn EVP_PKEY_derive_set_peer
86function sets the peer key: this will normally be a public key. 123configures the
124.Fa ctx ,
125which already needs to be initialized with
126.Fn EVP_PKEY_derive_init ,
127.Xr EVP_PKEY_encrypt_init 3 ,
128or
129.Xr EVP_PKEY_decrypt_init 3 ,
130to use the
131.Fa peerkey ,
132which is normally a public key.
133In case of success, the reference count of the
134.Fa peerkey
135is incremented by one.
136Consequently, the caller needs to call
137.Xr EVP_PKEY_free 3
138on the
139.Fa peerkey
140when the caller no longer needs it, even if it is still in use by
141.Fa ctx .
87.Pp 142.Pp
88The
89.Fn EVP_PKEY_derive 143.Fn EVP_PKEY_derive
90function derives a shared secret using 144derives a shared secret using
91.Fa ctx . 145.Fa ctx .
92If 146If
93.Fa key 147.Fa key
@@ -110,22 +164,45 @@ If the call is successful, the shared secret is written to
110and the amount of data written to 164and the amount of data written to
111.Fa keylen . 165.Fa keylen .
112.Pp 166.Pp
113After the call to
114.Fn EVP_PKEY_derive_init ,
115algorithm specific control operations can be performed to set any
116appropriate parameters for the operation.
117.Pp
118The function 167The function
119.Fn EVP_PKEY_derive 168.Fn EVP_PKEY_derive
120can be called more than once on the same context if several operations 169can be called more than once on the same context if several operations
121are performed using the same parameters. 170are 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 ,
124and 174and
125.Fn EVP_PKEY_derive 175.Fn EVP_PKEY_derive
126return 1 for success and 0 or a negative value for failure. 176return 1 for success and 0 or a negative value for failure.
127In particular, a return value of -2 indicates the operation is not 177In particular, a return value of \-2 indicates the operation is not
128supported by the public key algorithm. 178supported by the public key algorithm.
179.Pp
180For
181.Fn EVP_PKEY_derive_set_peer ,
182a return value of \-1 can for example occur if
183.Fa ctx
184is not properly initialized, does not contain an
185.Vt EVP_PKEY
186that can be retrieved with
187.Xr EVP_PKEY_CTX_get0_pkey 3 ,
188the
189.Xr EVP_PKEY_id 3
190of both keys mismatch, or
191.Xr EVP_PKEY_cmp_parameters 3
192reports mismatching key parameters.
193.Pp
194.Fn EVP_PKEY_derive
195fails with a return value of \-1 for example if
196.Fa ctx
197has not been successfully initialized with
198.Fn EVP_PKEY_derive_init .
199.Pp
200.Fn EVP_PKEY_CTX_get0_peerkey
201returns an internal pointer to the
202.Fa peerkey
203used by
204.Fa ctx
205without incrementing its reference count.
129.Sh EXAMPLES 206.Sh EXAMPLES
130Derive shared secret (for example DH or EC keys): 207Derive 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 ,
176and 254and
177.Fn EVP_PKEY_derive 255.Fn EVP_PKEY_derive
178first appeared in OpenSSL 1.0.0 and have been available since 256first appeared in OpenSSL 1.0.0 and have been available since