1 | =pod
|
---|
2 | {- OpenSSL::safe::output_do_not_edit_headers(); -}
|
---|
3 |
|
---|
4 | =head1 NAME
|
---|
5 |
|
---|
6 | openssl-kdf - perform Key Derivation Function operations
|
---|
7 |
|
---|
8 | =head1 SYNOPSIS
|
---|
9 |
|
---|
10 | B<openssl kdf>
|
---|
11 | [B<-help>]
|
---|
12 | [B<-cipher>]
|
---|
13 | [B<-digest>]
|
---|
14 | [B<-mac>]
|
---|
15 | [B<-kdfopt> I<nm>:I<v>]
|
---|
16 | [B<-keylen> I<num>]
|
---|
17 | [B<-out> I<filename>]
|
---|
18 | [B<-binary>]
|
---|
19 | {- $OpenSSL::safe::opt_provider_synopsis -}
|
---|
20 | I<kdf_name>
|
---|
21 |
|
---|
22 | =head1 DESCRIPTION
|
---|
23 |
|
---|
24 | The key derivation functions generate a derived key from either a secret or
|
---|
25 | password.
|
---|
26 |
|
---|
27 | =head1 OPTIONS
|
---|
28 |
|
---|
29 | =over 4
|
---|
30 |
|
---|
31 | =item B<-help>
|
---|
32 |
|
---|
33 | Print a usage message.
|
---|
34 |
|
---|
35 | =item B<-keylen> I<num>
|
---|
36 |
|
---|
37 | The output size of the derived key. This field is required.
|
---|
38 |
|
---|
39 | =item B<-out> I<filename>
|
---|
40 |
|
---|
41 | Filename to output to, or standard output by default.
|
---|
42 |
|
---|
43 | =item B<-binary>
|
---|
44 |
|
---|
45 | Output the derived key in binary form. Uses hexadecimal text format if not specified.
|
---|
46 |
|
---|
47 | =item B<-cipher> I<name>
|
---|
48 |
|
---|
49 | Specify the cipher to be used by the KDF.
|
---|
50 | Not all KDFs require a cipher and it is an error to use this option in such
|
---|
51 | cases.
|
---|
52 |
|
---|
53 | =item B<-digest> I<name>
|
---|
54 |
|
---|
55 | Specify the digest to be used by the KDF.
|
---|
56 | Not all KDFs require a digest and it is an error to use this option in such
|
---|
57 | cases.
|
---|
58 | To see the list of supported digests, use C<openssl list -digest-commands>.
|
---|
59 |
|
---|
60 | =item B<-mac> I<name>
|
---|
61 |
|
---|
62 | Specify the MAC to be used by the KDF.
|
---|
63 | Not all KDFs require a MAC and it is an error to use this option in such
|
---|
64 | cases.
|
---|
65 |
|
---|
66 | =item B<-kdfopt> I<nm>:I<v>
|
---|
67 |
|
---|
68 | Passes options to the KDF algorithm.
|
---|
69 | A comprehensive list of parameters can be found in the EVP_KDF_CTX
|
---|
70 | implementation documentation.
|
---|
71 | Common parameter names used by EVP_KDF_CTX_set_params() are:
|
---|
72 |
|
---|
73 | =over 4
|
---|
74 |
|
---|
75 | =item B<key:>I<string>
|
---|
76 |
|
---|
77 | Specifies the secret key as an alphanumeric string (use if the key contains
|
---|
78 | printable characters only).
|
---|
79 | The string length must conform to any restrictions of the KDF algorithm.
|
---|
80 | A key must be specified for most KDF algorithms.
|
---|
81 |
|
---|
82 | =item B<hexkey:>I<string>
|
---|
83 |
|
---|
84 | Specifies the secret key in hexadecimal form (two hex digits per byte).
|
---|
85 | The key length must conform to any restrictions of the KDF algorithm.
|
---|
86 | A key must be specified for most KDF algorithms.
|
---|
87 |
|
---|
88 | =item B<pass:>I<string>
|
---|
89 |
|
---|
90 | Specifies the password as an alphanumeric string (use if the password contains
|
---|
91 | printable characters only).
|
---|
92 | The password must be specified for PBKDF2 and scrypt.
|
---|
93 |
|
---|
94 | =item B<hexpass:>I<string>
|
---|
95 |
|
---|
96 | Specifies the password in hexadecimal form (two hex digits per byte).
|
---|
97 | The password must be specified for PBKDF2 and scrypt.
|
---|
98 |
|
---|
99 | =item B<digest:>I<string>
|
---|
100 |
|
---|
101 | This option is identical to the B<-digest> option.
|
---|
102 |
|
---|
103 | =item B<cipher:>I<string>
|
---|
104 |
|
---|
105 | This option is identical to the B<-cipher> option.
|
---|
106 |
|
---|
107 | =item B<mac:>I<string>
|
---|
108 |
|
---|
109 | This option is identical to the B<-mac> option.
|
---|
110 |
|
---|
111 | =back
|
---|
112 |
|
---|
113 | {- $OpenSSL::safe::opt_provider_item -}
|
---|
114 |
|
---|
115 | =item I<kdf_name>
|
---|
116 |
|
---|
117 | Specifies the name of a supported KDF algorithm which will be used.
|
---|
118 | The supported algorithms names include TLS1-PRF, HKDF, SSKDF, PBKDF2,
|
---|
119 | SSHKDF, X942KDF-ASN1, X942KDF-CONCAT, X963KDF and SCRYPT.
|
---|
120 |
|
---|
121 | =back
|
---|
122 |
|
---|
123 | =head1 EXAMPLES
|
---|
124 |
|
---|
125 | Use TLS1-PRF to create a hex-encoded derived key from a secret key and seed:
|
---|
126 |
|
---|
127 | openssl kdf -keylen 16 -kdfopt digest:SHA2-256 -kdfopt key:secret \
|
---|
128 | -kdfopt seed:seed TLS1-PRF
|
---|
129 |
|
---|
130 | Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
|
---|
131 |
|
---|
132 | openssl kdf -keylen 10 -kdfopt digest:SHA2-256 -kdfopt key:secret \
|
---|
133 | -kdfopt salt:salt -kdfopt info:label HKDF
|
---|
134 |
|
---|
135 | Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
|
---|
136 |
|
---|
137 | openssl kdf -keylen 64 -kdfopt mac:KMAC-128 -kdfopt maclen:20 \
|
---|
138 | -kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
|
---|
139 | -kdfopt hexsalt:3638271ccd68a2 SSKDF
|
---|
140 |
|
---|
141 | Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
|
---|
142 |
|
---|
143 | openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA2-256 \
|
---|
144 | -kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
|
---|
145 | -kdfopt hexsalt:3638271c SSKDF
|
---|
146 |
|
---|
147 | Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
|
---|
148 |
|
---|
149 | openssl kdf -keylen 14 -kdfopt digest:SHA2-256 \
|
---|
150 | -kdfopt hexkey:6dbdc23f045488 \
|
---|
151 | -kdfopt hexinfo:a1b2c3d4 SSKDF
|
---|
152 |
|
---|
153 | Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
|
---|
154 |
|
---|
155 | openssl kdf -keylen 16 -kdfopt digest:SHA2-256 \
|
---|
156 | -kdfopt hexkey:0102030405 \
|
---|
157 | -kdfopt hexxcghash:06090A \
|
---|
158 | -kdfopt hexsession_id:01020304 \
|
---|
159 | -kdfopt type:A SSHKDF
|
---|
160 |
|
---|
161 | Use PBKDF2 to create a hex-encoded derived key from a password and salt:
|
---|
162 |
|
---|
163 | openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
|
---|
164 | -kdfopt salt:salt -kdfopt iter:2 PBKDF2
|
---|
165 |
|
---|
166 | Use scrypt to create a hex-encoded derived key from a password and salt:
|
---|
167 |
|
---|
168 | openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
|
---|
169 | -kdfopt n:1024 -kdfopt r:8 -kdfopt p:16 \
|
---|
170 | -kdfopt maxmem_bytes:10485760 SCRYPT
|
---|
171 |
|
---|
172 | =head1 NOTES
|
---|
173 |
|
---|
174 | The KDF mechanisms that are available will depend on the options
|
---|
175 | used when building OpenSSL.
|
---|
176 |
|
---|
177 | =head1 SEE ALSO
|
---|
178 |
|
---|
179 | L<openssl(1)>,
|
---|
180 | L<openssl-pkeyutl(1)>,
|
---|
181 | L<EVP_KDF(3)>,
|
---|
182 | L<EVP_KDF-SCRYPT(7)>,
|
---|
183 | L<EVP_KDF-TLS1_PRF(7)>,
|
---|
184 | L<EVP_KDF-PBKDF2(7)>,
|
---|
185 | L<EVP_KDF-HKDF(7)>,
|
---|
186 | L<EVP_KDF-SS(7)>,
|
---|
187 | L<EVP_KDF-SSHKDF(7)>,
|
---|
188 | L<EVP_KDF-X942-ASN1(7)>,
|
---|
189 | L<EVP_KDF-X942-CONCAT(7)>,
|
---|
190 | L<EVP_KDF-X963(7)>
|
---|
191 |
|
---|
192 | =head1 HISTORY
|
---|
193 |
|
---|
194 | Added in OpenSSL 3.0
|
---|
195 |
|
---|
196 | =head1 COPYRIGHT
|
---|
197 |
|
---|
198 | Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
|
---|
199 |
|
---|
200 | Licensed under the Apache License 2.0 (the "License"). You may not use
|
---|
201 | this file except in compliance with the License. You can obtain a copy
|
---|
202 | in the file LICENSE in the source distribution or at
|
---|
203 | L<https://www.openssl.org/source/license.html>.
|
---|
204 |
|
---|
205 | =cut
|
---|