Deprecate unprefixed manual entries for openssl commands
[openssl.git] / doc / man1 / openssl-kdf.pod
1 =pod
2
3 =head1 NAME
4
5 openssl-kdf - perform Key Derivation Function operations
6
7 =head1 SYNOPSIS
8
9 B<openssl kdf>
10 [B<-help>]
11 [B<-kdfopt> I<nm:v>]
12 [B<-keylen> I<num>]
13 [B<-out> I<filename>]
14 [B<-binary>]
15 I<kdf_name>
16
17 =head1 DESCRIPTION
18
19 The key derivation functions generate a derived key from either a secret or
20 password.
21
22 =head1 OPTIONS
23
24 =over 4
25
26 =item B<-help>
27
28 Print a usage message.
29
30 =item B<-keylen> I<num>
31
32 The output size of the derived key. This field is required.
33
34 =item B<-out> I<filename>
35
36 Filename to output to, or standard output by default.
37
38 =item B<-binary>
39
40 Output the derived key in binary form. Uses hexadecimal text format if not specified.
41
42 =item B<-kdfopt> I<nm:v>
43
44 Passes options to the KDF algorithm.
45 A comprehensive list of controls can be found in the EVP_KDF_CTX implementation
46 documentation.
47 Common control strings used by EVP_KDF_ctrl_str() are:
48
49 =over 4
50
51 =item B<key:>I<string>
52
53 Specifies the secret key as an alphanumeric string (use if the key contains
54 printable characters only).
55 The string length must conform to any restrictions of the KDF algorithm.
56 A key must be specified for most KDF algorithms.
57
58 =item B<hexkey:>I<string>
59
60 Specifies the secret key in hexadecimal form (two hex digits per byte).
61 The key length must conform to any restrictions of the KDF algorithm.
62 A key must be specified for most KDF algorithms.
63
64 =item B<pass:>I<string>
65
66 Specifies the password as an alphanumeric string (use if the password contains
67 printable characters only).
68 The password must be specified for PBKDF2 and scrypt.
69
70 =item B<hexpass:>I<string>
71
72 Specifies the password in hexadecimal form (two hex digits per byte).
73 The password must be specified for PBKDF2 and scrypt.
74
75 =item B<digest:>I<string>
76
77 Specifies the name of a digest as an alphanumeric string.
78 To see the list of supported digests, use the command I<list -digest-commands>.
79
80 =back
81
82 =item I<kdf_name>
83
84 Specifies the name of a supported KDF algorithm which will be used.
85 The supported algorithms names are TLS1-PRF, HKDF, SSKDF, PBKDF2, SSHKDF and id-scrypt.
86
87 =back
88
89 =head1 EXAMPLES
90
91 Use TLS1-PRF to create a hex-encoded derived key from a secret key and seed:
92
93     openssl kdf -keylen 16 -kdfopt digest:SHA256 -kdfopt key:secret \
94                 -kdfopt seed:seed TLS1-PRF
95
96 Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
97
98     openssl kdf -keylen 10 -kdfopt digest:SHA256 -kdfopt key:secret \
99                 -kdfopt salt:salt -kdfopt info:label HKDF
100
101 Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
102
103     openssl kdf -keylen 64 -kdfopt mac:KMAC128 -kdfopt maclen:20 \
104                 -kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
105                 -kdfopt hexsalt:3638271ccd68a2 SSKDF
106
107 Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
108
109     openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA256 \
110                 -kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
111                 -kdfopt hexsalt:3638271c SSKDF
112
113 Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
114
115     openssl kdf -keylen 14 -kdfopt digest:SHA256 \
116                 -kdfopt hexkey:6dbdc23f045488 \
117                 -kdfopt hexinfo:a1b2c3d4 SSKDF
118
119 Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
120
121     openssl kdf -keylen 16 -kdfopt digest:SHA256 \
122                 -kdfopt hexkey:0102030405 \
123                 -kdfopt hexxcghash:06090A \
124                 -kdfopt hexsession_id:01020304 \
125                 -kdfopt type:A SSHKDF
126
127 Use PBKDF2 to create a hex-encoded derived key from a password and salt:
128
129     openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
130                 -kdfopt salt:salt -kdfopt iter:2 PBKDF2
131
132 Use scrypt to create a hex-encoded derived key from a password and salt:
133
134     openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
135                 -kdfopt N:1024 -kdfopt r:8 -kdfopt p:16 \
136                 -kdfopt maxmem_bytes:10485760 id-scrypt
137
138 =head1 NOTES
139
140 The KDF mechanisms that are available will depend on the options
141 used when building OpenSSL.
142
143 =head1 SEE ALSO
144
145 L<openssl(1)>,
146 L<openssl-pkeyutl(1)>
147 L<EVP_KDF_CTX(3)>,
148 L<EVP_KDF_SCRYPT(7)>
149 L<EVP_KDF_TLS1_PRF(7)>
150 L<EVP_KDF_PBKDF2(7)>
151 L<EVP_KDF_HKDF(7)>
152 L<EVP_KDF_SS(7)>
153 L<EVP_KDF_SSHKDF(7)>
154
155 =head1 HISTORY
156
157 Added in OpenSSL 3.0
158
159 =head1 COPYRIGHT
160
161 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
162
163 Licensed under the OpenSSL license (the "License").  You may not use
164 this file except in compliance with the License.  You can obtain a copy
165 in the file LICENSE in the source distribution or at
166 L<https://www.openssl.org/source/license.html>.
167
168 =cut