Iterated block ciphers Most block cipher algorithms are classified as
iterated block ciphers which means that they transform fixed-size blocks of
plaintext into identically sized blocks of
ciphertext, via the repeated application of an invertible transformation known as the
round function, with each iteration referred to as a
round. Usually, the round function
R takes different
round keys Ki as a second input, which is derived from the original key: :M_i = R_{K_i}(M_{i-1}) where M_0 is the plaintext and M_r the ciphertext, with
r being the number of rounds. Frequently,
key whitening is used in addition to this. At the beginning and the end, the data is modified with key material (often with
XOR): : M_0 = M \oplus K_0 :M_i = R_{K_i}(M_{i-1})\; ; \; i = 1 \dots r :C = M_r \oplus K_{r+1} Given one of the standard iterated block cipher design schemes, it is fairly easy to construct a block cipher that is cryptographically secure, simply by using a large number of rounds. However, this will make the cipher inefficient. Thus, efficiency is the most important additional design criterion for professional ciphers. Further, a good block cipher is designed to avoid side-channel attacks, such as branch prediction and input-dependent memory accesses that might leak secret data via the cache state or the execution time. In addition, the cipher should be concise, for small hardware and software implementations.
Substitution–permutation networks One important type of iterated block cipher known as a
substitution–permutation network (SPN) takes a block of the plaintext and the key as inputs and applies several alternating rounds consisting of a
substitution stage followed by a
permutation stage—to produce each block of ciphertext output. The non-linear substitution stage mixes the key bits with those of the plaintext, creating Shannon's
confusion. The linear permutation stage then dissipates redundancies, creating
diffusion. A
substitution box (S-box) substitutes a small block of input bits with another block of output bits. This substitution must be
one-to-one, to ensure invertibility (hence decryption). A secure S-box will have the property that changing one input bit will change about half of the output bits on average, exhibiting what is known as the
avalanche effect—i.e. it has the property that each output bit will depend on every input bit. A
permutation box (P-box) is a
permutation of all the bits: it takes the outputs of all the S-boxes of one round, permutes the bits, and feeds them into the S-boxes of the next round. A good P-box has the property that the output bits of any S-box are distributed to as many S-box inputs as possible. At each round, the round key (obtained from the key with some simple operations, for instance, using S-boxes and P-boxes) is combined using some group operation, typically
XOR.
Decryption is done by simply reversing the process (using the inverses of the S-boxes and P-boxes and applying the round keys in reversed order).
Feistel ciphers s'' In a
Feistel cipher, the block of plain text to be encrypted is split into two equal-sized halves. The round function is applied to one half, using a subkey, and then the output is XORed with the other half. The two halves are then swapped. Let {\rm F} be the round function and let K_0,K_1,\ldots,K_{n} be the sub-keys for the rounds 0,1,\ldots,n respectively. Then the basic operation is as follows: Split the plaintext block into two equal pieces, (L_0, R_0) For each round i =0,1,\dots,n, compute :L_{i+1} = R_i\, :R_{i+1}= L_i \oplus {\rm F}(R_i, K_i). Then the ciphertext is (R_{n+1}, L_{n+1}). The decryption of a ciphertext (R_{n+1}, L_{n+1}) is accomplished by computing for i=n,n-1,\ldots,0 :R_{i} = L_{i+1}\, :L_{i} = R_{i+1} \oplus {\rm F}(L_{i+1}, K_{i}). Then (L_0,R_0) is the plaintext again. One advantage of the Feistel model compared to a
substitution–permutation network is that the round function {\rm F} does not have to be invertible.
Lai–Massey ciphers . The Lai–Massey scheme offers security properties similar to those of the
Feistel structure. It also shares the advantage that the round function \mathrm F does not have to be invertible. Another similarity is that it also splits the input block into two equal pieces. However, the round function is applied to the difference between the two, and the result is then added to both half blocks. Let \mathrm F be the round function and \mathrm H a half-round function and let K_0,K_1,\ldots,K_n be the sub-keys for the rounds 0,1,\ldots,n respectively. Then the basic operation is as follows: Split the plaintext block into two equal pieces, (L_0, R_0) For each round i =0,1,\dots,n, compute :(L_{i+1}',R_{i+1}') = \mathrm H(L_i' + T_i,R_i' + T_i), where T_i = \mathrm F(L_i' - R_i', K_i) and (L_0',R_0') = \mathrm H(L_0,R_0) Then the ciphertext is (L_{n+1}, R_{n+1}) = (L_{n+1}',R_{n+1}'). The decryption of a ciphertext (L_{n+1}, R_{n+1}) is accomplished by computing for i=n,n-1,\ldots,0 :(L_i',R_i') = \mathrm H^{-1}(L_{i+1}' - T_i, R_{i+1}' - T_i) where T_i = \mathrm F(L_{i+1}' - R_{i+1}',K_i) and (L_{n+1}',R_{n+1}')=\mathrm H^{-1}(L_{n+1},R_{n+1}) Then (L_0,R_0) = (L_0',R_0') is the plaintext again.
Operations ARX (add–rotate–XOR) Many modern block ciphers and hashes are
ARX algorithms—their round function involves only three operations: (A) modular addition, (R)
rotation with fixed rotation amounts, and (X)
XOR. Examples include
ChaCha20,
Speck,
XXTEA, and
BLAKE. Many authors draw an ARX network, a kind of
data flow diagram, to illustrate such a round function.{{cite book |last1=Aumasson |first1=Jean-Philippe |last2=Bernstein |first2=Daniel J. These ARX operations are popular because they are relatively fast and cheap in hardware and software, their implementation can be made extremely simple, and also because they run in constant time, and therefore are immune to
timing attacks. The
rotational cryptanalysis technique attempts to attack such round functions.
Other operations Other operations often used in block ciphers include data-dependent rotations as in
RC5 and
RC6, a
substitution box implemented as a
lookup table as in
Data Encryption Standard and
Advanced Encryption Standard, a
permutation box, and multiplication as in
IDEA. ==Modes of operation==