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