Back to home page

OSCL-LXR

 
 

    


0001 ========
0002 dm-crypt
0003 ========
0004 
0005 Device-Mapper's "crypt" target provides transparent encryption of block devices
0006 using the kernel crypto API.
0007 
0008 For a more detailed description of supported parameters see:
0009 https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt
0010 
0011 Parameters::
0012 
0013               <cipher> <key> <iv_offset> <device path> \
0014               <offset> [<#opt_params> <opt_params>]
0015 
0016 <cipher>
0017     Encryption cipher, encryption mode and Initial Vector (IV) generator.
0018 
0019     The cipher specifications format is::
0020 
0021        cipher[:keycount]-chainmode-ivmode[:ivopts]
0022 
0023     Examples::
0024 
0025        aes-cbc-essiv:sha256
0026        aes-xts-plain64
0027        serpent-xts-plain64
0028 
0029     Cipher format also supports direct specification with kernel crypt API
0030     format (selected by capi: prefix). The IV specification is the same
0031     as for the first format type.
0032     This format is mainly used for specification of authenticated modes.
0033 
0034     The crypto API cipher specifications format is::
0035 
0036         capi:cipher_api_spec-ivmode[:ivopts]
0037 
0038     Examples::
0039 
0040         capi:cbc(aes)-essiv:sha256
0041         capi:xts(aes)-plain64
0042 
0043     Examples of authenticated modes::
0044 
0045         capi:gcm(aes)-random
0046         capi:authenc(hmac(sha256),xts(aes))-random
0047         capi:rfc7539(chacha20,poly1305)-random
0048 
0049     The /proc/crypto contains a list of currently loaded crypto modes.
0050 
0051 <key>
0052     Key used for encryption. It is encoded either as a hexadecimal number
0053     or it can be passed as <key_string> prefixed with single colon
0054     character (':') for keys residing in kernel keyring service.
0055     You can only use key sizes that are valid for the selected cipher
0056     in combination with the selected iv mode.
0057     Note that for some iv modes the key string can contain additional
0058     keys (for example IV seed) so the key contains more parts concatenated
0059     into a single string.
0060 
0061 <key_string>
0062     The kernel keyring key is identified by string in following format:
0063     <key_size>:<key_type>:<key_description>.
0064 
0065 <key_size>
0066     The encryption key size in bytes. The kernel key payload size must match
0067     the value passed in <key_size>.
0068 
0069 <key_type>
0070     Either 'logon', 'user', 'encrypted' or 'trusted' kernel key type.
0071 
0072 <key_description>
0073     The kernel keyring key description crypt target should look for
0074     when loading key of <key_type>.
0075 
0076 <keycount>
0077     Multi-key compatibility mode. You can define <keycount> keys and
0078     then sectors are encrypted according to their offsets (sector 0 uses key0;
0079     sector 1 uses key1 etc.).  <keycount> must be a power of two.
0080 
0081 <iv_offset>
0082     The IV offset is a sector count that is added to the sector number
0083     before creating the IV.
0084 
0085 <device path>
0086     This is the device that is going to be used as backend and contains the
0087     encrypted data.  You can specify it as a path like /dev/xxx or a device
0088     number <major>:<minor>.
0089 
0090 <offset>
0091     Starting sector within the device where the encrypted data begins.
0092 
0093 <#opt_params>
0094     Number of optional parameters. If there are no optional parameters,
0095     the optional parameters section can be skipped or #opt_params can be zero.
0096     Otherwise #opt_params is the number of following arguments.
0097 
0098     Example of optional parameters section:
0099         3 allow_discards same_cpu_crypt submit_from_crypt_cpus
0100 
0101 allow_discards
0102     Block discard requests (a.k.a. TRIM) are passed through the crypt device.
0103     The default is to ignore discard requests.
0104 
0105     WARNING: Assess the specific security risks carefully before enabling this
0106     option.  For example, allowing discards on encrypted devices may lead to
0107     the leak of information about the ciphertext device (filesystem type,
0108     used space etc.) if the discarded blocks can be located easily on the
0109     device later.
0110 
0111 same_cpu_crypt
0112     Perform encryption using the same cpu that IO was submitted on.
0113     The default is to use an unbound workqueue so that encryption work
0114     is automatically balanced between available CPUs.
0115 
0116 submit_from_crypt_cpus
0117     Disable offloading writes to a separate thread after encryption.
0118     There are some situations where offloading write bios from the
0119     encryption threads to a single thread degrades performance
0120     significantly.  The default is to offload write bios to the same
0121     thread because it benefits CFQ to have writes submitted using the
0122     same context.
0123 
0124 no_read_workqueue
0125     Bypass dm-crypt internal workqueue and process read requests synchronously.
0126 
0127 no_write_workqueue
0128     Bypass dm-crypt internal workqueue and process write requests synchronously.
0129     This option is automatically enabled for host-managed zoned block devices
0130     (e.g. host-managed SMR hard-disks).
0131 
0132 integrity:<bytes>:<type>
0133     The device requires additional <bytes> metadata per-sector stored
0134     in per-bio integrity structure. This metadata must by provided
0135     by underlying dm-integrity target.
0136 
0137     The <type> can be "none" if metadata is used only for persistent IV.
0138 
0139     For Authenticated Encryption with Additional Data (AEAD)
0140     the <type> is "aead". An AEAD mode additionally calculates and verifies
0141     integrity for the encrypted device. The additional space is then
0142     used for storing authentication tag (and persistent IV if needed).
0143 
0144 sector_size:<bytes>
0145     Use <bytes> as the encryption unit instead of 512 bytes sectors.
0146     This option can be in range 512 - 4096 bytes and must be power of two.
0147     Virtual device will announce this size as a minimal IO and logical sector.
0148 
0149 iv_large_sectors
0150    IV generators will use sector number counted in <sector_size> units
0151    instead of default 512 bytes sectors.
0152 
0153    For example, if <sector_size> is 4096 bytes, plain64 IV for the second
0154    sector will be 8 (without flag) and 1 if iv_large_sectors is present.
0155    The <iv_offset> must be multiple of <sector_size> (in 512 bytes units)
0156    if this flag is specified.
0157 
0158 Example scripts
0159 ===============
0160 LUKS (Linux Unified Key Setup) is now the preferred way to set up disk
0161 encryption with dm-crypt using the 'cryptsetup' utility, see
0162 https://gitlab.com/cryptsetup/cryptsetup
0163 
0164 ::
0165 
0166         #!/bin/sh
0167         # Create a crypt device using dmsetup
0168         dmsetup create crypt1 --table "0 `blockdev --getsz $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
0169 
0170 ::
0171 
0172         #!/bin/sh
0173         # Create a crypt device using dmsetup when encryption key is stored in keyring service
0174         dmsetup create crypt2 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 :32:logon:my_prefix:my_key 0 $1 0"
0175 
0176 ::
0177 
0178         #!/bin/sh
0179         # Create a crypt device using cryptsetup and LUKS header with default cipher
0180         cryptsetup luksFormat $1
0181         cryptsetup luksOpen $1 crypt1