Add simple cipher benchmarking.
[platform/upstream/cryptsetup.git] / man / cryptsetup.8
1 .TH CRYPTSETUP "8" "May 2012" "cryptsetup" "Maintenance Commands"
2 .SH NAME
3 cryptsetup - manage plain dm-crypt and LUKS encrypted volumes
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 
9 device-mapper mappings. These include plain dm-crypt volumes and 
10 LUKS volumes. The difference is that LUKS uses a metadata header
11 and can hence offer more features than plain dm-crypt. On the other 
12 hand, the header is visible and vulnerable to damage.
13 .SH PLAIN DM-CRYPT OR LUKS?
14 .PP
15 Unless you understand the cryptographic background well, use LUKS.
16 With plain dm-crypt there are a number of possible user errors
17 that massively decrease security. While LUKS cannot fix them
18 all, it can lessen the impact for many of them.
19 .SH WARNINGS
20 .PP 
21 A lot of good information on the risks of using encrypted storage,
22 on handling problems and on security aspects can be found in the
23 \fICryptsetup FAQ\fR. Read it. Nonetheless, some risks deserve
24 to be mentioned here. 
25
26 \fBBackup:\fR Storage media die. Encryption has no influence on that.
27 Backup is mandatory for encrypted data as well, if the data has any
28 worth. See the Cryptsetup FAQ for advice on how to do backup of an
29 encrypted volume.
30
31 \fBCharacter encoding:\fR If you enter a 
32 passphrase with special symbols, the passphrase can change 
33 depending character encoding. Keyboard settings can also change,
34 which can make blind input hard or impossible. For
35 example, switching from some ASCII 8-bit variant to UTF-8
36 can lead to a different binary encoding and hence different
37 passphrase seen by cryptsetup, even if what you see on
38 the terminal is exactly the same. It is therefore highly
39 recommended to select passphrase characters only from 7-bit 
40 ASCII, as the encoding for 7-bit ASCII stays the same for
41 all ASCII variants and UTF-8.
42
43 \fBLUKS header:\fR If the header of a LUKS volume gets damaged,
44 all data is permanently lost unless you have a header-backup.
45 If a key-slot is damaged, it can only be restored from a header-backup
46 or if another active key-slot with known passphrase is undamaged.
47 Damaging the LUKS header is something people manage to do with 
48 surprising frequency. This risk is the result of a trade-off 
49 between security and safety, as LUKS is designed for fast and 
50 secure wiping by just overwriting header and key-slot area. 
51
52 .SH PLAIN MODE
53 Plain dm-crypt encrypts the device sector-by-sector with a
54 single, non-salted hash of the passphrase. No checks 
55 are performed, no metadata is used. There is no formatting operation. 
56 When the raw device is mapped (created), the usual device operations 
57 can be used on the mapped device, including filesystem creation.
58 Mapped devices usually reside in /dev/mapper/<name>.
59
60 There are four operations:
61
62 \fIcreate\fR <name> <device>
63 .IP
64 Creates a mapping with <name> backed by device <device>.
65
66 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
67 \-\-key-file, \-\-keyfile-offset, \-\-key-size, \-\-offset, \-\-skip, \-\-size,
68 \-\-readonly, \-\-shared, \-\-allow-discards]
69
70 Example: 'cryptsetup create e1 /dev/sda10' maps the raw
71 encrypted device /dev/sda10 to the mapped (decrypted) device
72 /dev/mapper/e1, which can then be mounted, fsck-ed or have a 
73 filesystem created on it.
74 .PP
75 \fIremove\fR <name>
76 .IP
77 Removes the existing mapping <name> and wipes the key from kernel memory.
78 .PP
79 \fIstatus\fR <name>
80 .IP
81 Reports the status for the mapping <name>.
82 .PP
83 \fIresize\fR <name>
84 .IP
85 Resizes an active mapping <name>.
86
87 If \-\-size (in sectors) is not specified, the size of the 
88 underlying block device is used. Note that this does not
89 change the raw device geometry, it just changes how many
90 sectors of the raw device are represented in the mapped device.
91 .SH LUKS EXTENSION
92 LUKS, the Linux Unified Key Setup, is a standard for disk encryption.
93 It adds a standardized header at the start of the device, 
94 a key-slot area directly behind the header and the bulk
95 data area behind that. The whole set is called a 'LUKS container'.
96 The device that a LUKS container resides on is called a 'LUKS device'.
97 For most purposes both terms can be used interchangeably. But
98 note that when the LUKS header is at a nonzero offset
99 in a device, then the device is not a LUKS device anymore, but
100 has a LUKS container stored in it at an offset.
101
102 LUKS can manage multiple passphrases that can be individually revoked 
103 or changed and that can be securely scrubbed from persistent 
104 media due to the use of anti-forensic stripes. Passphrases
105 are protected against brute-force and dictionary
106 attacks by PBKDF2, which implements hash iteration and salting
107 in one function.
108
109 Each passphrase, also called a
110 .B key
111 in this document, is associated with one of 8 key-slots.
112 Key operations that do not specify a slot affect the first slot
113 that matches the supplied passphrase or the first empty slot if
114 a new passphrase is added.
115
116 The following are valid LUKS actions:
117
118 \fIluksFormat\fR <device> [<key file>]
119 .IP
120 Initializes a LUKS partition and sets the initial passphrase
121 (for key-slot 0), 
122 either via prompting or via <key file>. Note that 
123 if the second argument is present, then the passphrase 
124 is taken from the file given there, without the need
125 to use the \-\-key-file option. Also note that for both forms
126 of reading the passphrase from file you can 
127 give '-' as file name, which results in the passphrase being read
128 from stdin and the safety-question being skipped.
129
130 You can only call luksFormat on a LUKS device that is not mapped.
131
132 \fB<options>\fR can be [\-\-cipher, \-\-verify-passphrase, \-\-key-size,
133 \-\-key-slot, \-\-key-file (takes precedence over optional second argument),
134 \-\-keyfile-offset, \-\-keyfile-size, \-\-use-random | \-\-use-urandom, 
135 \-\-uuid,
136 \-\-master-key-file].
137
138 \fBWARNING:\fR Doing a luksFormat on an existing LUKS container will
139 make all data the old container permanently irretrievable, unless
140 you have a header backup.
141 .PP
142 \fIluksOpen\fR <device> <name>
143 .IP
144 Opens the LUKS device <device> and sets up a mapping <name> after
145 successful verification of the supplied passphrase. 
146 If the passphrase is not supplied via \-\-key-file, the command
147 prompts for it interactively.
148
149 The <device> parameter can be also specified by LUKS UUID in the 
150 format UUID=<uuid>, which uses the symlinks in /dev/disk/by-uuid.
151
152 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-offset, 
153 \-\-keyfile-size, \-\-readonly, \-\-test-passphrase,
154 \-\-allow-discards, \-\-header, \-\-key-slot, \-\-master-key-file].
155 .PP
156 \fIluksClose\fR <name>
157 .IP
158 identical to \fIremove\fR.
159 .PP
160 \fIluksSuspend\fR <name>
161 .IP
162 Suspends an active device (all IO operations will blocked
163 and accesses to the device will wait indefinitely)
164 and wipes the encryption
165 key from kernel memory. Needs kernel 2.6.19 or later.
166
167 After this operation you have to use \fIluksResume\fR to reinstate
168 the encryption key and unblock the device or \fIluksClose\fR to remove 
169 the mapped device.
170
171 \fBWARNING:\fR never suspend the device on which the cryptsetup binary resides.
172
173 \fB<options>\fR can be [\-\-header].
174 .PP
175 \fIluksResume\fR <name>
176 .IP
177 Resumes a suspended device and reinstates the encryption key. 
178 Prompts interactively for a passphrase if \-\-key-file is not given.
179
180 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-header]
181 .PP
182 \fIluksAddKey\fR <device> [<key file with new key>]
183 .IP
184 adds a new passphrase. An existing passphrase must be supplied 
185 interactively or via \-\-key-file.
186 The new passphrase to be added can be specified interactively
187 or read from the file given as positional argument.
188
189 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-offset, 
190 \-\-keyfile-size, \-\-new-keyfile-offset,
191 \-\-new-keyfile-size, \-\-key-slot, \-\-master-key-file].
192 .PP
193 \fIluksRemoveKey\fR <device> [<key file with passphrase to be removed>] 
194 .IP
195 Removes the supplied passphrase from the LUKS device. The
196 passphrase to be removed can be specified interactively,
197 as positional argument or via \-\-key-file.
198
199 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-offset, 
200 \-\-keyfile-size]
201
202 \fBWARNING:\fR If you read the passphrase from stdin
203 (without further argument or with '-' as argument 
204 to \-\-key-file), batch-mode (-q) will be implicitely
205 switched on and no warning will be given when you remove the 
206 last remaining passphrase from a LUKS container. Removing
207 the last passphrase makes the LUKS container permanently 
208 inaccessible.
209 .PP
210 \fIluksChangeKey\fR <device> [<new key file>]
211 .IP
212 Changes an existing passphrase. The passphrase
213 to be changed must be supplied interactively or via \-\-key-file.
214 The new passphrase can be supplied interactively or in 
215 a file given as positional argument.
216
217 If a key-slot is specified (via \-\-key-slot), the passphrase
218 for that key-slot must be given and the new passphrase
219 will overwrite the specified key-slot. If no key-slot
220 is specified and there is still a free key-slot, then
221 the new passphrase will be put into a free key-slot before the 
222 key-slot containing the old passphrase is purged. If there is
223 no free key-slot, then the key-slot with the old passphrase is
224 overwritten directly.
225
226 \fBWARNING:\fR If a key-slot is overwritten, a media failure
227 during this operation can cause the overwrite to fail after
228 the old passphrase has been wiped and make the LUKS container
229 inaccessible. 
230
231 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-offset, 
232 \-\-keyfile-size, \-\-new-keyfile-offset,
233 \-\-new-keyfile-size, \-\-key-slot].
234 .PP
235 \fIluksKillSlot\fR <device> <key slot number>
236 .IP
237 Wipe the key-slot number <key slot> from the LUKS device. A remaining 
238 passphrase must be supplied, either interactively or via \-\-key-file.
239 This command can remove the last remaining key-slot, but requires
240 an interactive confirmation when doing so. Removing the last
241 passphrase makes a LUKS container permanently inaccessible.
242
243 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-offset, \-\-keyfile-size].
244
245 \fBWARNING:\fR If you read the passphrase from stdin
246 (without further argument or with '-' as argument 
247 to \-\-key-file), batch-mode (-q) will be implicitely
248 switched on and no warning will be given when you remove the 
249 last remaining passphrase from a LUKS container. Removing
250 the last passphrase makes the LUKS container permanently 
251 inaccessible.
252 .PP
253 \fIluksUUID\fR <device>
254 .IP
255 Print the UUID of a LUKS device.
256 .br
257 Set new UUID if \fI\-\-uuid\fR option is specified.
258 .PP
259 \fIisLuks\fR <device>
260 .IP
261 Returns true, if <device> is a LUKS device, false otherwise.
262 Use option \-v to get human-readable feedback. 'Command successful.'
263 means the device is a LUKS device. 
264 .PP
265 \fIluksDump\fR <device>
266 .IP
267 Dump the header information of a LUKS device.
268
269 If the \-\-dump-master-key option is used, the LUKS device master key is 
270 dumped instead of the keyslot info. Beware that the master key cannot be
271 changed and can be used to decrypt the data stored in the LUKS container
272 without a passphrase and even without the LUKS header. This means
273 that if the master key is compromised, the whole device has to be 
274 erased to prevent further access. Use this option carefully.  
275
276 In order to dump the master key, a passphrase has to be supplied,
277 either interactively or via \-\-key-file. 
278
279 \fB<options>\fR can be [\-\-dump-master-key, \-\-key-file, 
280 \-\-keyfile-offset, \-\-keyfile-size].
281
282 \fBWARNING:\fR If \-\-dump-master-key is used with \-\-key-file
283 and the argument to \-\-key-file is '-', no validation question 
284 will be asked and no warning given.
285 .PP
286 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
287 .IP
288 Stores a binary backup of the LUKS header and keyslot area.
289 .br
290 Note: Using '-' as filename writes the header backup to a file named '-'. 
291
292 \fBWARNING:\fR This backup file and a passphrase valid
293 at the time of backup allows decryption of the 
294 LUKS data area, even if the passphrase was later changed or 
295 removed from the LUKS device. Also note that with a header
296 backup you lose the ability to securely wipe the LUKS
297 device by just overwriting the header and key-slots. You 
298 either need to securely erase all header backups in 
299 addition or overwrite the encrypted data area as well.
300 The second option is less secure, as some sectors
301 can survive, e.g. due to defect management. 
302 .PP
303 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
304 .IP
305 Restores a binary backup of the LUKS header and keyslot area 
306 from the specified file.
307 .br
308 Note: Using '-' as filename reads the header backup from a file named '-'.
309
310 \fBWARNING:\fR Header and keyslots will be replaced, only
311 the passphrases from the backup will work afterwards.
312
313 This command requires that the master key size and data offset 
314 of the LUKS header already on the device and of the header backup 
315 match. Alternatively, if there is no LUKS header on the device,
316 the backup will also be written to it.
317 .PP
318 \fIrepair\fR <device>
319 .IP
320 Tries to repair the LUKS device metadata if possible.
321
322 This command is useful to fix some known benign LUKS metadata 
323 header corruptions. Only basic corruptions of unused keyslot 
324 are fixable. This command will only change the LUKS header, not
325 any key-slot data.
326
327 \fBWARNING:\fR Always create a binary backup of the original 
328 header before calling this command.
329 .SH loop-AES EXTENSION
330 cryptsetup supports mapping loop-AES encrypted partition using
331 a compatibility mode.
332 .PP
333 \fIloopaesOpen\fR <device> <name> \-\-key-file <keyfile>
334 .IP
335 Opens the loop-AES <device> and sets up a mapping <name>.
336
337 If the key file is encrypted with GnuPG, then you have to use
338 \-\-key-file=- and decrypt it before use, e.g. like this:
339 .br
340 gpg \-\-decrypt <keyfile> | cryptsetup loopaesOpen \-\-key-file=- <device> <name>
341
342 Use \fB\-\-key-file-size\fR to specify the proper key length if needed. 
343
344 Use \fB\-\-offset\fR to specify device offset. Note that the units 
345 need to be specified in number of 512 byte sectors.
346
347 Use \fB\-\-skip\fR to specify the IV offset. If the original device 
348 used an offset and but did not use it in IV sector calculations, 
349 you have to explicitly use \fB\-\-skip 0\fR in addition to the offset 
350 parameter.
351
352 Use \fB\-\-hash\fR to override the default hash function for 
353 passphrase hashing (otherwise it is detected according to key 
354 size).
355
356 \fB<options>\fR can be [\-\-key-file, \-\-key-size, \-\-offset, \-\-skip,
357 \-\-hash, \-\-readonly, \-\-allow-discards].
358 .PP
359 \fIloopaesClose\fR <name>
360 .IP
361 Identical to \fIremove\fR.
362 .PP
363 See also section 7 of the FAQ and \fBhttp://loop-aes.sourceforge.net\fR
364 for more information regarding loop-AES.
365 .SH MISCELLANEOUS
366 .PP
367 \fIbenchmark\fR <options>
368 .IP
369 Benchmarks ciphers. Without parameters it tries to measure few common
370 configurations.
371
372 To benchmark other ciphers or modes, you need to specify \fB\-\-cipher\fR
373 and \fB\-\-key-size\fR options.
374
375 \fBNOTE:\fR This benchmark is using memory only and is only informative.
376 You cannot directly predict real storage encryption speed from it.
377
378 This benchmark requires kernel userspace crypto API interface to be available
379 (kernel af_alg and af_skcipher modules, introduced in Linux kernel 2.6.38).
380
381 \fB<options>\fR can be [\-\-cipher, \-\-key-size].
382 .SH OPTIONS
383 .TP
384 .B "\-\-verbose, \-v"
385 Print more information on command execution.
386 .TP
387 .B "\-\-debug"
388 Run in debug mode with full diagnostic logs. Debug output
389 lines are always prefixed by '#'.
390 .TP
391 .B "\-\-hash, \-h \fI<hash-spec>\fR"
392 Specifies the passphrase hash for \fIcreate\fR and \fIloopaesOpen\fR.
393
394 Specifies the hash used in the LUKS key setup scheme and volume key digest 
395 for \fIluksFormat\fR.
396
397 The specified hash name is passed to the compiled-in crypto backend. 
398 Different backends may support different hashes. 
399 For \fIluksFormat\fR, the hash 
400 algorithm must provide at least 160 bits of output, which 
401 excludes, e.g., MD5. Do not use a non-crypto hash like
402 \fB"crc32"\fR as this breaks security.
403
404 Values compatible with old version of cryptsetup are 
405 \fB"ripemd160"\fR for \fIcreate\fR and 
406 \fB"sha1"\fR for \fIluksFormat\fR.
407
408 Use \fIcryptsetup \-\-help\fR to show the defaults.
409 .TP
410 .B "\-\-cipher, \-c \fI<cipher-spec>\fR"
411 Set the cipher specification string.
412
413 \fIcryptsetup \-\-help\fR shows the compiled-in defaults.
414 The current default in the distributed sources is
415 "aes-cbc-essiv:sha256" for both plain dm-crypt and LUKS.
416
417 For XTS mode (a possible future default), use "aes-xts-plain"
418 or better "aes-xts-plain64"
419 as cipher specification and optionally set a key size of
420 512 bits with the \-s option. Key size for XTS
421 mode is twice that for other modes for the same 
422 security level. 
423
424 XTS mode requires kernel 2.6.24 or later and plain64 requires 
425 kernel 2.6.33 or later. More information can be found in the FAQ.
426 .TP
427 .B "\-\-verify-passphrase, \-y"
428 When interactively asking for a passphrase, ask for it twice
429 and complain if both inputs do not match. Advised when creating 
430 a regular mapping for the first time, or when running 
431 \fIluksFormat\fR. Ignores on input from file or stdin.
432 .TP
433 .B "\-\-key-file, \-d \fIname\fR"
434 Read the passphrase from file.
435
436 If the name given is "-", then the passphrase will be read from stdin. 
437 In this case, reading will not stop at newline characters.
438
439 With LUKS, passphrases supplied via \-\-key-file are always 
440 the existing passphrases requested by a command, except in 
441 the case of \fIluksFormat\fR where \-\-key-file is equivalent 
442 to the positional key file argument.
443
444 If you want to set a new passphrase via key file, you have to 
445 use a positional argument to \fIluksAddKey\fR.
446
447 See section \fBNOTES ON PASSPHRASE PROCESSING\fR for more information.
448 .TP
449 .B "\-\-keyfile-offset \fIvalue\fR"
450 Skip \fIvalue\fR bytes at the beginning of the key file.
451 Works with all commands that accepts key files.
452 .TP
453 .B "\-\-keyfile-size, \-l \fIvalue\fR"
454 Read a maximum of \fIvalue\fR bytes from the key file.
455 Default is to read the whole file up to the compiled-in
456 maximum that can be queried with \-\-help. Supplying more 
457 data than the compiled-in maximum aborts the operation.
458
459 This option is useful
460 to cut trailing newlines, for example. If \-\-keyfile-offset 
461 is also given, the size count starts after the offset.
462 Works with all commands that accepts key files.
463 .TP
464 .B "\-\-new-keyfile-offset \fIvalue\fR"
465 Skip \fIvalue\fR bytes at the start when
466 adding a new passphrase from key file with 
467 \fIluksAddKey\fR. 
468 .TP
469 .B "\-\-new-keyfile-size  \fIvalue\fR"
470 Read a maximum of \fIvalue\fR bytes when adding
471 a new passphrase from key file with \fIluksAddKey\fR. 
472 Default is to read the whole file up to the compiled-in 
473 maximum length that can be queried with \-\-help.
474 Supplying more than the compiled in maximum aborts the
475 operation.
476 When \-\-new-keyfile-offset is also given, reading starts
477 after the offset.
478 .TP
479 .B "\-\-master-key-file"
480 Use a master key stored in a file. 
481
482 For \fIluksFormat\fR this
483 allows creating a LUKS header with this specific
484 master key. If the master key was taken from an existing
485 LUKS header and all other parameters are the same,
486 then the new header decrypts the data encrypted with the
487 header the master key was taken from.
488
489 For \fIluksAddKey\fR this allows adding a new passphrase 
490 without having to know an exiting one.
491
492 For \fIluksOpen\fR this allows to open the LUKS device 
493 without giving a passphrase.
494 .TP
495 .B "\-\-dump-master-key"
496 For \fIluksDump\fR this option includes the master key in the displayed
497 information. Use with care, as the master key can be used to
498 bypass the passphrases, see also option \-\-master-key-file. 
499 .TP
500 .B "\-\-use-random"
501 .TP
502 .B "\-\-use-urandom"
503 For \fIluksFormat\fR these options define which kernel random number 
504 generator will be used to create the master key (which is a
505 long-term key).
506
507 See \fBNOTES ON RANDOM NUMBER GENERATORS\fR for more 
508 information. Use \fIcryptsetup \-\-help\fR
509 to show the compiled-in default random number generator.
510
511 \fBWARNING:\fR In a low-entropy situation (e.g. in an 
512 embedded system), both selections are problematic.
513 Using /dev/urandom can lead to weak keys.
514 Using /dev/random can block a long time, potentially 
515 forever, if not enough entropy can be harvested by 
516 the kernel.
517 .TP
518 .B "\-\-key-slot, \-S <0-7>"
519 For LUKS operations that add key material, this options allows you
520 to specify which key slot is selected for the new key.
521 This option can be used for \fIluksFormat\fR, 
522 and \fIluksAddKey\fR.
523 .br
524 In addition, for \fIluksOpen\fR, this option selects a
525 specific key-slot to compare the passphrase against.
526 If the given passphrase would only match a different key-slot,
527 the operation fails.            
528 .TP
529 .B "\-\-key-size, \-s <bits>"
530 Sets key size in bits. The argument has to be a multiple of 
531 8. The possible key-sizes are limited by the cipher and
532 mode used. 
533
534 See /proc/crypto for more information. Note that key-size 
535 in /proc/crypto is stated in bytes.
536
537 This option can be used for \fIcreate\fR or \fIluksFormat\fR. All 
538 other LUKS actions will use the key-size specified in the LUKS header.
539 Use \fIcryptsetup \-\-help\fR to show the compiled-in defaults.
540 .TP
541 .B "\-\-size, \-b <number of 512 byte sectors>"
542 Force the size of the underlying device in sectors of 512 bytes.
543 This option is only relevant for the \fIcreate\fR and \fIresize\fR 
544 actions. 
545 .TP
546 .B "\-\-offset, \-o <number of 512 byte sectors>"
547 Start offset in the backend device in 512-byte sectors.
548 This option is only relevant for the \fIcreate\fR and \fIloopaesOpen\fR 
549 actions.
550 .TP
551 .B "\-\-skip, \-p <number of 512 byte sectors>"
552 How many sectors of the encrypted data to skip at the beginning.
553 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
554
555 This is different from the \-\-offset options with respect to 
556 the sector numbers used in IV calculation.
557 Using \-\-offset will shift the IV calculation by the same negative amount.
558 Hence, if \-\-offset \fIn\fR, sector \fIn\fR will get a sector
559 number of \fI0\fR for the IV calculation.
560 Using \-\-skip causes sector \fIn\fR to also be the first sector
561 of the mapped device, but with its number for IV generation is \fIn\fR.
562 .TP
563 .B "\-\-readonly, \-r" 
564 set up a read-only mapping.
565 .TP
566 .B "\-\-shared"
567 Creates an additional mapping for one common 
568 ciphertext device. Arbitrary mappings are supported.
569 This option is only relevant for the 
570 \fIcreate\fR action. Use \-\-offset, \-\-size and \-\-skip to 
571 specify the mapped area.
572 .TP
573 .B "\-\-iter-time, \-i <number of milliseconds>"
574 The number of milliseconds to spend with PBKDF2 passphrase processing.
575 This option is only relevant for LUKS operations that set or change
576 passphrases, such as \fIluksFormat\fR or \fIluksAddKey\fR.
577 Specifying 0 as parameter selects the compiled-in default.
578 .TP
579 .B "\-\-batch-mode, \-q"
580 Suppresses all confirmation questions. Use with care! 
581
582 If the \-y option is not specified, this option also switches off
583 the passphrase verification for \fIluksFormat\fR.
584 .TP
585 .B "\-\-timeout, \-t <number of seconds>"
586 The number of seconds to wait before timeout on passphrase input
587 via terminal. It is relevant every time a passphrase is asked, 
588 for example for \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR 
589 or \fIluksAddKey\fR. It has no effect if used in conjunction 
590 with \-\-key-file. 
591 .br
592 This option is useful when the system 
593 should not stall if the user does not input a passphrase, 
594 e.g. during boot. The default is a value of 0 seconds,
595 which means to wait forever.  
596 .TP
597 .B "\-\-tries, \-T"
598 How often the input of the passphrase shall be retried. 
599 This option is relevant
600 every time a passphrase is asked, for example for 
601 \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
602 or \fIluksAddKey\fR. The default is 3 tries.
603 .TP
604 .B "\-\-align-payload <number of 512 byte sectors>"   
605 Align payload at a boundary of \fIvalue\fR 512-byte sectors.
606 This option is relevant for \fIluksFormat\fR.
607
608 If not specified, cryptsetup tries to use the topology info 
609 provided by kernel for the underlying device to get optimal alignment.
610 If not available (or the calculated value is a multiple of the default) 
611 data is by default aligned to a 1MiB boundary (i.e. 2048 512-byte sectors).
612
613 For a detached LUKS header this option specifies the offset on the
614 data device. See also the \-\-header option.
615 .TP
616 .B "\-\-uuid=\fIUUID\fR"
617 Use the provided \fIUUID\fR for the \fIluksFormat\fR command 
618 instead of generating new one. Changes the existing UUID when 
619 used with the \fIluksUUID\fR command.
620
621 The UUID must be provided in the standard UUID format,
622 e.g. 12345678-1234-1234-1234-123456789abc.
623 .TP
624 .B "\-\-allow-discards\fR"
625 Allow the use of discard (TRIM) requests for device.
626 This option is only relevant for \fIcreate\fR, \fIluksOpen\fR 
627 and \fIloopaesOpen\fR.
628
629 \fBWARNING:\fR This command can have a negative security impact
630 because it can make filesystem-level operations visible on
631 the physical device. For example, information leaking
632 filesystem type, used space, etc. may be extractable from
633 the physical device if the discarded blocks can be located
634 later. If in doubt, do no use it.
635
636 A kernel version of 3.1 or later is needed. For earlier kernels
637 this option is ignored.
638 .TP
639 .B "\-\-test-passphrase\fR"
640 Do not activate device, just verify passphrase.
641 This option is only relevant for \fIluksOpen\fR.
642 .TP
643 .B "\-\-header\fR <device or file storing the LUKS header>"
644 Use a detached (separated) metadata device or file where the 
645 LUKS header is stored. This options allows to store ciphertext
646 and LUKS header on different devices.
647
648 This option is only relevant for LUKS devices and can be 
649 used with the \fIluksFormat\fR, \fIluksOpen\fR, \fIluksSuspend\fR, 
650 \fIluksResume\fR, \fIstatus\fR and \fIresize\fR commands.
651
652 For \fIluksFormat\fR with a file name as argument to \-\-header,
653 it has to exist and be large enough to contain the LUKS header.
654 See the cryptsetup FAQ for header size calculation.
655
656 For other commands that change the LUKS header (e.g. \fIluksAddKey\fR),
657 specify the device or file with the LUKS header directly as the 
658 LUKS device.
659
660 If used with \fIluksFormat\fR, the \-\-align-payload option is taken
661 as absolute sector alignment on ciphertext device and can be zero.
662
663 \fBWARNING:\fR There is no check whether the ciphertext device specified
664 actually belongs to the header given. In fact you can specify an
665 arbitrary device as the ciphertext device for \fIluksOpen\fR
666 with the \-\-header option. Use with care.
667 .TP
668 .B "\-\-version"
669 Show the program version.
670 .SH RETURN CODES
671 Cryptsetup returns 0 on success and a non-zero value on error.
672
673 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
674 3 out of memory, 4 wrong device specified, 5 device already exists
675 or device is busy.
676 .SH NOTES ON PASSPHRASE PROCESSING FOR PLAIN MODE
677 Note that no iterated hashing or salting is done in plain mode.
678 If hashing is done, it is a single direct hash. This means that
679 low-entropy passphrases are easy to attack in plain mode.
680
681 \fBFrom a terminal\fR: The passphrase is read until the
682 first newline, i.e. '\\n'.
683 The input without the newline character is processed with
684 the default hash or the hash specified with \-\-hash.
685 The has result will be truncated to the key size 
686 of the used cipher, or the size specified with \-s.
687
688 \fBFrom stdin\fR: Reading will continue until a newline (or until
689 the maximum input size is reached), with the trailing newline 
690 stripped. The maximum input size is defined by the same 
691 compiled-in default as for the maximum key file size and  can 
692 be overwritten using \-\-keyfile-size option.
693
694 The data read will be hashed with the default hash
695 or the hash specified with \-\-hash.
696 The has result will be truncated to the key size
697 of the used cipher, or the size specified with \-s.
698
699 Note that if \-\-key-file=- is used for reading the key 
700 from stdin, trailing newlines are not stripped from the input. 
701
702 If "plain" is used as argument to \-\-hash, the input
703 data will not be hashed. Instead, it will be zero padded (if 
704 shorter than the key size) or truncated (if longer than the 
705 key size) and used directly as the binary key. This is useful for
706 directly specifying a binary key.
707 No warning will be given if the amount of data read from stdin is
708 less than the key size.
709
710 \fBFrom a key file\fR: It will be truncated to the 
711 key size of the used cipher or the size given by \-s
712 and directly used as binary key. 
713 if the key file is shorter than the key, cryptsetup
714 will quit with an error.
715
716 .SH NOTES ON PASSPHRASE PROCESSING FOR LUKS
717 LUKS uses PBKDF2 to protect against dictionary attacks 
718 and to give some protection to low-entropy passphrases
719 (see RFC 2898 and the cryptsetup FAQ).
720
721 \fBFrom a terminal\fR: The passphrase is read until the
722 first newline and then processed by PBKDF2 without 
723 the newline character.
724
725 \fBFrom stdin\fR:
726 LUKS will read passphrases from stdin up to the 
727 first newline character or the compiled-in
728 maximum key file length. If \-\-keyfile-size is 
729 given, it is ignored. 
730
731 \fBFrom key file\fR:
732 The complete keyfile is read up to the compiled-in
733 maximum size. Newline characters do not terminate the
734 input. The \-\-keyfile-size option can be used to limit
735 what is read.
736
737 \fBPassphrase processing\fR:
738 Whenever a passphrase is added to a LUKS header (luksAddKey, luksFormat),
739 the user may specify how much the time the passphrase processing
740 should consume. The time is used to determine the iteration count 
741 for PBKDF2 and higher times will offer better protection for
742 low-entropy passphrases, but luksOpen will take longer to 
743 complete. For passphrases that have entropy higher than the
744 used key length, higher iteration times will not increase security.
745
746 The default setting of one second is sufficient for most
747 practical cases. The only exception is a low-entropy
748 passphrase used on a slow device.
749 .SH INCOHERENT BEHAVIOR FOR INVALID PASSPHRASES/KEYS
750 LUKS checks for a valid passphrase when an encrypted partition
751 is unlocked. The behavior of plain dm-crypt is different.
752 It will always decrypt with the passphrase given. If the
753 given passphrase is wrong, the device mapped by plain
754 dm-crypt will essentially still contain encrypted data and 
755 will be unreadable.
756 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
757 The available combinations of ciphers, modes, hashes and key sizes
758 depend on kernel support. See /proc/crypto for a list of available
759 options. You might need to load additional kernel crypto modules
760 in order to get more options.
761
762 For the \-\-hash option, if the crypto backend is libgcrypt, 
763 then all algorithms supported by the gcrypt library are available.
764 For other crypto backends some algorithms may be missing.
765 .SH NOTES ON PASSPHRASES
766 Mathematics can't be bribed. Make sure you keep your passphrases safe.
767 There are a few nice tricks for constructing a fallback, when suddenly
768 out of the blue, your brain refuses to cooperate.
769 These fallbacks need LUKS, as it's only possible with LUKS
770 to have multiple passphrases. Still, if your attacker model does
771 not prevent it, storing your passphrase in a sealed envelope somewhere 
772 may be a good idea as well.
773 .SH NOTES ON RANDOM NUMBER GENERATORS
774 Random Number Generators (RNG) used in cryptsetup are always the 
775 kernel RNGs without any modifications or additions to data stream 
776 produced.
777
778 There are two types of randomness cryptsetup/LUKS needs. One type 
779 (which always uses /dev/urandom) is used for salts, the AF splitter 
780 and for wiping deleted keyslots.
781
782 The second type is used for the volume (master) key. You can switch 
783 between using /dev/random and /dev/urandom  here, see 
784 \fP\-\-use-random\fR and \fP\-\-use-urandom\fR
785 options. Using /dev/random on a system without enough entropy sources
786 can cause \fPluksFormat\fR to block until the requested amount of 
787 random data is gathered. In a low-entropy situation (embedded system),
788 this can take a very long time and potentially forever. At the same
789 time, using /dev/urandom in a low-entropy situation will 
790 produce low-quality keys. This is a serious problem, but solving
791 it is out of scope for a mere man-page.
792 See \fPurandom(4)\fR for more information.
793 .SH NOTES ON LOOPBACK DEVICE USE
794 Cryptsetup is usually used directly on a block device (disk 
795 partition or LVM volume). However, if the device argument is a 
796 file, cryptsetup tries to allocate a loopback device
797 and map it into this file. This mode requires Linux kernel 2.6.25 
798 or more recent which supports the loop autoclear flag (loop device is 
799 cleared on last close automatically). Of course, you can
800 always map a file to a loop-device manually. See the 
801 cryptsetup FAQ for an example.
802
803 When device mapping is active, you can see the loop backing file in 
804 the status command output. Also see losetup(8).
805 .SH DEPRECATED ACTIONS
806 .PP
807 The \fIreload\fR action is no longer supported.
808 Please use \fIdmsetup(8)\fR if you need to
809 directly manipulate with the device mapping table.
810 .PP
811 The \fIluksDelKey\fR was replaced with \fIluksKillSlot\fR.
812 .PP
813 .SH REPORTING BUGS
814 Report bugs, including ones in the documentation, on
815 the cryptsetup mailing list at <dm-crypt@saout.de> 
816 or in the 'Issues' section on LUKS website.
817 Please attach the output of the failed command with the 
818 \-\-debug option added.
819 .SH AUTHORS
820 cryptsetup originally written by Christophe Saout <christophe@saout.de>
821 .br
822 The LUKS extensions and original man page were written by 
823 Clemens Fruhwirth <clemens@endorphin.org>.
824 .br
825 Man page extensions by Milan Broz <gmazyland@gmail.com>.
826 .br
827 Man page rewrite and extension by Arno Wagner <arno@wagner.name>. 
828 .SH COPYRIGHT
829 Copyright \(co 2004 Christophe Saout
830 .br
831 Copyright \(co 2004-2006 Clemens Fruhwirth
832 .br
833 Copyright \(co 2009-2012 Red Hat, Inc.
834 .br
835 Copyright \(co 2012 Arno Wagner
836
837 This is free software; see the source for copying conditions.  There is NO
838 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
839 .SH SEE ALSO
840 The LUKS website at \fBhttp://code.google.com/p/cryptsetup/\fR
841
842 The cryptsetup FAQ, contained in the distribution package and
843 online at 
844 \fBhttp://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions\fR
845
846 The cryptsetup mailing list and list archive, see FAQ entry 1.6.
847
848 The LUKS on-disk format specification available at
849 \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR