d89f84fd43f1abfd44422c73922d32ec8254a1d2
[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>:I<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>:I<v>
43
44 Passes options to the KDF algorithm.
45 A comprehensive list of parameters can be found in the EVP_KDF_CTX
46 implementation documentation.
47 Common parameter names used by EVP_KDF_CTX_set_params() 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 include TLS1-PRF, HKDF, SSKDF, PBKDF2,
86 SSHKDF, X942KDF, X963KDF and SCRYPT.
87
88 =back
89
90 =head1 EXAMPLES
91
92 Use TLS1-PRF to create a hex-encoded derived key from a secret key and seed:
93
94     openssl kdf -keylen 16 -kdfopt digest:SHA2-256 -kdfopt key:secret \
95                 -kdfopt seed:seed TLS1-PRF
96
97 Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
98
99     openssl kdf -keylen 10 -kdfopt digest:SHA2-256 -kdfopt key:secret \
100                 -kdfopt salt:salt -kdfopt info:label HKDF
101
102 Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
103
104     openssl kdf -keylen 64 -kdfopt mac:KMAC-128 -kdfopt maclen:20 \
105                 -kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
106                 -kdfopt hexsalt:3638271ccd68a2 SSKDF
107
108 Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
109
110     openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA2-256 \
111                 -kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
112                 -kdfopt hexsalt:3638271c SSKDF
113
114 Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
115
116     openssl kdf -keylen 14 -kdfopt digest:SHA2-256 \
117                 -kdfopt hexkey:6dbdc23f045488 \
118                 -kdfopt hexinfo:a1b2c3d4 SSKDF
119
120 Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
121
122     openssl kdf -keylen 16 -kdfopt digest:SHA2-256 \
123                 -kdfopt hexkey:0102030405 \
124                 -kdfopt hexxcghash:06090A \
125                 -kdfopt hexsession_id:01020304 \
126                 -kdfopt type:A SSHKDF
127
128 Use PBKDF2 to create a hex-encoded derived key from a password and salt:
129
130     openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
131                 -kdfopt salt:salt -kdfopt iter:2 PBKDF2
132
133 Use scrypt to create a hex-encoded derived key from a password and salt:
134
135     openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
136                 -kdfopt N:1024 -kdfopt r:8 -kdfopt p:16 \
137                 -kdfopt maxmem_bytes:10485760 SCRYPT
138
139 =head1 NOTES
140
141 The KDF mechanisms that are available will depend on the options
142 used when building OpenSSL.
143
144 =head1 SEE ALSO
145
146 L<openssl(1)>,
147 L<openssl-pkeyutl(1)>,
148 L<EVP_KDF(3)>,
149 L<EVP_KDF-SCRYPT(7)>,
150 L<EVP_KDF-TLS1_PRF(7)>,
151 L<EVP_KDF-PBKDF2(7)>,
152 L<EVP_KDF-HKDF(7)>,
153 L<EVP_KDF-SS(7)>,
154 L<EVP_KDF-SSHKDF(7)>,
155 L<EVP_KDF-X942(7)>,
156 L<EVP_KDF-X963(7)>
157
158 =head1 HISTORY
159
160 Added in OpenSSL 3.0
161
162 =head1 COPYRIGHT
163
164 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
165
166 Licensed under the OpenSSL license (the "License").  You may not use
167 this file except in compliance with the License.  You can obtain a copy
168 in the file LICENSE in the source distribution or at
169 L<https://www.openssl.org/source/license.html>.
170
171 =cut