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