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