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