Debian Codegraph @

upstream/debian-unstable/man7/EVP_KDF-SSHKDF.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_KDF-SSHKDF 7SSL"
58 .TH EVP_KDF-SSHKDF 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_KDF\-SSHKDF \- The SSHKDF EVP_KDF implementation
65 .SH DESCRIPTION
66 .IX Header "DESCRIPTION"
67 Support for computing the \fBSSHKDF\fR KDF through the \fBEVP_KDF\fR API.
68 .PP
69 The EVP_KDF\-SSHKDF algorithm implements the SSHKDF key derivation function.
70 It is defined in RFC 4253, section 7.2 and is used by SSH to derive IVs,
71 encryption keys and integrity keys.
72 Five inputs are required to perform key derivation: The hashing function
73 (for example SHA256), the Initial Key, the Exchange Hash, the Session ID,
74 and the derivation key type.
75 .PP
76 The output is considered to be keying material.
77 .SS Identity
78 .IX Subsection "Identity"
79 "SSHKDF" is the name for this implementation; it
80 can be used with the \fBEVP_KDF_fetch()\fR function.
81 .SS "Supported parameters"
82 .IX Subsection "Supported parameters"
83 The supported parameters are:
84 .IP """properties"" (\fBOSSL_KDF_PARAM_PROPERTIES\fR) <UTF8 string>" 4
85 .IX Item """properties"" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"
86 .PD 0
87 .IP """digest"" (\fBOSSL_KDF_PARAM_DIGEST\fR) <UTF8 string>" 4
88 .IX Item """digest"" (OSSL_KDF_PARAM_DIGEST) <UTF8 string>"
89 .IP """key"" (\fBOSSL_KDF_PARAM_KEY\fR) <octet string>" 4
90 .IX Item """key"" (OSSL_KDF_PARAM_KEY) <octet string>"
91 .PD
92 These parameters work as described in "PARAMETERS" in \fBEVP_KDF\fR\|(3).
93 .IP """xcghash"" (\fBOSSL_KDF_PARAM_SSHKDF_XCGHASH\fR) <octet string>" 4
94 .IX Item """xcghash"" (OSSL_KDF_PARAM_SSHKDF_XCGHASH) <octet string>"
95 .PD 0
96 .IP """session_id"" (\fBOSSL_KDF_PARAM_SSHKDF_SESSION_ID\fR) <octet string>" 4
97 .IX Item """session_id"" (OSSL_KDF_PARAM_SSHKDF_SESSION_ID) <octet string>"
98 .PD
99 These parameters set the respective values for the KDF.
100 If a value is already set, the contents are replaced.
101 .IP """type"" (\fBOSSL_KDF_PARAM_SSHKDF_TYPE\fR) <UTF8 string>" 4
102 .IX Item """type"" (OSSL_KDF_PARAM_SSHKDF_TYPE) <UTF8 string>"
103 This parameter sets the type for the SSHKDF operation.
104 There are six supported types:
105 .RS 4
106 .IP EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 4
107 .IX Item "EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV"
108 The Initial IV from client to server.
109 A single char of value 65 (ASCII char 'A').
110 .IP EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 4
111 .IX Item "EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI"
112 The Initial IV from server to client
113 A single char of value 66 (ASCII char 'B').
114 .IP EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 4
115 .IX Item "EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV"
116 The Encryption Key from client to server
117 A single char of value 67 (ASCII char 'C').
118 .IP EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 4
119 .IX Item "EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI"
120 The Encryption Key from server to client
121 A single char of value 68 (ASCII char 'D').
122 .IP EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 4
123 .IX Item "EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV"
124 The Integrity Key from client to server
125 A single char of value 69 (ASCII char 'E').
126 .IP EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 4
127 .IX Item "EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI"
128 The Integrity Key from client to server
129 A single char of value 70 (ASCII char 'F').
130 .RE
131 .RS 4
132 .RE
133 .PP
134 The OpenSSL FIPS provider also supports the following parameters:
135 .IP """fips-indicator"" (\fBOSSL_KDF_PARAM_FIPS_APPROVED_INDICATOR\fR) <integer>" 4
136 .IX Item """fips-indicator"" (OSSL_KDF_PARAM_FIPS_APPROVED_INDICATOR) <integer>"
137 A getter that returns 1 if the operation is FIPS approved, or 0 otherwise.
138 This may be used after calling EVP_KDF_derive. It returns 0 if any "***\-check"
139 related parameter is set to 0 and the check fails.
140 .IP """digest-check"" (\fBOSSL_KDF_PARAM_FIPS_DIGEST_CHECK\fR) <integer>" 4
141 .IX Item """digest-check"" (OSSL_KDF_PARAM_FIPS_DIGEST_CHECK) <integer>"
142 The default value of 1 causes an error during \fBEVP_KDF_CTX_set_params()\fR if
143 used digest is not approved.
144 Setting this to zero will ignore the error and set the approved
145 "fips-indicator" to 0.
146 This option breaks FIPS compliance if it causes the approved "fips-indicator"
147 to return 0.
148 .Sp
149 According to SP 800\-135r1, the following are approved digest algorithms: SHA\-1,
150 SHA2\-224, SHA2\-256, SHA2\-384, SHA2\-512.
151 .IP """key-check"" (\fBOSSL_KDF_PARAM_FIPS_KEY_CHECK\fR) <integer>" 4
152 .IX Item """key-check"" (OSSL_KDF_PARAM_FIPS_KEY_CHECK) <integer>"
153 The default value of 1 causes an error during \fBEVP_KDF_CTX_set_params()\fR if the
154 length of used key-derivation key (\fBOSSL_KDF_PARAM_KEY\fR) is shorter than 112
155 bits.
156 Setting this to zero will ignore the error and set the approved
157 "fips-indicator" to 0.
158 This option breaks FIPS compliance if it causes the approved "fips-indicator"
159 to return 0.
160 .SH NOTES
161 .IX Header "NOTES"
162 A context for SSHKDF can be obtained by calling:
163 .PP
164 .Vb 2
165 \& EVP_KDF *kdf = EVP_KDF_fetch(NULL, "SSHKDF", NULL);
166 \& EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
167 .Ve
168 .PP
169 The output length of the SSHKDF derivation is specified via the \fIkeylen\fR
170 parameter to the \fBEVP_KDF_derive\fR\|(3) function.
171 Since the SSHKDF output length is variable, calling \fBEVP_KDF_CTX_get_kdf_size\fR\|(3)
172 to obtain the requisite length is not meaningful. The caller must
173 allocate a buffer of the desired length, and pass that buffer to the
174 \&\fBEVP_KDF_derive\fR\|(3) function along with the desired length.
175 .SH EXAMPLES
176 .IX Header "EXAMPLES"
177 This example derives an 8 byte IV using SHA\-256 with a 1K "key" and appropriate
178 "xcghash" and "session_id" values:
179 .PP
180 .Vb 9
181 \& EVP_KDF *kdf;
182 \& EVP_KDF_CTX *kctx;
183 \& char type = EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV;
184 \& unsigned char key[1024] = "01234...";
185 \& unsigned char xcghash[32] = "012345...";
186 \& unsigned char session_id[32] = "012345...";
187 \& unsigned char out[8];
188 \& size_t outlen = sizeof(out);
189 \& OSSL_PARAM params[6], *p = params;
190 \&
191 \& kdf = EVP_KDF_fetch(NULL, "SSHKDF", NULL);
192 \& kctx = EVP_KDF_CTX_new(kdf);
193 \& EVP_KDF_free(kdf);
194 \&
195 \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
196 \& SN_sha256, strlen(SN_sha256));
197 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
198 \& key, (size_t)1024);
199 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SSHKDF_XCGHASH,
200 \& xcghash, (size_t)32);
201 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SSHKDF_SESSION_ID,
202 \& session_id, (size_t)32);
203 \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_SSHKDF_TYPE,
204 \& &type, sizeof(type));
205 \& *p = OSSL_PARAM_construct_end();
206 \& if (EVP_KDF_derive(kctx, out, outlen, params) <= 0)
207 \& /* Error */
208 .Ve
209 .SH "CONFORMING TO"
210 .IX Header "CONFORMING TO"
211 RFC 4253
212 .SH "SEE ALSO"
213 .IX Header "SEE ALSO"
214 \&\fBEVP_KDF\fR\|(3),
215 \&\fBEVP_KDF_CTX_new\fR\|(3),
216 \&\fBEVP_KDF_CTX_free\fR\|(3),
217 \&\fBEVP_KDF_CTX_set_params\fR\|(3),
218 \&\fBEVP_KDF_CTX_get_kdf_size\fR\|(3),
219 \&\fBEVP_KDF_derive\fR\|(3),
220 "PARAMETERS" in \fBEVP_KDF\fR\|(3)
221 .SH HISTORY
222 .IX Header "HISTORY"
223 This functionality was added in OpenSSL 3.0.
224 .SH COPYRIGHT
225 .IX Header "COPYRIGHT"
226 Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
227 .PP
228 Licensed under the Apache License 2.0 (the "License"). You may not use
229 this file except in compliance with the License. You can obtain a copy
230 in the file LICENSE in the source distribution or at
231 <https://www.openssl.org/source/license.html>.