5 Device-Mapper's "crypt" target provides transparent encryption of block devices
6 using the kernel crypto API.
8 For a more detailed description of supported parameters see:
9 https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt
13 <cipher> <key> <iv_offset> <device path> \
14 <offset> [<#opt_params> <opt_params>]
17 Encryption cipher, encryption mode and Initial Vector (IV) generator.
19 The cipher specifications format is::
21 cipher[:keycount]-chainmode-ivmode[:ivopts]
29 Cipher format also supports direct specification with kernel crypt API
30 format (selected by capi: prefix). The IV specification is the same
31 as for the first format type.
32 This format is mainly used for specification of authenticated modes.
34 The crypto API cipher specifications format is::
36 capi:cipher_api_spec-ivmode[:ivopts]
40 capi:cbc(aes)-essiv:sha256
43 Examples of authenticated modes::
46 capi:authenc(hmac(sha256),xts(aes))-random
47 capi:rfc7539(chacha20,poly1305)-random
49 The /proc/crypto contains a list of curently loaded crypto modes.
52 Key used for encryption. It is encoded either as a hexadecimal number
53 or it can be passed as <key_string> prefixed with single colon
54 character (':') for keys residing in kernel keyring service.
55 You can only use key sizes that are valid for the selected cipher
56 in combination with the selected iv mode.
57 Note that for some iv modes the key string can contain additional
58 keys (for example IV seed) so the key contains more parts concatenated
62 The kernel keyring key is identified by string in following format:
63 <key_size>:<key_type>:<key_description>.
66 The encryption key size in bytes. The kernel key payload size must match
67 the value passed in <key_size>.
70 Either 'logon' or 'user' kernel key type.
73 The kernel keyring key description crypt target should look for
74 when loading key of <key_type>.
77 Multi-key compatibility mode. You can define <keycount> keys and
78 then sectors are encrypted according to their offsets (sector 0 uses key0;
79 sector 1 uses key1 etc.). <keycount> must be a power of two.
82 The IV offset is a sector count that is added to the sector number
83 before creating the IV.
86 This is the device that is going to be used as backend and contains the
87 encrypted data. You can specify it as a path like /dev/xxx or a device
88 number <major>:<minor>.
91 Starting sector within the device where the encrypted data begins.
94 Number of optional parameters. If there are no optional parameters,
95 the optional paramaters section can be skipped or #opt_params can be zero.
96 Otherwise #opt_params is the number of following arguments.
98 Example of optional parameters section:
99 3 allow_discards same_cpu_crypt submit_from_crypt_cpus
102 Block discard requests (a.k.a. TRIM) are passed through the crypt device.
103 The default is to ignore discard requests.
105 WARNING: Assess the specific security risks carefully before enabling this
106 option. For example, allowing discards on encrypted devices may lead to
107 the leak of information about the ciphertext device (filesystem type,
108 used space etc.) if the discarded blocks can be located easily on the
112 Perform encryption using the same cpu that IO was submitted on.
113 The default is to use an unbound workqueue so that encryption work
114 is automatically balanced between available CPUs.
116 submit_from_crypt_cpus
117 Disable offloading writes to a separate thread after encryption.
118 There are some situations where offloading write bios from the
119 encryption threads to a single thread degrades performance
120 significantly. The default is to offload write bios to the same
121 thread because it benefits CFQ to have writes submitted using the
124 integrity:<bytes>:<type>
125 The device requires additional <bytes> metadata per-sector stored
126 in per-bio integrity structure. This metadata must by provided
127 by underlying dm-integrity target.
129 The <type> can be "none" if metadata is used only for persistent IV.
131 For Authenticated Encryption with Additional Data (AEAD)
132 the <type> is "aead". An AEAD mode additionally calculates and verifies
133 integrity for the encrypted device. The additional space is then
134 used for storing authentication tag (and persistent IV if needed).
137 Use <bytes> as the encryption unit instead of 512 bytes sectors.
138 This option can be in range 512 - 4096 bytes and must be power of two.
139 Virtual device will announce this size as a minimal IO and logical sector.
142 IV generators will use sector number counted in <sector_size> units
143 instead of default 512 bytes sectors.
145 For example, if <sector_size> is 4096 bytes, plain64 IV for the second
146 sector will be 8 (without flag) and 1 if iv_large_sectors is present.
147 The <iv_offset> must be multiple of <sector_size> (in 512 bytes units)
148 if this flag is specified.
152 LUKS (Linux Unified Key Setup) is now the preferred way to set up disk
153 encryption with dm-crypt using the 'cryptsetup' utility, see
154 https://gitlab.com/cryptsetup/cryptsetup
159 # Create a crypt device using dmsetup
160 dmsetup create crypt1 --table "0 `blockdev --getsz $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
165 # Create a crypt device using dmsetup when encryption key is stored in keyring service
166 dmsetup create crypt2 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 :32:logon:my_prefix:my_key 0 $1 0"
171 # Create a crypt device using cryptsetup and LUKS header with default cipher
172 cryptsetup luksFormat $1
173 cryptsetup luksOpen $1 crypt1