Disk encryption theory

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Disk encryption is a special case of data at rest protection when the storage media is a sector-addressable device (e.g., a hard disk). This article presents cryptographic aspects of the problem. For discussion of different software packages and hardware devices devoted to this problem see disk encryption software and disk encryption hardware.

Problem definition[edit]

Disk encryption methods aim to provide three distinct properties:

  1. The data on the disk should remain confidential
  2. Data retrieval and storage should both be fast operations, no matter where on the disk the data is stored.
  3. The encryption method should not waste disk space (i.e., the amount of storage used for encrypted data should not be significantly larger than the size of plaintext)

The first property requires defining an adversary from whom the data is being kept confidential. The strongest adversaries studied in the field of disk encryption have these abilities:

  1. they can read the raw contents of the disk at any time;
  2. they can request the disk to encrypt and store arbitrary files of their choosing;
  3. and they can modify unused sectors on the disk and then request their decryption.

A method provides good confidentiality if the only information such an adversary can determine over time is whether the data in a sector has or has not changed since the last time they looked.

The second property requires dividing the disk into several sectors, usually 512 bytes (4,096 bits) long, which are encrypted and decrypted independently of each other. In turn, if the data is to stay confidential, the encryption method must be tweakable; no two sectors should be processed in exactly the same way. Otherwise, the adversary could decrypt any sector of the disk by copying it to an unused sector of the disk and requesting its decryption.

The third property is generally non-controversial. However, it indirectly prohibits the use of stream ciphers, since stream ciphers require, for their security, that the same initial state not be used twice (which would be the case if a sector is updated with different data); thus this would require an encryption method to store separate initial states for every sector on disk—seemingly a clear waste of space. The alternative, a block cipher, is limited to a certain block size (usually 128 or 256 bits). Because of this, disk encryption chiefly studies chaining modes, which expand the encryption block length to cover a whole disk sector. The considerations already listed make several well-known chaining modes unsuitable: ECB mode, which cannot be tweaked, and modes that turn block ciphers into stream ciphers, such as the CTR mode.

These three properties do not provide any assurance of disk integrity; that is, they don't tell you whether an adversary has been modifying your ciphertext. In part, this is because an absolute assurance of disk integrity is impossible: no matter what, an adversary could always revert the entire disk to a prior state, circumventing any such checks. If some non-absolute level of disk integrity is desired, it can be achieved within the encrypted disk on a file-by-file basis using message authentication codes.

Block cipher-based modes[edit]

Like most encryption schemes, block cipher-based disk encryption makes use of modes of operation, which allow encrypting larger amounts of data than the ciphers' block-size (typically 128 bits). Modes are therefore rules on how to repeatedly apply the ciphers' single-block operations.

Cipher-block chaining (CBC)[edit]

Main article: Cipher-block chaining

Cipher block chaining (CBC) is a common chaining mode in which the previous block's ciphertext is xored with the current block's plaintext before encryption:

C_i = E_K(C_{i-1} \oplus P_i)

Since there isn't a "previous block's ciphertext" for the first block, an initialization vector (IV) must be used as \scriptstyle C_{-1}. This, in turn, makes CBC tweakable in some ways.

CBC suffers from some problems. For example, if the IVs are predictable, then an adversary may leave a "watermark" on the disk, i.e., store a specially created file or combination of files which is identifiable even after encryption. The exact method of constructing the watermark depends on the exact function providing the IVs, but the general recipe is to create two encrypted sectors which have identical first blocks \scriptstyle b_1 and \scriptstyle b_2; these two are then related to each other by \scriptstyle b_1 \,\oplus\, IV_1 \;=\; b_2 \,\oplus\, IV_2. Thus the encryption of  \scriptstyle b_1 is identical to the encryption of  \scriptstyle b_2 , leaving a watermark on the disk. The exact pattern of "same-different-same-different" on disk can then be altered to make the watermark unique to a given file.

To protect against the watermarking attack, a cipher or a hash function is used to generate the IVs from the key and the current sector number, so that an adversary cannot predict the IVs. In particular, the ESSIV approach uses a block cipher in CTR mode to generate the IVs.

Encrypted salt-sector initialization vector (ESSIV)[edit]

ESSIV[1] is a method for generating initialization vectors for block encryption to use in disk encryption. The usual methods for generating IVs are predictable sequences of numbers based on, for example, time stamp or sector number, and permits certain attacks such as a watermarking attack. ESSIV prevents such attacks by generating IVs from a combination of the sector number SN with the hash of the key. It is the combination with the key in form of a hash that makes the IV unpredictable.

IV(\textrm{SN}) = E_s(\textrm{SN}), \quad\textrm{where}\;\; s = \textrm{hash}(K)

ESSIV was designed by Clemens Fruhwirth and has been integrated into the Linux kernel since version 2.6.10, though a similar scheme has been used to generate IVs for OpenBSD's swap encryption since 2000.[2]

