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