682d67b35facb4341be5dd2a10db2da2fe466404
[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 .B cryptsetup <options> <action> <action args>
6 .SH DESCRIPTION
7 .PP
8 cryptsetup is used to conveniently setup dm-crypt managed device-mapper mappings.
9 .SH PLAIN MODE
10 For basic (plain) dm-crypt mappings, there are four operations.
11
12 \fIcreate\fR <name> <device>
13 .IP
14 creates a mapping with <name> backed by device <device>.
15
16 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
17 \-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-size, \-\-readonly, \-\-shared,
18 \-\-allow-discards]
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 .SH LUKS EXTENSION
34 LUKS, Linux Unified Key Setup, is a standard for hard disk encryption.
35 It standardizes a partition header, as well as the format of the bulk data.
36 LUKS can manage multiple passwords, that can be revoked effectively
37 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,
46 \-\-key-slot, \-\-key-file (takes precedence over optional second argument),
47 \-\-keyfile-size, \-\-use-random | \-\-use-urandom, \-\-uuid].
48 .PP
49 \fIluksOpen\fR <device> <name>
50 .IP
51 opens the LUKS partition <device> and sets up a mapping <name> after
52 successful verification of the supplied key material
53 (either via key file by \-\-key-file, or via prompting).
54
55 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-readonly, \-\-allow-discards,
56 \-\-header].
57 .PP
58 \fIluksClose\fR <name>
59 .IP
60 identical to \fIremove\fR.
61 .PP
62 \fIluksSuspend\fR <name>
63 .IP
64 suspends active device (all IO operations are frozen) and wipes encryption
65 key from kernel. Kernel version 2.6.19 or later is required.
66
67 After that operation you have to use \fIluksResume\fR to reinstate
68 encryption key (and resume device) or \fIluksClose\fR to remove mapped device.
69
70 \fBWARNING:\fR never try to suspend device where is the cryptsetup binary itself.
71
72 \fB<options>\fR can be [\-\-header].
73 .PP
74 \fIluksResume\fR <name>
75 .IP
76 Resumes suspended device and reinstates encryption key. You will need provide passphrase
77 identical to \fIluksOpen\fR command (using prompting or key file).
78
79 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-header]
80 .PP
81 \fIluksAddKey\fR <device> [<new key file>]
82 .IP
83 add a new key file/passphrase. An existing passphrase or key file
84 (via \-\-key-file) must be supplied.
85 The key file with the new material is supplied as a positional argument.
86
87 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-new-keyfile-size, \-\-key-slot].
88 .PP
89 \fIluksRemoveKey\fR <device> [<key file>] 
90 .IP
91 remove supplied key or key file from LUKS device
92 .PP
93 \fIluksChangeKey\fR <device> [<new key file>]
94 .IP
95 change existing key file or passphrase. An existing passphrase
96 or key file (via \-\-key-file) must be supplied.
97 The key file with the new material is supplied as a positional argument.
98
99 If no key slot is specified (and there is still free key slot on device)
100 new slot is allocated before the old is purged.
101
102 If \fB\-\-key\-slot\fR option is specified (or there is no free slot)
103 command will overwrite existing slot.
104
105 \fBWARNING:\fR Be sure you have another slot active or header backup
106 when using explicit key slot (so you can unlock the device even after
107 possible media failure during slot swap).
108
109 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size,\-\-new-keyfile-size,
110 \-\-key-slot].
111 .PP
112 \fIluksKillSlot\fR <device> <key slot number>
113 .IP
114 wipe key with number <key slot> from LUKS device. A remaining passphrase or
115 key file (via \-\-key-file) must be supplied.
116
117 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size].
118 .PP
119 \fIluksUUID\fR <device>
120 .IP
121 print UUID, if <device> has a LUKS header.
122
123 set new UUID if \fI\-\-uuid\fR option is specified.
124 .PP
125 \fIisLuks\fR <device>
126 .IP
127 returns true, if <device> is a LUKS partition. Otherwise, false.
128 .PP
129 \fIluksDump\fR <device>
130 .IP
131 dumps the header information of a LUKS partition.
132
133 If \-\-dump-master-key option is used, the volume (master) key is dumped
134 instead of keyslot info.
135
136 Because this information can be used to access encrypted device without
137 passphrase knowledge (even without LUKS header) use this option
138 very carefully.
139
140 Dump with volume key (either printed or stored to file) should be always
141 stored encrypted and on safe place.
142
143 LUKS passphrase or key file is required for volume key dump.
144
145 \fB<options>\fR can be [\-\-dump-master-key, \-\-key-file, \-\-keyfile-size].
146 .PP
147 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
148 .IP
149 Stores binary backup of LUKS header and keyslot areas.
150
151 \fBWARNING:\fR Please note that with this backup file (and old passphrase
152 knowledge) you can decrypt data even if old passphrase was wiped from real device.
153
154 Also note that anti-forensic splitter is not used during manipulation with backup file.
155 .PP
156 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
157 .IP
158 Restores binary backup of LUKS header and keyslot areas from specified file.
159
160 \fBWARNING:\fR All the keyslot areas are overwritten, only active keyslots
161 form backup file are available after issuing this command.
162
163 This command allows restoring header if device do not contain LUKS header
164 or if the master key size and data offset in LUKS header on device match the backup file.
165 .PP
166 For more information about LUKS, see
167 \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR
168 .SH loop-AES EXTENSION
169 cryptsetup supports mapping of loop-AES encrypted partition using
170 compatible dm-crypt mode.
171 .PP
172 \fIloopaesOpen\fR <device> <name> \-\-key-file <keyfile>
173 .IP
174 opens the loop-AES <device> and sets up a mapping <name>.
175
176 N.B. If key file is in GPG encrypted format, you have to use
177 \-\-key-file=- and decrypt it before use.
178 gpg \-\-decrypt <keyfile> | cryptsetup loopaesOpen \-\-key-file=- <device> <name>
179
180 Use \fB\-\-key-file\fR to specify proper key length, default compiled-in
181 parameters are visible in \fB\-\-help\fR output.
182
183 Use \fB\-\-offset\fR to specify device offset. Note the units need to be
184 specified in 512 bytes sectors.
185
186 Use \fB\-\-skip\fR to specify IV offset. If original device used offset
187 and not used it in IV sector calculations, you have to explicitly use
188 \fB\-\-skip 0\fR in addition to offset parameter.
189
190 Use \fB\-\-hash\fR to override hash function for password hashing
191 (otherwise it is detected according to key size).
192
193 \fB<options>\fR can be [\-\-key-file, \-\-key-size, \-\-offset, \-\-skip,
194 \-\-hash, \-\-readonly, \-\-allow-discards].
195 .PP
196 \fIloopaesClose\fR <name>
197 .IP
198 identical to \fIremove\fR.
199 .PP
200 For more information about loop-AES, see \fBhttp://loop-aes.sourceforge.net\fR
201 .SH OPTIONS
202 .TP
203 .B "\-\-verbose, \-v"
204 Print more verbose messages.
205 .TP
206 .B "\-\-debug"
207 Run in debug mode with full diagnostic logs.
208 .TP
209 .B "\-\-hash, \-h"
210 For \fIcreate\fR and \fIloopaesOpen\fR action specifies hash to use for password hashing.
211
212 For \fIluksFormat\fR action specifies hash used in LUKS key setup scheme
213 and volume key digest.
214
215 \fBWARNING:\fR setting hash other than \fBsha1\fR causes LUKS device
216 incompatible with older version of cryptsetup.
217
218 The hash string is passed to libgcrypt, so all hash algorithms are supported
219 (for \fIluksFormat\fR algorithm must provide at least 20 byte long hash).
220 Default is set during compilation, compatible values with old version of cryptsetup are
221 \fB"ripemd160"\fR for \fIcreate\fR action and \fB"sha1"\fR for \fIluksFormat\fR.
222
223 Use \fIcryptsetup \-\-help\fR to show defaults.
224 .TP
225 .B "\-\-cipher, \-c"
226 set cipher specification string.
227
228 Default mode is configurable during compilation,
229 you can see compiled-in default using \fIcryptsetup \-\-help\fR.
230 If not changed, the default is for plain dm-crypt and LUKS mappings
231 "aes-cbc-essiv:sha256".
232
233 For XTS mode, kernel version 2.6.24 or more recent is required.
234 Use "aes-xts-plain64" cipher specification and set key size to 256
235 (or 512) bits (see \-s option).
236 Note that plain64 IV (Initialization Vector) is available since kernel version 2.6.33
237 and it is full 64bit version of plain IV. For more info please see FAQ.
238 .TP
239 .B "\-\-verify-passphrase, \-y"
240 query for passwords twice. Useful when creating a (regular) mapping
241 for the first time, or when running \fIluksFormat\fR.
242 .TP
243 .B "\-\-key-file, \-d"
244 use file as key material.
245
246 With LUKS, key material supplied in key files via \-d are always used
247 for existing passphrases, except in \fIluksFormat\fR action where
248 \-d is equivalent to positional key file argument.
249
250 If you want to set a new key via a key file, you have to use
251 a positional arg to \fIluksAddKey\fR.
252
253 If the key file is "-", stdin will be used. With the "-" key file
254 reading will not stop when new line character is detected.
255
256 See section \fBNOTES ON PASSWORD PROCESSING\fR for more information.
257 .TP
258 .B "\-\-keyfile-size, \-l \fIvalue\fR"
259 Limits read from key file to \fIvalue\fR bytes.
260 Usable together with all commands using key file.
261 .TP
262 .B "\-\-new-keyfile-size  \fIvalue\fR"
263 Limits read from new key file to \fIvalue\fR bytes in \fIluksAddKey\fR when
264 adding new key file. Default is exhaustive read from key file.
265 .TP
266 .B "\-\-master-key-file"
267 Use pre-generated master key stored in file. For \fIluksFormat\fR it allows
268 LUKS header reformatting with the same master key (if all other parameters
269 are the same existing encrypted data remains intact).
270
271 For \fIluksAddKey\fR it allows adding new passphrase with only master key knowledge.
272 .TP
273 .B "\-\-dump-master-key"
274 For \fIluksDump\fR it allows LUKS header dump including volume (master) key.
275 Use with care (this information allows access to device without passphrase knowledge).
276
277 See \fIluksDump\fR for more info.
278 .TP
279 .B "\-\-use-random"
280 .TP
281 .B "\-\-use-urandom"
282 For \fIluksFormat\fR it defines which kernel random number generator will
283 be used for long-term key (volume key).
284
285 See \fBNOTES ON RNG\fR for more information. Use \fIcryptsetup \-\-help\fR
286 to show default RNG.
287 .TP
288 .B "\-\-key-slot, \-S"
289 For LUKS operations that add key material, this options allows you
290 to specify which key slot is selected for the new key.
291 This option can be used for \fIluksFormat\fR and \fIluksAddKey\fR.
292 .TP
293 .B "\-\-key-size, \-s"
294 set key size in bits.
295
296 Has to be a multiple of 8 bits. The key size is limited by the used cipher.
297
298 See output of /proc/crypto for more information.
299
300 Can be used for \fIcreate\fR or \fIluksFormat\fR, all other LUKS actions
301 will use key-size specified by the LUKS header.
302 Default is set during compilation, if not changed it is 256 bits.
303
304 Use \fIcryptsetup \-\-help\fR to show defaults.
305 .TP
306 .B "\-\-size, \-b"
307 force the size of the underlying device in sectors.
308 This option is only relevant for \fIcreate\fR and \fIresize\fR action.
309 .TP
310 .B "\-\-offset, \-o"
311 start offset in the backend device (in 512-byte sectors).
312 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
313 .TP
314 .B "\-\-skip, \-p"
315 how many sectors of the encrypted data to skip at the beginning.
316 This is different from the \-\-offset options with respect to IV calculations.
317 Using \-\-offset will shift the IV calculation by the same negative amount.
318 Hence, if \-\-offset \fIn\fR, sector \fIn\fR will be the first sector
319 on the mapping with IV \fI0\fR. Using \-\-skip would have resulted in sector
320 \fIn\fR being the first sector also, but with IV \fIn\fR.
321 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
322 .TP
323 .B "\-\-readonly"
324 set up a read-only mapping.
325 .TP
326 .B "\-\-shared"
327 create another non-overlapping mapping to one common ciphertext device,
328 e.g. to create hidden device inside another encrypted device.
329 This option is only relevant for \fIcreate\fR action.
330 Use \-\-offset, \-\-size and \-\-skip to specify mapped area.
331 .TP
332 .B "\-\-iter-time, \-i"
333 The number of milliseconds to spend with PBKDF2 password processing.
334 This option is only relevant to the LUKS operations as
335 \fIluksFormat\fR or \fIluksAddKey\fR.
336 Note that 0 means default.
337 .TP
338 .B "\-\-batch-mode, \-q"
339 Do not ask for confirmation. Use with care! This option is only relevant
340 for \fIluksFormat\fR, \fIluksAddKey\fR, \fIluksRemoveKey\fR or \fIluksKillSlot\fR.
341 .TP
342 .B "\-\-timeout, \-t"
343 The number of seconds to wait before timeout. This option is relevant every
344 time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
345 or \fIluksAddKey\fR. It has no effect if used in conjunction with \-\-key-file.
346 .TP
347 .B "\-\-tries, \-T"
348 How often the input of the passphrase shall be retried. This option is relevant
349 every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
350 or \fIluksAddKey\fR. The default is 3 tries.
351 .TP
352 .B "\-\-align-payload=\fIvalue\fR"
353 Align payload at a boundary of \fIvalue\fR 512-byte sectors.
354 This option is relevant for \fIluksFormat\fR.
355
356 If not specified, cryptsetup tries to use topology info provided by kernel
357 for underlying device to get optimal alignment.
358 If not available (or calculated value is multiple of default) data is by
359 default aligned to 1 MiB boundary (2048 512-byte sectors).
360
361 For detached LUKS header it specifies offset on data device.
362 See also \-\-header option.
363 .TP
364 .B "\-\-uuid=\fIUUID\fR"
365 Use provided \fIUUID\fR in \fIluksFormat\fR command instead of generating
366 new one or change existing UUID in \fIluksUUID\fR command.
367
368 The UUID must be provided in standard UUID format
369 (e.g. 12345678-1234-1234-1234-123456789abc).
370 .TP
371 .B "\-\-allow-discards\fR"
372 Allow using of discards (TRIM) requests for device.
373 This option is only relevant for \fIcreate\fR, \fIluksOpen\fR or \fIloopaesOpen\fR.
374
375 \fBWARNING:\fR Assess the specific security risks carefully before enabling this
376 option.  For example, allowing discards on encrypted devices may lead to the leak
377 of information about the ciphertext device (filesystem type, used space etc.)
378 if the discarded blocks can be located easily on the device later.
379
380 Kernel version 3.1 or more recent is required.
381 For older versions is the option ignored.
382 .TP
383 .B "\-\-header\fR"
384 Set detached (separated) metadata device or file with LUKS header.
385
386 This options allows separation of ciphertext device and on-disk metadata header.
387
388 This option is only relevant for LUKS devices and can be used in \fIluksFormat\fR,
389 \fIluksOpen\fR, \fIluksSuspend\fR, \fIluksResume\fR and \fIresize\fR commands.
390
391 If used with \fIluksFormat\fR the \-\-align-payload option is taken
392 as absolute sector alignment on ciphertext device and can be zero.
393
394 For other commands with separated metadata device you have to always specify
395 path to metadata device (not to the ciphertext device).
396
397 \fBWARNING:\fR There is no possible check that specified ciphertext device
398 is correct if on-disk header is detached. Use with care.
399 .TP
400 .B "\-\-version"
401 Show the version.
402 .SH RETURN CODES
403 Crypsetup returns 0 on success or non-zero on error.
404
405 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
406 3 out of memory, 4 wrong device specified, 5 device already exists
407 or device is busy.
408 .SH NOTES ON PASSWORD PROCESSING FOR PLAIN MODE
409 \fBFrom a terminal\fR: Password processing is new-line sensitive,
410 meaning the reading will stop after encountering \\n.
411 It will process the read material (without newline) with the default
412 hash or the hash given by \-\-hash.
413 After hashing, it will be cropped to the key size given by \-s.
414
415 \fBFrom stdin\fR: Reading will continue until EOF (or until
416 maximum input size is reached), with the trailing newline stripped.
417 The maximum input size is defined by the same compiled-in default
418 as for the maximum key file size or can be overwrittten
419 using \-\-keysfile-size option.
420
421 After that the read data will be hashed with the default hash
422 or the hash given by \-\-hash and the result will be cropped
423 to the keysize given by \-s.
424
425 If "plain" is used as an argument to the hash option, the input
426 data will not be hashed.
427 Instead, it will be zero padded (if shorter than the keysize) or
428 truncated (if longer than the keysize) and used directly as the key.
429 No warning will be given if the amount of data read from stdin is
430 less than the keysize.
431
432 \fBFrom a key file\fR: It will be cropped to the size given by \-s.
433 If there is insufficient key material in the key file, cryptsetup
434 will quit with an error.
435
436 If \-\-key-file=- is used for reading the key from stdin, no
437 trailing newline is stripped from the input. Without that option,
438 cryptsetup strips trailing newlines from stdin input.
439 .SH NOTES ON PASSWORD PROCESSING FOR LUKS
440 LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898).
441
442 LUKS will always do an exhaustive password reading.
443 Hence, password can not be read from /dev/random, /dev/zero or any
444 other stream that does not terminate.
445 To prevent exhausting of system memory, cryptsetup limits
446 maximum key file size. Compiled-in default is displayed in \-\-help
447 output. You can limit reads from key file using \-\-key-size option,
448 this option takes precedence over compiled-in default.
449
450 For any password creation action (luksAddKey, or luksFormat),
451 the user may specify how much the time the password processing
452 should consume. Increasing the time will lead to a more secure
453 password, but also will take luksOpen longer to complete.
454 The default setting of one second is sufficient for good security.
455 .SH INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS
456 LUKS checks for a valid password or key when an encrypted partition
457 is unlocked. Thus the luksOpen action fails with invalid password
458 or key, contrary to the plain dm-crypt create action.
459
460 Please also be sure that you are using the same keyboard and
461 language setting as during device format.
462 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
463 The available combinations of ciphers, modes, hashes and key sizes
464 depend on kernel support. See /proc/crypto for a list of available
465 options. You might need to load additional kernel crypto modules
466 in order to get more options.
467
468 For \-\-hash option all algorithms supported by gcrypt library are available.
469 .SH NOTES ON PASSWORDS
470 Mathematics can't be bribed. Make sure you keep your passwords safe.
471 There are a few nice tricks for constructing a fallback, when suddenly
472 out of (or after being) blue, your brain refuses to cooperate.
473 These fallbacks are possible with LUKS, as it's only possible with LUKS
474 to have multiple passwords.
475 .SH NOTES ON RNG
476 Random Number Generator (RNG) used in cryptsetup always uses kernel RNG without
477 any modifications or additions to data stream procudes by kernel (like internal
478 random pool operations or mixing with the other random sources).
479
480 There are two types of randomness cryptsetup/LUKS needs. One type (which always
481 uses /dev/urandom) is used for salt, AF splitter and for wiping removed
482 keyslot.
483
484 Second type is used for volume (master) key. You can switch between
485 using /dev/random and /dev/urandom  here, see \fP\-\-use-random\fR and \fP\-\-use-urandom\fR
486 options. Using /dev/random on system without enough entropy sources
487 can cause \fPluksFormat\fR to block until the requested amount of random data is gathered.
488 See \fPurandom(4)\fR for more information.
489 .SH NOTES ON LOOPBACK DEVICE USE
490 Cryptsetup is usually used directly over block device (like disk partition or LVM volume).
491 However if the device argument is file, cryptsetup tries to allocate loopback device
492 and map it into this file. This mode requires Linux kernel 2.6.25 or more recent which
493 supports loop autoclear flag (loop device is cleared on last close automatically).
494
495 When device mapping is active, you can see loop backing file in status command output.
496 Also see losetup(8).
497 .SH AUTHORS
498 cryptsetup is written by Christophe Saout <christophe@saout.de>
499 .br
500 LUKS extensions, and man page by Clemens Fruhwirth <clemens@endorphin.org>
501 .SH DEPRECATED ACTIONS
502 .PP
503 The \fIreload\fR action is no longer supported.
504 Please use \fIdmsetup(8)\fR if you need to
505 directly manipulate with the device mapping table.
506 .PP
507 The \fIluksDelKey\fR was replaced with \fIluksKillSlot\fR.
508 .PP
509 .SH REPORTING BUGS
510 Report bugs to <dm-crypt@saout.de> or Issues section on LUKS website.
511 Please attach output of failed command with added \-\-debug option.
512 .SH COPYRIGHT
513 Copyright \(co 2004 Christophe Saout
514 .br
515 Copyright \(co 2004-2006 Clemens Fruhwirth
516 .br
517 Copyright \(co 2009-2011 Red Hat, Inc.
518
519 This is free software; see the source for copying conditions.  There is NO
520 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
521 .SH SEE ALSO
522 LUKS website, \fBhttp://code.google.com/p/cryptsetup/\fR