ESSIV is supported as an option by the dm-crypt and FreeOTFE disk encryption systems.

Malleability attack[edit]

While CBC (with or without ESSIV) ensures confidentiality, it does not ensure integrity of the encrypted data. If the plaintext is known to the adversary, it is possible to change every 2nd plaintext block to a value chosen by the attacker, while the blocks in between are changed to random values. This can be used for practical attacks on disk encryption in CBC or CBC-ESSIV mode.[3]

Liskov, Rivest, and Wagner (LRW)[edit]

In order to prevent such elaborate attacks, different modes of operation were introduced: tweakable narrow-block encryption (LRW and XEX) and wide-block encryption (CMC and EME).

Whereas a purpose of a usual block cipher \scriptstyle E_K is to mimic a random permutation for any secret key \scriptstyle K, the purpose of tweakable encryption \scriptstyle E_K^Tis to mimic a random permutation for any secret key \scriptstyle K and any known tweak \scriptstyle T. The tweakable narrow-block encryption (LRW)[1] is an instantiation of the mode of operations introduced by Liskov, Rivest, and Wagner[2] (see Theorem 2). This mode uses two keys: \scriptstyle K is the key for the block cipher and \scriptstyle F is an additional key of the same size as block. For example, for AES with a 256-bit key, \scriptstyle K is a 256-bit number and \scriptstyle F is a 128-bit number. Encrypting block \scriptstyle P with logical index (tweak) \scriptstyle I uses the following formula:

\begin{align}
  C &= E_K(P \oplus X) \oplus X \\
  X &= F \otimes I
\end{align}

Here multiplication \scriptstyle \otimes and addition \scriptstyle \oplus are performed in the finite field (\scriptstyle \text{GF}\left(2^{128}\right) for AES). With some precomputation, only a single multiplication per sector is required (note that addition in a binary finite field is a simple bitwise addition, also known as xor): \scriptstyle F \,\otimes\, I \;=\; F \,\otimes\, (I_0 \,\oplus\, \delta) \;=\; F \,\otimes\, I_0 \,\oplus\, F \,\otimes\, \delta, where \scriptstyle F \,\otimes\, \delta are precomputed for all possible values of \scriptstyle \delta. This mode of operation needs only a single encryption per block and protects against all the above attacks except a minor leak: if the user changes a single plaintext block in a sector then only a single ciphertext block changes. (Note that this is not the same leak the ECB mode has: with LRW mode equal plaintexts in different positions are encrypted to different ciphertexts.)

Some security concerns exist with LRW, and this mode of operation has now been replaced by XTS.

LRW is employed by Bestcrypt and supported as an option for dm-crypt and FreeOTFE disk encryption systems.

Xor-encrypt-xor (XEX)[edit]

Another tweakable encryption mode XEX (xor-encrypt-xor), was designed by Rogaway[4] to allow efficient processing of consecutive blocks (with respect to the cipher used) within one data unit (e.g., a disk sector). The tweak is represented as a combination of the sector address and index of the block within the sector (the original XEX mode proposed by Rogaway[4] allows several indexes). The ciphertext, \scriptstyle C, is obtained using:

\begin{align}
  X &= E_{K}(I) \otimes \alpha^j \\
  C &= E_{K}(P \oplus X) \oplus X
\end{align}

where:

  • \scriptstyle P is the plaintext,
  • \scriptstyle I is the number of the sector,
  • \scriptstyle \alpha is the primitive element of \scriptstyle \text{GF}\left(2^{128}\right) defined by polynomial \scriptstyle x; i.e., the number 2,
  • \scriptstyle j is the number of the block within the sector.

The basic operations of the LRW mode (AES cipher and Galois field multiplication) are the same as the ones used in the Galois/Counter Mode (GCM) thus permitting a compact implementation of the universal LRW/XEX/GCM hardware.

XEX-based tweaked-codebook mode with ciphertext stealing (XTS)[edit]

Ciphertext stealing provides support for sectors with size not divisible by block size, for example, 520-byte sectors and 16-byte blocks. XTS-AES was standardized on 2007-12-19[5] as IEEE P1619.[6]

XTS encryption.svg

On January 27, 2010, NIST released Special Publication (SP) 800-38E[7] in final form. SP 800-38E is a recommendation for the XTS-AES mode of operation, as standardized by IEEE Std 1619-2007, for cryptographic modules. The publication approves the XTS-AES mode of the AES algorithm by reference to the IEEE Std 1619-2007, subject to one additional requirement, which limits the maximum size of each encrypted data unit (typically a sector or disk block) to 2^{20} AES blocks. According to SP 800-38E, "In the absence of authentication or access control, XTS-AES provides more protection than the other approved confidentiality-only modes against unauthorized manipulation of the encrypted data."

