3ee55b59ad36f3529a34b92bf5a11488bc5957c5
[platform/upstream/cryptsetup.git] / man / cryptsetup.8
1 .TH CRYPTSETUP "8" "March 2005" "cryptsetup" "Maintenance Commands"
2 .SH NAME
3 cryptsetup - setup cryptographic volumes for dm-crypt (including LUKS extension)
4 .SH SYNOPSIS
5
6 .B cryptsetup <options> <action> <action args>
7
8 .SH DESCRIPTION
9 .\" Add any additional description here
10 .PP
11 cryptsetup is used to conveniently setup dm-crypt managed device-mapper mappings. For basic dm-crypt mappings, there are five operations.
12 .SH ACTIONS
13 These strings are valid for \fB<action>\fR, followed by their \fB<action args>\fR:
14
15 \fIcreate\fR <name> <device>
16 .IP
17 creates a mapping with <name> backed by device <device>.
18 <options> can be [\-\-hash, \-\-cipher, \-\-verify-passphrase, \-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-readonly]
19 .PP
20 \fIremove\fR <name>
21 .IP
22 removes an existing mapping <name>. No options.
23 .PP
24 \fIstatus\fR <name>
25 .IP
26 reports the status for the mapping <name>. No options.
27 .PP
28 \fIresize\fR <name>
29 .IP
30 resizes an active mapping <name>.
31
32 If \-\-size (in sectors) is not specified, the size of the underlying block device is used.
33 .PP
34 .br
35 .SH LUKS EXTENSION
36
37 LUKS, Linux Unified Key Setup, is a standard for hard disk encryption. It standardizes a partition header, as well as the format of the bulk data. LUKS can manage multiple passwords, that can be revoked effectively and that are protected against dictionary attacks with PBKDF2. 
38
39 These are valid LUKS actions:
40
41 \fIluksFormat\fR <device> [<key file>]
42 .IP
43 initializes a LUKS partition and sets the initial key, either via prompting or via <key file>.
44 <options> can be [\-\-cipher, \-\-verify-passphrase, \-\-key-size, \-\-key-slot].
45 .PP
46 \fIluksOpen\fR <device> <name>
47 .IP
48 opens the LUKS partition <device> and sets up a mapping <name> after successful verification of the supplied key material (either via key file by \-\-key-file, or via prompting).
49 <options> can be [\-\-key-file, \-\-readonly].
50 .PP
51 \fIluksClose\fR <name>
52 .IP
53 identical to \fIremove\fR.
54 .PP
55 \fIluksSuspend\fR <name>
56 .IP
57 suspends active device (all IO operations are frozen) and wipes encryption key from kernel. Kernel version 2.6.19 or later is required.
58
59 After that operation you have to use \fIluksResume\fR to reinstate encryption key (and resume device) or \fIluksClose\fR to remove mapped device.
60
61 \fBWARNING:\fR never try to suspend device where is the cryptsetup binary itself.
62 .PP
63 \fIluksResume\fR <name>
64 .IP
65 Resumes suspended device and reinstates encryption key. You will need provide passphrase identical to \fIluksOpen\fR command (using prompting or key file).
66 .PP
67 \fIluksAddKey\fR <device> [<new key file>]
68 .IP
69 add a new key file/passphrase. An existing passphrase or key file (via \-\-key-file) must be supplied. The key file with the new material is supplied as a positional argument. <options> can be [\-\-key-file, \-\-key-slot].
70 .PP
71 \fIluksRemoveKey\fR <device> [<key file>] 
72 .IP
73 remove supplied key or key file from LUKS device
74 .PP
75 \fIluksKillSlot\fR <device> <key slot number>
76 .IP
77 wipe key with number <key slot> from LUKS device. A remaining passphrase or key file (via \-\-key-file) must be supplied. <options> can be [\-\-key-file].
78 .PP
79 \fIluksDelKey\fR <device> <key slot number>
80 .IP
81 identical to luksKillSlot, but deprecated action name.
82 .PP
83 \fIluksUUID\fR <device>
84 .IP
85 print UUID, if <device> has a LUKS header. No options.
86 .PP
87 \fIisLuks\fR <device>
88 .IP
89 returns true, if <device> is a LUKS partition. Otherwise, false. No options.
90 .PP
91 \fIluksDump\fR <device>
92 .IP
93 dumps the header information of a LUKS partition. No options.
94 .PP
95 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
96 .IP
97 Stores binary backup of LUKS header and keyslot areas.
98
99 \fBWARNING:\fR Please note that with this backup file (and old passphrase knowledge) you can decrypt data even if old passphrase was wiped from real device.
100
101 Also note that anti-forensic splitter is not used during manipulation with backup file.
102 .PP
103 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
104 .IP
105
106 Restores binary backup of LUKS header and keyslot areas from specified file.
107
108 \fBWARNING:\fR All the keyslot areas are overwritten, only active keyslots form backup file are available after issuing this command.
109
110 This command allows restoring header if device do not contain LUKS header or if the master key size and data offset in LUKS header on device match the backup file.
111 .PP
112
113 For more information about LUKS, see \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR
114
115 .SH OPTIONS
116 .TP
117 .B "\-\-hash, \-h"
118 For \fIcreate\fR action specifies hash to use for password hashing.
119
120 For \fIluksFormat\fR action specifies hash used in LUKS key setup scheme and volume key digest.
121
122 \fBWARNING:\fR setting hash other than \fBsha1\fR causes LUKS device incompatible with older version of cryptsetup.
123
124 The hash string is passed to libgcrypt, so all hashes accepted by gcrypt are supported.
125 Default is set during compilation, compatible values with old version of cryptsetup are
126 \fB"ripemd160"\fR for \fIcreate\fR action and \fB"sha1"\fR for \fIluksFormat\fR.
127
128 Use \fIcryptsetup --help\fR to show defaults.
129 .TP
130 .B "\-\-cipher, \-c"
131 set cipher specification string.
132
133 Default mode is configurable during compilation,
134 you can see compiled-in default using \fIcryptsetup --help\fR.
135 If not changed, the default is for plain dm-crypt and LUKS mappings
136 "aes-cbc-essiv:sha256".
137
138 For pre-2.6.10 kernels, use "aes-plain" as they don't understand
139 the new cipher spec strings. To use ESSIV, use "aes-cbc-essiv:sha256".
140
141 For XTS mode, kernel version 2.6.24 or more recent is required.
142 Use "aes-xts-plain" cipher specification and set key size to 256 (or 512) bits (see \-s option).
143 .TP
144 .B "\-\-verify-passphrase, \-y"
145 query for passwords twice. Useful when creating a (regular) mapping for the first time, or when running \fIluksFormat\fR.
146 .TP
147 .B "\-\-key-file, \-d"
148 use file as key material. With LUKS, key material supplied in key files via \-d are always used for existing passphrases. If you want to set a new key via a key file, you have to use a positional arg to \fIluksFormat\fR or \fIluksAddKey\fR.
149
150 If the key file is "-", stdin will be used. This is different from how cryptsetup usually reads from stdin. See section \fBNOTES ON PASSWORD PROCESSING\fR for more information.
151 .TP
152 .B "\-\-master-key-file"
153 Use pre-generated master key stored in file. For \fIluksFormat\fR it allows LUKS header reformatting with the same master key (if all other parameters are the same existing encrypted data remains intact).
154
155 For \fIluksAddKey\fR it allows adding new passphrase with only master key knowledge.
156 .TP
157 .B "\-\-key-slot, \-S"
158 For LUKS operations that add key material, this options allows to you specify which key slot is selected for the new key. This option can be used for \fIluksFormat\fR and \fIluksAddKey\fR.
159 .TP
160 .B "\-\-key-size, \-s"
161 set key size in bits.
162
163 Has to be a multiple of 8 bits. The key size is limited by the used cipher. See output of /proc/crypto for more information.
164 Can be used for \fIcreate\fR or \fIluksFormat\fR, all other LUKS actions will use key-size specified by the LUKS header.
165 Default is set during compilation, if not changed it is 256 bits.
166
167 Use \fIcryptsetup --help\fR to show defaults.
168
169 For \fIluksOpen\fR this option specifies number of bits read from the key-file (default is exhaustive read from key-file).
170 .TP
171 .B "\-\-size, \-b"
172 force the size of the underlying device in sectors.
173 This option is only relevant for \fIcreate\fR and \fIresize\fR action.
174 .TP
175 .B "\-\-offset, \-o"
176 start offset in the backend device.
177 This option is only relevant for \fIcreate\fR action.
178 .TP
179 .B "\-\-skip, \-p"
180 how many sectors of the encrypted data to skip at the beginning. This is different from the \-\-offset options with respect to IV calculations. Using \-\-offset will shift the IV calculation by the same negative amount. Hence, if \-\-offset \fIn\fR, sector \fIn\fR will be the first sector on the mapping with IV \fI0\fR. Using \-\-skip would have resulted in sector \fIn\fR being the first sector also, but with IV \fIn\fR.
181 This option is only relevant for \fIcreate\fR action.
182 .TP
183 .B "\-\-readonly"
184 set up a read-only mapping.
185 .TP
186 .B "\-\-iter-time, \-i"
187 The number of milliseconds to spend with PBKDF2 password processing. This option is only relevant to the LUKS operations as \fIluksFormat\fR or \fIluksAddKey\fR.
188 .TP
189 .B "\-\-batch-mode, \-q"
190 Do not ask for confirmation. Use with care! This option is only relevant for \fIluksFormat\fR, \fIluksAddKey\fR, \fIluksRemoveKey\fR or \fIluksKillSlot\fR.
191 .TP
192 .B "\-\-timeout, \-t"
193 The number of seconds to wait before timeout. This option is relevant every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR or \fIluksAddKey\fR. It has no effect if used in conjunction with \-\-key-file.
194 .TP
195 .B "\-\-tries, \-T"
196 How often the input of the passphrase shall be retried. This option is relevant every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR or \fIluksAddKey\fR. The default is 3 tries.
197 .TP
198 .B "\-\-align-payload=\fIvalue\fR"
199 Align payload at a boundary of \fIvalue\fR 512-byte sectors. This option is relevant for \fIluksFormat\fR.  If your block device lives on a RAID, it is
200 useful to align the filesystem at full stripe boundaries so it can take advantage of the RAID's geometry.  See for instance the sunit and swidth options
201 in the mkfs.xfs manual page. By default, the payload is aligned at an 8 sector (4096 byte) boundary.
202 .TP
203 .B "\-\-version"
204 Show the version.
205
206 .SH NOTES ON PASSWORD PROCESSING
207 \fIFrom a file descriptor or a terminal\fR: Password processing is new-line sensitive, meaning the reading will stop after encountering \\n. It will process the read material (without newline) with the default hash or the hash given by \-\-hash. After hashing, it will be cropped to the key size given by \-s.
208
209 \fIFrom stdin\fR: Reading will continue until EOF (so using e.g. /dev/random as stdin will not work), with the trailing newline stripped. After that the read data will be hashed with the default hash or the hash given by \-\-hash and the result will be cropped to the keysize given by \-s. If "plain" is used as an argument to the hash option, the input data will not be hashed.
210 Instead, it will be zero padded (if shorter than the keysize) or truncated (if longer than the keysize) and used directly as the key. No warning will be given if the amount of data read from stdin is less than the keysize.
211
212 \fIFrom a key file\fR: It will be cropped to the size given by \-s. If there is insufficient key material in the key file, cryptsetup will quit with an error.
213
214 If \-\-key-file=- is used for reading the key from stdin, no trailing newline is stripped from the input. Without that option, cryptsetup strips trailing newlines from stdin input.
215 .SH NOTES ON PASSWORD PROCESSING FOR LUKS
216 LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898). 
217
218 LUKS will always do an exhaustive password reading. Hence, password can not be read from /dev/random, /dev/zero or any other stream that does not terminate.
219
220 LUKS saves the processing options when a password is set to the respective key slot.
221 Therefore, no options can be given to luksOpen. 
222 For any password creation action (luksAddKey, or luksFormat), the user may specify how much the time the password processing should consume.
223 Increasing the time will lead to a more secure password, but also will take luksOpen longer to complete. The default setting of one second is sufficient for good security.
224 .SH INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS
225 LUKS checks for a valid password or key when an encrypted partition is unlocked. Thus the luksOpen action fails with invalid password or key, contrary to the plain dm-crypt create action.
226
227 Please also be sure that you are using the same keyboard and language setting as during device format.
228 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
229 The available combinations of ciphers, modes, hashes and key sizes depend on kernel support. See /proc/crypto for a list of available options. You might need to load additional kernel crypto modules in order to get more options.
230
231 For \-\-hash option all algorithms supported by gcrypt library are available.
232 .SH NOTES ON PASSWORDS
233 Mathematics can't be bribed. Make sure you keep your passwords safe. There are a few nice tricks for constructing a fallback, when suddenly out of (or after being) blue, your brain refuses to cooperate. These fallbacks are possible with LUKS, as it's only possible with LUKS to have multiple passwords.
234 .SH AUTHORS
235 cryptsetup is written by Christophe Saout <christophe@saout.de>
236 .br
237 LUKS extensions, and man page by Clemens Fruhwirth <clemens@endorphin.org>
238 .SH "COMPATABILITY WITH OLD SUSE TWOFISH PARTITIONS"
239 To read images created with SuSE Linux 9.2's loop_fish2 use \-\-cipher
240 twofish-cbc-null \-s 256 \-h sha512, for images created with even
241 older SuSE Linux use \-\-cipher twofish-cbc-null \-s 192 \-h
242 ripemd160:20
243
244 .SH DEPRECATED ACTIONS
245 .PP
246 \fIreload\fR <name> <device>
247 .IP
248 modifies an active mapping <name>. Same options as for
249 create. 
250 .B WARNING:
251 Do not use this for LUKS devices, as the semantics
252 are identical to the create action, which are totally incompatible
253 with the LUKS key setup. 
254
255 This action is deprected because it proved to be rarely useful.  It is
256 uncommon to change the underlying device, key, or offset on the
257 fly. In case, you really want to do this, you certainly know what you
258 are doing and then you are probably better off with the swiss knive
259 tool for device mapper, namely dmsetup. It provides you with the same
260 functionality, see dmsetup reload.
261 .PP
262 \fIluksDelKey\fR <device> <key slot number>
263 .IP
264 identical to luksKillSlot, but deprecated action name. This option was
265 renamed, as we introduced luksRemoveKey, a softer method for disabling
266 password slots. To make a clear distinction that luksDelKey was more brutal than luksRemoveKey
267 .PP
268 \fI\-\-non-exclusive\fR
269 .IP
270 This option is ignored. Non-exclusive access to the same block device
271 can cause data corruption thus this mode is no longer supported by cryptsetup.
272
273 .SH "REPORTING BUGS"
274 Report bugs to <dm-crypt@saout.de>.
275 .SH COPYRIGHT
276 Copyright \(co 2004 Christophe Saout
277 .br
278 Copyright \(co 2004-2006 Clemens Fruhwirth
279 .br
280 Copyright \(co 2009 Red Hat, Inc.
281
282 This is free software; see the source for copying conditions.  There is NO
283 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
284 .SH "SEE ALSO"
285
286 dm-crypt website, \fBhttp://www.saout.de/misc/dm-crypt/\fR
287
288 LUKS website, \fBhttp://code.google.com/p/cryptsetup/\fR
289
290 dm-crypt TWiki, \fBhttp://www.saout.de/tikiwiki/tiki-index.php\fR