summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/ECDH_compute_key.3
blob: ba67098cd09f9184dfb318ba18d2000270c2efe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.\" $OpenBSD: ECDH_compute_key.3,v 1.2 2021/03/12 05:18:00 jsg Exp $
.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 12 2021 $
.Dt ECDH_COMPUTE_KEY 3
.Os
.Sh NAME
.Nm ECDH_compute_key ,
.Nm ECDH_size
.Nd Elliptic Curve Diffie-Hellman key exchange
.Sh SYNOPSIS
.In openssl/ecdh.h
.Ft int
.Fo ECDH_compute_key
.Fa "void *out"
.Fa "size_t outlen"
.Fa "const EC_POINT *public_key"
.Fa "EC_KEY *ecdh"
.Fa "void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)"
.Fc
.Ft int
.Fo ECDH_size
.Fa "const EC_KEY *ecdh"
.Fc
.Sh DESCRIPTION
.Fn ECDH_compute_key
performs Elliptic Curve Diffie-Hellman key agreement.
It combines the private key contained in
.Fa ecdh
with the other party's
.Fa public_key ,
takes the
.Fa x
component of the affine coordinates,
and optionally applies the key derivation function
.Fa KDF .
It stores the resulting symmetric key in the buffer
.Fa out ,
which is
.Fa outlen
bytes long.
If
.Fa KDF
is
.Dv NULL ,
.Fa outlen
must be at least
.Fn ECDH_size ecdh .
.Pp
.Fn ECDH_size
returns the number of bytes needed to store an affine coordinate of a
point on the elliptic curve used by
.Fa ecdh ,
which is one eighth of the degree of the finite field underlying
that elliptic curve, rounded up to the next integer number.
.Sh RETURN VALUES
.Fn ECDH_compute_key
returns the length of the computed key in bytes or -1 if an error occurs.
.Pp
.Fn ECDH_size
returns the number of bytes needed to store an affine coordinate.
.Sh SEE ALSO
.Xr DH_generate_key 3 ,
.Xr DH_size 3 ,
.Xr EC_GROUP_new 3 ,
.Xr EC_KEY_new 3 ,
.Xr EC_POINT_new 3 ,
.Xr X25519 3
.Sh HISTORY
.Fn ECDH_compute_key
first appeared in OpenSSL 0.9.8 and has been available since
.Ox 4.5 .
.Pp
.Fn ECDH_size
first appeared in
.Ox 6.1 .