XTS is supported by BestCrypt, dm-crypt, FreeOTFE, TrueCrypt, DiskCryptor, FreeBSD's geli, OpenBSD softraid disk encryption software, and Mac OS X Lion's FileVault 2. XTS makes use of two different keys, usually generated by splitting the supplied block cipher's key in half, without adding any additional security, but complicating the process.[8] According to this source, the reason for this seems to be rooted in a misinterpretation of the original XEX-paper.[4] Because of the splitting, users wanting AES 256 and AES 128 encryption will need to choose key sizes of 512 bits and 256 bits respectively.

XTS mode is susceptible to data manipulation and tampering, and applications must employ measures to detect modifications of data if manipulation and tampering is a concern: "...since there are no authentication tags then any ciphertext (original or modified by attacker) will be decrypted as some plaintext and there is no built-in mechanism to detect alterations. The best that can be done is to ensure that any alteration of the ciphertext will completely randomize the plaintext, and rely on the application that uses this transform to include sufficient redundancy in its plaintext to detect and discard such random plaintexts." The mode is also susceptible to traffic analysis, replay, and sector randomization attacks.[9]

CBC-mask-CBC (CMC) and ECB-mask-ECB (EME)[edit]

CMC and EME protect even against the minor leak mentioned above for LRW. Unfortunately, the price is a twofold degradation of performance: each block must be encrypted twice; many consider this to be too high a cost, since the same leak on a sector level is unavoidable anyway.

CMC, introduced by Halevi and Rogaway, stands for CBC-mask-CBC: the whole sector encrypted in CBC mode (with \scriptstyle C_{-1} \;=\; E_A(I)), the ciphertext is masked by xoring with \scriptstyle 2(C'_0 \,\oplus\, C'_{k-1}), and re-encrypted in CBC mode starting from the last block. When the underlying block cipher is a strong pseudorandom permutation (PRP) then on the sector level the scheme is a tweakable PRP. One problem is that in order to decrypt \scriptstyle P_0 one must sequentially pass over all the data twice.

In order to solve this problem, Halevi and Rogaway introduced a parallelizable variant called EME (ECB-mask-ECB). It works in the following way:

  • the plaintexts are xored with \scriptstyle L \;=\; E_K(0), shifted by different amount to the left, and are encrypted: \scriptstyle P'_i \;=\; E_K(P_i \,\oplus\, 2^i L);
  • the mask is calculated: \scriptstyle M \;=\; M_P \,\oplus\, M_C, where \scriptstyle M_P \;=\; I \,\oplus\, \bigoplus P'_i and \scriptstyle M_C \;=\; E_K(M_P);
  • intermediate ciphertexts are masked: \scriptstyle C'_i \;=\; P'_i \,\oplus\, 2^i M for \scriptstyle i \;=\; 1,\, \ldots,\, k-1 and \scriptstyle C'_0 \;=\; M_C \,\oplus\, I \,\oplus\, \bigoplus_{i=1}^{k-1} C'_i;
  • the final ciphertexts are calculated: \scriptstyle C_i \;=\; E_K(C'_i) \,\oplus\, 2^i L for \scriptstyle i \;=\; 0,\, \ldots,\, k-1.

Note that unlike LRW and CMC there is only a single key \scriptstyle K.

CMC and EME were considered for standardization by SISWG. CMC was rejected for technical considerations.[citation needed] EME is patented, and so is not favored to be a primary supported mode.[3]

See also[edit]

Sources[edit]

References[edit]

  1. ^ New Methods in Hard Disk Encryption (PDF)
  2. ^ Encrypting Virtual Memory (Postscript)
  3. ^ Jakob Lell, Practical malleability attack against CBC-encrypted LUKS partitions; http://www.jakoblell.com/blog/2013/12/22/practical-malleability-attack-against-cbc-encrypted-luks-partitions/
  4. ^ a b c Rogaway, Phillip (2004-09-24). "Efficient Instantiations of Tweakable Blockciphers and Refinements to Modes OCB and PMAC". 
  5. ^ IEEE Approves Standards for Data Encryption
  6. ^ Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices
  7. ^ http://csrc.nist.gov/publications/nistpubs/800-38E/nist-sp-800-38E.pdf
  8. ^ Liskov, Moses; Minematsu, Kazuhiko (2008-09-02). "Comments on XTS-AES". , On the Use of Two Keys, pp. 1-3.
  9. ^ "Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices", IEEE P1619/D16, 2007, p. 34 http://grouper.ieee.org/groups/1619/email/pdf00086.pdf, retrieved 14 September 2012  Missing or empty |title= (help)

Endnotes[edit]

  1. ^ Latest SISWG and IEEE P1619 drafts and meeting information are on the P1619 home page [4].
  2. ^ M. Liskov, R. Rivest, and D. Wagner. Tweakable block ciphers [5], CRYPTO '02 (LNCS, volume 2442), 2002.
  3. ^ P. Rogaway, Block cipher mode of operation for constructing a wide-blocksize block cipher from a conventional block cipher, US Patent Application 20040131182 A1, [6]

Papers[edit]

External links[edit]