Check if requested hash is supported before writing LUKS header.
[platform/upstream/cryptsetup.git] / man / cryptsetup.8
1 .TH CRYPTSETUP "8" "" "cryptsetup" "Maintenance Commands"
2 .SH NAME
3 cryptsetup - setup cryptographic volumes for dm-crypt (including LUKS extension)
4 .SH SYNOPSIS
5
6 .B cryptsetup <options> <action> <action args>
7 .SH DESCRIPTION
8 .PP
9 cryptsetup is used to conveniently setup dm-crypt managed device-mapper mappings.
10 For basic (plain) dm-crypt mappings, there are four operations.
11 .SH ACTIONS
12 These strings are valid for \fB<action>\fR, followed by their \fB<action args>\fR:
13
14 \fIcreate\fR <name> <device>
15 .IP
16 creates a mapping with <name> backed by device <device>.
17
18 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase, \-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-readonly]
19 .PP
20 \fIremove\fR <name>
21 .IP
22 removes an existing mapping <name>.
23 .PP
24 \fIstatus\fR <name>
25 .IP
26 reports the status for the mapping <name>.
27 .PP
28 \fIresize\fR <name>
29 .IP
30 resizes an active mapping <name>.
31
32 If \-\-size (in sectors) is not specified, the size of the underlying block device is used.
33 .PP
34 .br
35 .SH LUKS EXTENSION
36
37 LUKS, Linux Unified Key Setup, is a standard for hard disk encryption. It standardizes a partition header, as well as the format of the bulk data. LUKS can manage multiple passwords, that can be revoked effectively and that are protected against dictionary attacks with PBKDF2. 
38
39 These are valid LUKS actions:
40
41 \fIluksFormat\fR <device> [<key file>]
42 .IP
43 initializes a LUKS partition and sets the initial key, either via prompting or via <key file>.
44
45 \fB<options>\fR can be [\-\-cipher, \-\-verify-passphrase, \-\-key-size, \-\-key-slot,
46 \-\-key-file (takes precedence over optional second argument)].
47
48 .PP
49 \fIluksOpen\fR <device> <name>
50 .IP
51 opens the LUKS partition <device> and sets up a mapping <name> after successful verification of the supplied key material (either via key file by \-\-key-file, or via prompting).
52
53 \fB<options>\fR can be [\-\-key-file, \-\-readonly].
54 .PP
55 \fIluksClose\fR <name>
56 .IP
57 identical to \fIremove\fR.
58 .PP
59 \fIluksSuspend\fR <name>
60 .IP
61 suspends active device (all IO operations are frozen) and wipes encryption key from kernel. Kernel version 2.6.19 or later is required.
62
63 After that operation you have to use \fIluksResume\fR to reinstate encryption key (and resume device) or \fIluksClose\fR to remove mapped device.
64
65 \fBWARNING:\fR never try to suspend device where is the cryptsetup binary itself.
66 .PP
67 \fIluksResume\fR <name>
68 .IP
69 Resumes suspended device and reinstates encryption key. You will need provide passphrase
70 identical to \fIluksOpen\fR command (using prompting or key file).
71
72 \fB<options>\fR can be [\-\-key-file]
73 .PP
74 \fIluksAddKey\fR <device> [<new key file>]
75 .IP
76 add a new key file/passphrase. An existing passphrase or key file (via \-\-key-file) must be supplied.
77 The key file with the new material is supplied as a positional argument.
78
79 \fB<options>\fR can be [\-\-key-file, \-\-key-slot].
80 .PP
81 \fIluksRemoveKey\fR <device> [<key file>] 
82 .IP
83 remove supplied key or key file from LUKS device
84 .PP
85 \fIluksKillSlot\fR <device> <key slot number>
86 .IP
87 wipe key with number <key slot> from LUKS device. A remaining passphrase or
88 key file (via \-\-key-file) must be supplied.
89
90 \fB<options>\fR can be [\-\-key-file].
91 .PP
92 \fIluksDelKey\fR <device> <key slot number>
93 .IP
94 identical to luksKillSlot, but deprecated action name.
95 .PP
96 \fIluksUUID\fR <device>
97 .IP
98 print UUID, if <device> has a LUKS header.
99 .PP
100 \fIisLuks\fR <device>
101 .IP
102 returns true, if <device> is a LUKS partition. Otherwise, false.
103 .PP
104 \fIluksDump\fR <device>
105 .IP
106 dumps the header information of a LUKS partition.
107 .PP
108 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
109 .IP
110 Stores binary backup of LUKS header and keyslot areas.
111
112 \fBWARNING:\fR Please note that with this backup file (and old passphrase knowledge) you can decrypt data even if old passphrase was wiped from real device.
113
114 Also note that anti-forensic splitter is not used during manipulation with backup file.
115 .PP
116 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
117 .IP
118
119 Restores binary backup of LUKS header and keyslot areas from specified file.
120
121 \fBWARNING:\fR All the keyslot areas are overwritten, only active keyslots form backup file are available after issuing this command.
122
123 This command allows restoring header if device do not contain LUKS header or if the master key size and data offset in LUKS header on device match the backup file.
124 .PP
125
126 For more information about LUKS, see \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR
127
128 .SH OPTIONS
129 .TP
130 .B "\-\-verbose, \-v"
131 Print more verbose messages.
132 .TP
133 .B "\-\-debug"
134 Run in debug mode with full diagnostic logs.
135 .TP
136 .B "\-\-hash, \-h"
137 For \fIcreate\fR action specifies hash to use for password hashing.
138
139 For \fIluksFormat\fR action specifies hash used in LUKS key setup scheme and volume key digest.
140
141 \fBWARNING:\fR setting hash other than \fBsha1\fR causes LUKS device incompatible with older version of cryptsetup.
142
143 The hash string is passed to libgcrypt, so all hash algorithms are supported
144 (for \fIluksFormat\fR algorithm must provide at least 20 byte long hash).
145 Default is set during compilation, compatible values with old version of cryptsetup are
146 \fB"ripemd160"\fR for \fIcreate\fR action and \fB"sha1"\fR for \fIluksFormat\fR.
147
148 Use \fIcryptsetup \-\-help\fR to show defaults.
149 .TP
150 .B "\-\-cipher, \-c"
151 set cipher specification string.
152
153 Default mode is configurable during compilation,
154 you can see compiled-in default using \fIcryptsetup \-\-help\fR.
155 If not changed, the default is for plain dm-crypt and LUKS mappings
156 "aes-cbc-essiv:sha256".
157
158 For pre-2.6.10 kernels, use "aes-plain" as they don't understand
159 the new cipher spec strings. To use ESSIV, use "aes-cbc-essiv:sha256".
160
161 For XTS mode, kernel version 2.6.24 or more recent is required.
162 Use "aes-xts-plain" cipher specification and set key size to 256 (or 512) bits (see \-s option).
163 .TP
164 .B "\-\-verify-passphrase, \-y"
165 query for passwords twice. Useful when creating a (regular) mapping for the first time, or when running \fIluksFormat\fR.
166 .TP
167 .B "\-\-key-file, \-d"
168 use file as key material.
169
170 With LUKS, key material supplied in key files via \-d are always used for existing passphrases,
171 except in \fIluksFormat\fR action where \-d is equivalent to positional key file argument.
172 If you want to set a new key via a key file, you have to use a positional arg to \fIluksAddKey\fR.
173
174 If the key file is "-", stdin will be used. With the "-" key file reading will
175 not stop when new line character is detected. See section \fBNOTES ON PASSWORD PROCESSING\fR for more information.
176 .TP
177 .B "\-\-master-key-file"
178 Use pre-generated master key stored in file. For \fIluksFormat\fR it allows LUKS header reformatting with the same master key (if all other parameters are the same existing encrypted data remains intact).
179
180 For \fIluksAddKey\fR it allows adding new passphrase with only master key knowledge.
181 .TP
182 .B "\-\-key-slot, \-S"
183 For LUKS operations that add key material, this options allows to you specify which key slot is selected for the new key. This option can be used for \fIluksFormat\fR and \fIluksAddKey\fR.
184 .TP
185 .B "\-\-key-size, \-s"
186 set key size in bits.
187
188 Has to be a multiple of 8 bits. The key size is limited by the used cipher. See output of /proc/crypto for more information.
189 Can be used for \fIcreate\fR or \fIluksFormat\fR, all other LUKS actions will use key-size specified by the LUKS header.
190 Default is set during compilation, if not changed it is 256 bits.
191
192 Use \fIcryptsetup \-\-help\fR to show defaults.
193
194 For \fIluksOpen\fR this option specifies number of bits read from the key-file (default is exhaustive read from key-file).
195 .TP
196 .B "\-\-size, \-b"
197 force the size of the underlying device in sectors.
198 This option is only relevant for \fIcreate\fR and \fIresize\fR action.
199 .TP
200 .B "\-\-offset, \-o"
201 start offset in the backend device (in 512-byte sectors).
202 This option is only relevant for \fIcreate\fR action.
203 .TP
204 .B "\-\-skip, \-p"
205 how many sectors of the encrypted data to skip at the beginning. This is different from the \-\-offset options with respect to IV calculations. Using \-\-offset will shift the IV calculation by the same negative amount. Hence, if \-\-offset \fIn\fR, sector \fIn\fR will be the first sector on the mapping with IV \fI0\fR. Using \-\-skip would have resulted in sector \fIn\fR being the first sector also, but with IV \fIn\fR.
206 This option is only relevant for \fIcreate\fR action.
207 .TP
208 .B "\-\-readonly"
209 set up a read-only mapping.
210 .TP
211 .B "\-\-iter-time, \-i"
212 The number of milliseconds to spend with PBKDF2 password processing. This option is only relevant to the LUKS operations as \fIluksFormat\fR or \fIluksAddKey\fR.
213 .TP
214 .B "\-\-batch-mode, \-q"
215 Do not ask for confirmation. Use with care! This option is only relevant for \fIluksFormat\fR, \fIluksAddKey\fR, \fIluksRemoveKey\fR or \fIluksKillSlot\fR.
216 .TP
217 .B "\-\-timeout, \-t"
218 The number of seconds to wait before timeout. This option is relevant every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR or \fIluksAddKey\fR. It has no effect if used in conjunction with \-\-key-file.
219 .TP
220 .B "\-\-tries, \-T"
221 How often the input of the passphrase shall be retried. This option is relevant every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR or \fIluksAddKey\fR. The default is 3 tries.
222 .TP
223 .B "\-\-align-payload=\fIvalue\fR"
224 Align payload at a boundary of \fIvalue\fR 512-byte sectors. This option is relevant for \fIluksFormat\fR.
225 If not specified, cryptsetup tries to use topology info provided by kernel for underlying device to get optimal alignment.
226 If not available (or calculated value is multiple of default) data is by default aligned to 1 MiB boundary (2048 512-byte sectors).
227 .TP
228 .B "\-\-version"
229 Show the version.
230
231 .SH NOTES ON PASSWORD PROCESSING
232 \fIFrom a terminal\fR: Password processing is new-line sensitive, meaning the reading will stop after encountering \\n. It will process the read material (without newline) with the default hash or the hash given by \-\-hash. After hashing, it will be cropped to the key size given by \-s.
233
234 \fIFrom stdin\fR: Reading will continue until EOF (so using e.g. /dev/random as stdin will not work), with the trailing newline stripped. After that the read data will be hashed with the default hash or the hash given by \-\-hash and the result will be cropped to the keysize given by \-s. If "plain" is used as an argument to the hash option, the input data will not be hashed.
235 Instead, it will be zero padded (if shorter than the keysize) or truncated (if longer than the keysize) and used directly as the key. No warning will be given if the amount of data read from stdin is less than the keysize.
236
237 \fIFrom a key file\fR: It will be cropped to the size given by \-s. If there is insufficient key material in the key file, cryptsetup will quit with an error.
238
239 If \-\-key-file=- is used for reading the key from stdin, no trailing newline is stripped from the input. Without that option, cryptsetup strips trailing newlines from stdin input.
240 .SH NOTES ON PASSWORD PROCESSING FOR LUKS
241 LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898).
242
243 LUKS will always do an exhaustive password reading. Hence, password can not be read from /dev/random, /dev/zero or any other stream that does not terminate.
244
245 For any password creation action (luksAddKey, or luksFormat), the user may specify how much the time the password processing should consume.
246 Increasing the time will lead to a more secure password, but also will take luksOpen longer to complete. The default setting of one second is sufficient for good security.
247 .SH INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS
248 LUKS checks for a valid password or key when an encrypted partition is unlocked. Thus the luksOpen action fails with invalid password or key, contrary to the plain dm-crypt create action.
249
250 Please also be sure that you are using the same keyboard and language setting as during device format.
251 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
252 The available combinations of ciphers, modes, hashes and key sizes depend on kernel support. See /proc/crypto for a list of available options. You might need to load additional kernel crypto modules in order to get more options.
253
254 For \-\-hash option all algorithms supported by gcrypt library are available.
255 .SH NOTES ON PASSWORDS
256 Mathematics can't be bribed. Make sure you keep your passwords safe. There are a few nice tricks for constructing a fallback, when suddenly out of (or after being) blue, your brain refuses to cooperate. These fallbacks are possible with LUKS, as it's only possible with LUKS to have multiple passwords.
257 .SH AUTHORS
258 cryptsetup is written by Christophe Saout <christophe@saout.de>
259 .br
260 LUKS extensions, and man page by Clemens Fruhwirth <clemens@endorphin.org>
261 .SH "COMPATABILITY WITH OLD SUSE TWOFISH PARTITIONS"
262 To read images created with SuSE Linux 9.2's loop_fish2 use \-\-cipher
263 twofish-cbc-null \-s 256 \-h sha512, for images created with even
264 older SuSE Linux use \-\-cipher twofish-cbc-null \-s 192 \-h
265 ripemd160:20
266
267 .SH DEPRECATED ACTIONS
268 .PP
269 \fIreload\fR <name> <device>
270 .IP
271 modifies an active mapping <name>. Same options as for
272 create. 
273 .B WARNING:
274 Do not use this for LUKS devices, as the semantics
275 are identical to the create action, which are totally incompatible
276 with the LUKS key setup. 
277
278 This action is deprected because it proved to be rarely useful.  It is
279 uncommon to change the underlying device, key, or offset on the
280 fly. In case, you really want to do this, you certainly know what you
281 are doing and then you are probably better off with the swiss knive
282 tool for device mapper, namely dmsetup. It provides you with the same
283 functionality, see dmsetup reload.
284 .PP
285 \fIluksDelKey\fR <device> <key slot number>
286 .IP
287 identical to luksKillSlot, but deprecated action name. This option was
288 renamed, as we introduced luksRemoveKey, a softer method for disabling
289 password slots. To make a clear distinction that luksDelKey was more brutal than luksRemoveKey
290 .PP
291 \fI\-\-non-exclusive\fR
292 .IP
293 This option is ignored. Non-exclusive access to the same block device
294 can cause data corruption thus this mode is no longer supported by cryptsetup.
295
296 .SH "REPORTING BUGS"
297 Report bugs to <dm-crypt@saout.de> or Issues section on LUKS website.
298 Please attach output of failed command with added \-\-debug option.
299 .SH COPYRIGHT
300 Copyright \(co 2004 Christophe Saout
301 .br
302 Copyright \(co 2004-2006 Clemens Fruhwirth
303 .br
304 Copyright \(co 2009-2010 Red Hat, Inc.
305
306 This is free software; see the source for copying conditions.  There is NO
307 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
308 .SH "SEE ALSO"
309
310 dm-crypt website, \fBhttp://www.saout.de/misc/dm-crypt/\fR
311
312 LUKS website, \fBhttp://code.google.com/p/cryptsetup/\fR
313
314 dm-crypt TWiki, \fBhttp://www.saout.de/tikiwiki/tiki-index.php\fR