Debian Codegraph @

upstream/debian-unstable/man7/EVP_KEYEXCH-ECDH.7ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "EVP_KEYEXCH-ECDH 7SSL"
58 .TH EVP_KEYEXCH-ECDH 7SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 EVP_KEYEXCH\-ECDH \- ECDH Key Exchange algorithm support
65 .SH DESCRIPTION
66 .IX Header "DESCRIPTION"
67 Key exchange support for the \fBECDH\fR key type.
68 .SS "ECDH Key Exchange parameters"
69 .IX Subsection "ECDH Key Exchange parameters"
70 .IP """ecdh-cofactor-mode"" (\fBOSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE\fR) <integer>" 4
71 .IX Item """ecdh-cofactor-mode"" (OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE) <integer>"
72 Sets or gets the ECDH mode of operation for the associated key exchange ctx.
73 .Sp
74 In the context of an Elliptic Curve Diffie-Hellman key exchange, this parameter
75 can be used to select between the plain Diffie-Hellman (DH) or Cofactor
76 Diffie-Hellman (CDH) variants of the key exchange algorithm.
77 .Sp
78 When setting, the value should be 1, 0 or \-1, respectively forcing cofactor mode
79 on, off, or resetting it to the default for the private key associated with the
80 given key exchange ctx.
81 .Sp
82 When getting, the value should be either 1 or 0, respectively signaling if the
83 cofactor mode is on or off.
84 .Sp
85 See also \fBprovider\-keymgmt\fR\|(7) for the related
86 \&\fBOSSL_PKEY_PARAM_USE_COFACTOR_ECDH\fR parameter that can be set on a
87 per-key basis.
88 .IP """kdf-type"" (\fBOSSL_EXCHANGE_PARAM_KDF_TYPE\fR) <UTF8 string>" 4
89 .IX Item """kdf-type"" (OSSL_EXCHANGE_PARAM_KDF_TYPE) <UTF8 string>"
90 .PD 0
91 .IP """kdf-digest"" (\fBOSSL_EXCHANGE_PARAM_KDF_DIGEST\fR) <UTF8 string>" 4
92 .IX Item """kdf-digest"" (OSSL_EXCHANGE_PARAM_KDF_DIGEST) <UTF8 string>"
93 .IP """kdf-digest-props"" (\fBOSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS\fR) <UTF8 string>" 4
94 .IX Item """kdf-digest-props"" (OSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS) <UTF8 string>"
95 .IP """kdf-outlen"" (\fBOSSL_EXCHANGE_PARAM_KDF_OUTLEN\fR) <unsigned integer>" 4
96 .IX Item """kdf-outlen"" (OSSL_EXCHANGE_PARAM_KDF_OUTLEN) <unsigned integer>"
97 .IP """kdf-ukm"" (\fBOSSL_EXCHANGE_PARAM_KDF_UKM\fR) <octet string>" 4
98 .IX Item """kdf-ukm"" (OSSL_EXCHANGE_PARAM_KDF_UKM) <octet string>"
99 .PD
100 .PP
101 The OpenSSL FIPS provider also supports the following parameters:
102 .IP """fips-indicator"" (\fBOSSL_EXCHANGE_PARAM_FIPS_APPROVED_INDICATOR\fR) <integer>" 4
103 .IX Item """fips-indicator"" (OSSL_EXCHANGE_PARAM_FIPS_APPROVED_INDICATOR) <integer>"
104 .PD 0
105 .IP """key-check"" (\fBOSSL_EXCHANGE_PARAM_FIPS_KEY_CHECK\fR) <integer>" 4
106 .IX Item """key-check"" (OSSL_EXCHANGE_PARAM_FIPS_KEY_CHECK) <integer>"
107 .IP """digest-check"" (\fBOSSL_EXCHANGE_PARAM_FIPS_DIGEST_CHECK\fR) <integer>" 4
108 .IX Item """digest-check"" (OSSL_EXCHANGE_PARAM_FIPS_DIGEST_CHECK) <integer>"
109 .PD
110 See "Common Key Exchange parameters" in \fBprovider\-keyexch\fR\|(7).
111 .IP """ecdh-cofactor-check"" (\fBOSSL_EXCHANGE_PARAM_FIPS_ECDH_COFACTOR_CHECK\fR) <integer>" 4
112 .IX Item """ecdh-cofactor-check"" (OSSL_EXCHANGE_PARAM_FIPS_ECDH_COFACTOR_CHECK) <integer>"
113 If required this parameter should before \fBOSSL_FUNC_keyexch_derive()\fR.
114 The default value of 1 causes an error during the OSSL_FUNC_keyexch_derive if
115 the EC curve has a cofactor that is not 1, and the cofactor is not used.
116 Setting this to 0 will ignore the error and set the approved
117 "fips-indicator" to 0.
118 This option breaks FIPS compliance if it causes the approved "fips-indicator"
119 to return 0.
120 .SH EXAMPLES
121 .IX Header "EXAMPLES"
122 Examples of key agreement can be found in demos/keyexch.
123 .PP
124 Keys for the host and peer must be generated as shown in
125 "Examples" in \fBEVP_PKEY\-EC\fR\|(7) using the same curve name.
126 .PP
127 The code to generate a shared secret for the normal case is identical to
128 "Examples" in \fBEVP_KEYEXCH\-DH\fR\|(7).
129 .PP
130 To derive a shared secret on the host using the host's key and the peer's public
131 key but also using X963KDF with a user key material:
132 .PP
133 .Vb 10
134 \& /* It is assumed that the host_key, peer_pub_key and ukm are set up */
135 \& void derive_secret(EVP_PKEY *host_key, EVP_PKEY *peer_key,
136 \& unsigned char *ukm, size_t ukm_len)
137 \& {
138 \& unsigned char secret[64];
139 \& size_t out_len = sizeof(secret);
140 \& size_t secret_len = out_len;
141 \& unsigned int pad = 1;
142 \& OSSL_PARAM params[6];
143 \& EVP_PKEY_CTX *dctx = EVP_PKEY_CTX_new_from_pkey(NULL, host_key, NULL);
144 \&
145 \& EVP_PKEY_derive_init(dctx);
146 \&
147 \& params[0] = OSSL_PARAM_construct_uint(OSSL_EXCHANGE_PARAM_PAD, &pad);
148 \& params[1] = OSSL_PARAM_construct_utf8_string(OSSL_EXCHANGE_PARAM_KDF_TYPE,
149 \& "X963KDF", 0);
150 \& params[2] = OSSL_PARAM_construct_utf8_string(OSSL_EXCHANGE_PARAM_KDF_DIGEST,
151 \& "SHA1", 0);
152 \& params[3] = OSSL_PARAM_construct_size_t(OSSL_EXCHANGE_PARAM_KDF_OUTLEN,
153 \& &out_len);
154 \& params[4] = OSSL_PARAM_construct_octet_string(OSSL_EXCHANGE_PARAM_KDF_UKM,
155 \& ukm, ukm_len);
156 \& params[5] = OSSL_PARAM_construct_end();
157 \& EVP_PKEY_CTX_set_params(dctx, params);
158 \&
159 \& EVP_PKEY_derive_set_peer(dctx, peer_pub_key);
160 \& EVP_PKEY_derive(dctx, secret, &secret_len);
161 \& ...
162 \& OPENSSL_clear_free(secret, secret_len);
163 \& EVP_PKEY_CTX_free(dctx);
164 \& }
165 .Ve
166 .SH "SEE ALSO"
167 .IX Header "SEE ALSO"
168 \&\fBEVP_PKEY\-EC\fR\|(7)
169 \&\fBEVP_PKEY\fR\|(3),
170 \&\fBprovider\-keyexch\fR\|(7),
171 \&\fBprovider\-keymgmt\fR\|(7),
172 \&\fBOSSL_PROVIDER\-default\fR\|(7),
173 \&\fBOSSL_PROVIDER\-FIPS\fR\|(7),
174 .SH COPYRIGHT
175 .IX Header "COPYRIGHT"
176 Copyright 2020\-2024 The OpenSSL Project Authors. All Rights Reserved.
177 .PP
178 Licensed under the Apache License 2.0 (the "License"). You may not use
179 this file except in compliance with the License. You can obtain a copy
180 in the file LICENSE in the source distribution or at
181 <https://www.openssl.org/source/license.html>.