A.2. Block Ciphers

Block ciphers encrypt plaintext messages in blocks of fixed lengths and are more ubiquitously used than public-key encryption routines. In a sense, public-key encryption is also block encryption. Since public-key routines are much slower than (secret-key) block ciphers, it is a custom to use public-key algorithms only in specific situations, for example, for encrypting single blocks of data, like keys of symmetric ciphers.

In the rest of this chapter, we use the word bit in the conventional sense, that is, to denote a quantity that can take only two possible values, 0 and 1. It is convenient to use the symbol to refer to the set {0, 1}. We also let stand for the set of all bit strings of length m. Whenever we plan to refer to the field (or group) structure of , we will use the alternative notation .

Definition A.1.

A block cipher f of block-size n and of key-size r is a map

that encrypts a plaintext block m of bit length n to a ciphertext block c of bit length n under a key K, a bit string of length r. To ensure unique decryption, the map

for a fixed key K has to be a permutation of (that is, a bijective function on) . In that case, the decryption of c to get back m is carried out as .

A good block cipher has the following desirable properties:

  • The sizes n and r should be big enough, so that an adversary cannot exhaustively check all possibilities of m or K in feasible time.

  • For most, if not all, keys K, the permutations fK should be sufficiently random. In other words, if the key K is not known, it should be computationally infeasible to guess the functions fK and . That is, it should be difficult to guess c from m or m from c, unless the key K is provided. The identity map on , though a permutation of , is a bad candidate for an encryption function fK. It is also desirable that the functions fK for different values of K are unpredictably selected from the set of all permutations of . Thus, for example, taking fK to be a fixed permutation for all choices of K leads to a poor design of a block cipher f.

  • For most, if not all, pairs of distinct keys K1 and K2, the functions gK1 ο gK2 should not equal gK for some key K, where g stands for f or f–1 with independent choices in the three uses. A more stringent demand is that the subgroup generated by the permutations fK for all possible keys K should be a very big subset of the group of all permutations of . If gK = gK1 ο gK2 ο · · · ο gKt for some t ≥ 2, multiple encryption (see Section A.3) forfeits its expected benefits.

A block cipher provably possessing all these good characteristics (in particular, the randomness properties) is difficult to construct in practice. Practical block ciphers are manufactured for reasonably big n and r and come with the hope of representing reasonably unpredictable permutations. We dub a block cipher good or safe, if it stands the test of time. Table A.1 lists some widely used block ciphers.

Table A.1. Some popular block ciphers
Namenr
DES (Data Encryption Standard)6456
FEAL (Fast Data Encipherment Algorithm)6464
SAFER (Secure And Fast Encryption Routine)6464
IDEA (International Data Encryption Algorithm)64128
Blowfish64≤ 448
Rijndael, accepted as AES (Advanced Encryption Standard) by NIST (National Institute of Standards and Technology, a US government organization)128/192/256128/192/256

A.2.1. A Case Study: DES

The data encryption standard (DES) was proposed as a federal information processing standard (FIPS) in 1975. DES has been the most popular and the most widely used among all block ciphers ever designed. Although its relatively small key-size offers questionable security under today’s computing power, DES still enjoys large-scale deployment in not-so-serious cryptographic applications.

DES encryption requires a 64-bit plaintext block m and a 56-bit key K.[1] Let us plan to use the notations DESK and to stand respectively for DES encryption and decryption functions under the key K.

[1] A DES key K = k1k2 . . . k64 is actually a 64-bit string. Only 56 bits of K are used for encryption. The remaining 8 bits are used as parity-check bits. Specifically, for each i = 1, . . . , 8 the bit k8i is adjusted so that the i-th byte (k8i – 7k8i – 6 . . . k8i) has an odd number of one-bits.

DES key schedule

The DES algorithm first computes sixteen 48-bit keys K1, K2, . . . , K16 from K using a procedure known as the DES key schedule described in Algorithm A.1. These 16 keys are used in the 16 rounds of encryption. The key schedule uses two fixed permutations PC1 and PC2 described after Algorithm A.1 and to be read in the row-major order. Here, PC is an abbreviation for permuted choice.

Algorithm A.1. The DES key schedule

Input: A DES key K = k1k2 . . . k64 (containing the parity-check bits).

Output: Sixteen 48-bit round keys K1, K2, . . . , K16.

Steps:

Use PC1 to generate .
Write U0 = C0 ‖ D0 with C0.
for i = 1, 2, . . . ,16 {
   Take 
   Cyclically left shift Ci – 1 by s bits to get Ci.
   Cyclically left shift Di – 1 by s bits to get Di.
   Let .
   Compute the i-th round key Ki := PC2(Ui) = u14u17u11 . . . u29u32.
}

PC1
5749413325179
1585042342618
1025951433527
1911360524436
63554739312315
7625446383022
1466153453729
211352820124

PC2
1417112415
3281562110
2319124268
1672720132
415231374755
304051453348
444939563453
464250362932

DES encryption

DES encryption, as described in Algorithm A.2, proceeds in 16 rounds. The i-th round uses the key Ki (obtained from the key schedule) in tandem with the encryption primitive e. A fixed permutation IP and its inverse IP–1 are also used.[2]

[2] A block cipher that executes several encryption rounds with the i-th round computing the two halves as Li := Ri – 1 and Ri := Li – 1e(Ri – 1, Ki) for some round key Ki and for some encryption primitive e, is called a Feistel cipher. Most popular block ciphers mentioned earlier are of this type. Rijndael is an exception, and its acceptance as the new standard has been interpreted as an end of the Feistel dynasty.

It requires a specification of the round encryption function e to complete the description of DES encryption. The function e can be compactly depicted as:

e(X, J) := P(S(E(X) ⊕ J)),

Algorithm A.2. DES encryption

Input: Plaintext block m = m1m2 . . . m64 and the round keys K1, . . . , K16.

Output: The ciphertext block .

Steps:

Apply the initial permutation on m to get
     
Write V = L0 ‖ R0 with L0.
for i = 1, 2, . . . , 16 {
   /* The i-th encryption round */
   Li := Ri – 1.
   Ri := Li – 1 ⊕ e(Ri – 1Ki).
}
Let .
Apply the inverse of the initial permutation on W to get the ciphertext block
   .

IP
585042342618102
605244362820124
625446383022146
645648403224168
57494133251791
595143352719113
615345372921135
635547393123157

IP–1
408481656246432
397471555236331
386461454226230
375451353216129
364441252206028
353431151195927
342421050185826
33141949175725

where is an expansion function, is a contraction function and P is a fixed permutation of (called the permutation function). S uses eight S-boxes (substitution boxes) S1, S2, . . . , S8. Each S-box Sj is a 4 × 16 matrix with each row a permutation of 0, 1, 2, . . . , 15 and is used to convert a 6-bit string y1y2y3y4y5y6 to a 4-bit string z1z2z3z4 as follows. Let μ denote the integer with binary representation y1y6 and ν the integer with binary representation y2y3y4y5. Then, z1z2z3z4 is the 4-bit binary representation of the μ, ν-th entry in the matrix Sj. (Here, the numbering of the rows and columns starts from 0.) In this case, we write Sj(y1y2y3y4y5y6) = z1z2z3z4. Algorithm A.3 provides the description of e.

Algorithm A.3. The DES round encryption primitive e

Input: and .

Output: e(X, J).

Steps:

Y := E(X) ⊕ J (where E(x1x2 . . . x32) = x32x1x2 . . . x32x1).
Write Y = Y1 ‖ Y2 ‖ . . . ‖ Y8 with each .
for 
.
 (where P(z1z2 . . . z32) = z16z7z20 . . . z4z25).

The tables for E and P are as follows.

E
3212345
456789
8910111213
121314151617
161718192021
202122232425
242526272829
28293031321

P
1672021
29122817
1152326
5183110
282414
322739
1913306
2211425

Finally, the eight S-boxes are presented:

S1
1441312151183106125907
0157414213110612119538
4114813621115129731050
1512824917511314100613

S2
1518146113497213120510
3134715281412011069115
0147111041315812693215
1381013154211671205149

S3
1009146315511312711428
1370934610285141211151
1364981530111212510147
1101306987415143115212

S4
7131430691012851112415
1381156150347212110149
1069012117131513145284
3150610113894511127214

S5
2124171011685315130149
1411212471315015103986
4211110137815912563014
1181271142136150910453

S6
1211015926801334147511
1015427129561131401138
9141552812370410113116
4321295151011141760813

S7
4112141508133129751061
1301174911014351221586
1411131237141015680592
6111381410795015142312

S8
1328461511110931450127
1151381037412561101492
7114191214206101315358
2114741081315129035611

DES decryption

DES decryption is analogous to DES encryption. To obtain one first computes the round keys K1, K2, . . . , K16 using Algorithm A.1. One then calls a minor variant of Algorithm A.2. First, the roles of m and c are interchanged. That is, one inputs c instead of m, and obtains m in place of c as output. Moreover, the right half Ri in the i-th round is computed as Ri := Li – 1e(Ri – 1, K17 – i). In other words, DES decryption is same as DES encryption, only with the sequence of using the keys K1, K2, . . . , K16 reversed. Solve Exercise A.1 in order to establish the correctness of this decryption procedure.

DES test vectors

Some test vectors for DES are given in Table A.2.

Table A.2. DES test vectors
KeyPlaintext blockCiphertext block
010101010101010100000000000000008ca64de9c1b123a7
fefefefefefefefeffffffffffffffff7359b2163e4edc58
31010101010101011000000000000001958e6e627a05557B
10101010101010101111111111111111f40379ab9e0ec533
0123456789abcdef111111111111111117668dfc7292532d
10101010101010100123456789abcdef8a5ae1f81ab8f2dd
fedcba98765432100123456789abcdefed39d950fa74bcc4

Cryptanalysis of DES

DES, being a popular block cipher, has gone through a good amount of cryptanalytic studies. At present, linear cryptanalysis and differential cryptanalysis are the most sophisticated attacks on DES. But the biggest problem with DES is its relatively small key size (56 bits). An exhaustive key search for a given plaintext–ciphertext pair needs carrying out a maximum of 256 encryptions in order to obtain the correct key. But how big is this number 256 = 72,057,594,037,927,936 (nearly 72 quadrillion) in a cryptographic sense?

In order to review this question, RSA Security Inc. posed several challenges for obtaining the DES key from given plaintext–ciphertext pairs. The first challenge, posed in January 1997, was broken by Rocke Verser of Loveland, Colorado, with approximately 96 days of computing. DES Challenge II-1 was broken in February 1998 by distributed.net with 41 days of computing, and the DES challenge II-2 was cracked in July 1998 by the Electronic Frontier Foundation (EFF) in just 56 hours. Finally, DES Challenge III was broken in a record of 22 hours 15 minutes in January 1999. The computations were carried out in EFF’s supercomputer Deep Crack with collaborative efforts from nearly 105 PCs on the Internet guided by distributed.net. These figures demonstrate that DES offers hardly any security against a motivated adversary.

Another problem with DES is that its design criteria (most importantly, the objectives behind choosing the particular S-boxes) were never made public. Chances remain that there are hidden backdoors, though none has been discovered till date.

A.2.2. The Advanced Standard: AES

The advanced encryption standard (AES) [219] has superseded the older standard DES. The Rijndael cipher designed by Daemen and Rijmen has been accepted as the advanced standard. As mentioned in Footnote 2, Rijndael is not a Feistel cipher. Its working is based on the arithmetic in the finite field and in the finite ring .

Data representation

AES encrypts data in blocks of 128 bits. Let B = b0b1 . . . b127 be a block of data, where each bi is a bit. Keeping in view typical 32-bit processors, each such block B is represented as a sequence of four 32-bit words, that is, B = B0B1B2B3, where Bi represents the bit string b32ib32i+1 . . . b32i+31. Each word C = c0c1 . . . c31, in turn, is viewed as a sequence of four octets, that is, C = C0C1C2C3, where Ci stores the bit string c8ic8i+1 . . . c8i+7. Each octet is identified as an element of , whereas an entire 32-bit word is identified with an element of .

The field is represented as , where f(X) is the irreducible polynomial X8 + X4 + X3 + X + 1. Let x := X + 〈f(X)〉. The element is identified with the octet d7d6 . . . d1d0. Thus, the i-th octet c8ic8i+1 . . . c8i+7 in a word is treated as the finite field element .

Now, let us explain the interpretation of a 32-bit word C = C0C1C2C3. The -algebra is not a field, since the polynomial Y4 + 1 is reducible (over and so over ). However, each element β of A can be uniquely expressed as a polynomial β = α3y3 + α2y2 + α1y + α0, where y := Y + 〈Y4 + 1〉 and where each αi is an element of . As described in the last paragraph, each αi is represented as an octet. We take Ci to be the octet representing α3 – i, that is, the 32-bit word α3α2α1α0 stands for the element .

and A are rings and hence equipped with arithmetic operations (addition and multiplication). These operations are different from the usual addition and multiplication operations defined on octets and words. For example, the addition of two octets or words under the AES interpretation is the same as bit-wise XOR of octets or words. The AES multiplication of octets and words, on the other hand, involves polynomial arithmetic and reduction modulo the defining polynomials and so cannot be expressed so simply as addition. To resolve ambiguities, let us plan to denote the multiplication of by ⊙ and that of A by ⊗, whereas regular multiplication symbols (·, × and juxtaposition) stand for the standard multiplication on octets or words. Exercises A.5, A.6 and A.7 discuss about efficient implementations of the arithmetic in and A.

Every non-zero element is invertible; the inverse is denoted by α–1 and can be computed by the extended gcd algorithm on polynomials over . With an abuse of notation, we take 0–1 := 0. Every non-zero element of A is not invertible (under the multiplication of A). The AES algorithm uses the following invertible element β := 03010102 (in hex notation); its inverse is β–1 = 0b0d090e.

The AES algorithm uses an object called a state, comprising 16 octets arranged in a 4 × 4 array. Each message block also consists of 16 octets. Let M = μ0μ1 . . . μ15 be a message block (of 16 octets). This block is translated to a state as follows:

Equation A.1


Thus, each word in the block is relocated in a column of the state. At the end of the encryption procedure, AES makes the reverse translation of a state to a block:

Equation A.2


AES key schedule

A collection of round keys is generated from the given AES key K. The number of rounds of the AES encryption algorithm depends on the size of the key. Let us denote the number of words in the AES key by Nk and the corresponding number of rounds by Nr. We have:

One first generates an initial 128-bit key K0K1K2K3. Subsequently, for the i-th round, 1 ≤ iNr, a 128-bit key K4iK4i+1K4i+2K4i+3 is required. Here, each Kj is a 32-bit word. The key schedule (also called key expansion) generates a total of 4(Nr + 1) words K0, K1, . . . , K4Nr+3 from the given secret key K using a procedure described in Algorithm A.4. Here, (02)j – 1 stands for the octet that represents the element . The following table summarizes these values for j = 1, 2, . . . , 15.

j123456789101112131415
xj – 101020408102040801b366cd8ab4d9a

The transformation SubWord on a word T = τ0τ1τ2τ3 is the octet-wise application of AES S-box substitution SubOctet, that is,

SubWord(T) = SubOctet(τ0) ‖ SubOctet(τ1) ‖ SubOctet(τ2) ‖ SubOctet(τ3).

Algorithm A.4. AES key schedule

Input: (Nk and) the secret key K = κ0κ1 ... κ4Nk – 1, where each κi is an octet.

Output: The expanded keys K0, K1, . . . , K4Nr+3.

Steps:

/* Initially copy the bytes of K */
for i = 0, 1, . . . , Nk – 1 { Ki := κ4iκ4i+1κ4i+2κ4i+3. }

/* Recursively define the round keys */
for i = NkNk + 1, . . . , 4Nr + 3 {
      T := Ki – 1;       /* T is a temporary word variable. */
      /* Let T = τ0τ1τ2τ3where each τi is an octet. */
      if (i rem Nk = 0) { T := SubWord(τ1τ2τ3τ0) ⊕ [(02)(i/Nk) – 1‖000000]. }
      else if (Nk > 6) and (i rem Nk = 4) { T := SubWord(T). }
      Ki := KiNk ⊕ T.
}

The transformation SubOctet is also used in each encryption round and is now described. Let A = a0a1 . . . a7 be an octet that can be identified with an element of as mentioned earlier. Let B = b0b1 . . . b7 denote the octet representing the inverse of this finite field element. (We take 0–1 = 0.) One then applies the following affine transformation on B to generate the final value C := SubOctet(A) := c0c1 . . . c7. Here, D = d0d1 . . . d7 is the constant octet 63 = 01100011.

Equation A.3


In order to speed up this octet substitution, one may use table lookup. Since the output octet C depends only on the input octet A, one can precompute a table of values of SubOctet(A) for the 256 possible values of A. This list is given in Table A.3. The table is to be read in the row-major fashion. In other words, if hi and lo respectively represent the most and the least significant four bits of A, then SubOctet(A) can be read off from the entry in the table having row number hi and column number lo. For example, SubOctet(a7) = 5c. In an actual implementation, a one-dimensional array is to be used. We use a two-dimensional format in Table A.3 for the sake of clarity of presentation.

Table A.3. AES S-box
 0123456789abcdef
0637c777bf26b6fc53001672bfed7ab76
1ca82c97dfa5947f0add4a2af9ca472c0
2b7fd9326363ff7cc34a5e5f171d83115
304c723c31896059a071280e2eb27b275
409832c1a1b6e5aa0523bd6b329e32f84
553d100ed20fcb15b6acbbe394a4c58cf
6d0efaafb434d338545f9027f503c9fa8
751a3408f929d38f5bcb6da2110fff3d2
8cd0c13ec5f974417c4a77e3d645d1973
960814fdc222a908846eeb814de5e0bdb
ae0323a0a4906245cc2d3ac629195e479
be7c8376d8dd54ea96c56f4ea657aae08
cba78252e1ca6b4c6e8dd741f4bbd8b8a
d703eb5664803f60e613557b986c11d9e
ee1f8981169d98e949b1e87e9ce5528df
f8ca1890dbfe6426841992d0fb054bb16

AES encryption

AES encryption is described in Algorithm A.5. The algorithm first converts the input plaintext message block to a state, applies a series of transformations on this state and finally converts the state back to a message (the ciphertext).

The individual state transition transformations are now explained. The transition SubState is an octet-by-octet application of the substitution function SubOctet, that is, SubState maps

where for all r, c. The transform ShiftRows cyclically left rotates the r-th row by r byte positions, that is, maps

The AddKey operation uses four 32-bit round keys L0, L1, L2, L3. Name the octets of Li as λi0λi1λi2λi3. The i-th key Li is XORed with the i-th column of the state, that is, AddKey transforms

Finally, the MixCols transform multiplies each column of the state, regarded as an element of , by the element , where the coefficients (expressions within square brackets) are octet values in hexadecimal, that can be identified with elements of . For the c-th column, this transformation can be represented as:

Algorithm A.5. AES encryption

Input: The plaintext message M = μ0μ1 . . . μ15 and the round keys K0, K1, . . . , K4Nr+3.

Output: Ciphertext message C = γ0γ1 . . . γ15.

Steps:

Convert M to the state S.                                      /* Use Transform (A.1) */
S := AddKey(SK0K1K2K3).
for i = 1, 2, . . . , Nr {
      S := SubState(S).
      S := ShiftRows(S).
      if (i ≠ Nr) { S := MixCols(S). }
      S := AddKey(SK4iK4i+1K4i+2K4i+3).
}
Convert S to the message C.                                /* Use Transform (A.2) */

AES decryption

AES decryption involves taking inverse of each state transition performed during encryption. The key schedule needed for encryption is to be used during decryption too. The straightforward decryption routine is given in Algorithm A.6.

Algorithm A.6. AES decryption

Input: The ciphertext message C = γ0γ1 . . . γ15 and the round keys K0, K1, . . . , K4Nr+3.

Output: The recovered plaintext message M = μ0μ1 . . . μ15.

Steps:

Convert C to the state S.                                      /* Use Transform (A.1) */
S := AddKey(SK4NrK4Nr+1K4Nr+2K4Nr+3).
for i = Nr – 1, Nr – 2, . . . , 1, 0 {
      S := ShiftRows–1(S).
      S := SubState–1(S).
      S := AddKey(SK4iK4i+1K4i+2K4i+3).
      if (i ≠ 0) { S := MixCols–1(S). }
}
Convert S to the message M.                                /* Use Transform (A.2) */

What remains is a description of the inverses of the basic state transformations. AddKey involves octet-by-octet XORing and so is its own inverse. Table A.4 summarizes the inverse of the substitution transition SubOctet (Exercise A.8). For computing SubState–1(S), one should apply SubOctet–1 on each octet of S. The inverse of ShiftRows is also straightforward and can be given by

Finally, MixCols–1 involves multiplication of each column by the inverse of the element , that is, by the element [0b]y3 + [0d]y2 + [09]y + [0e]. So MixCols–1 transforms each column of the state as follows:

Table A.4. Inverse of AES S-box
 0123456789abcdef
052096ad53036a538bf40a39e81f3d7fb
17ce339829b2fff87348e4344c4dee9cb
2547b9432a6c2233dee4c950b42fac34e
3082ea16628d924b2765ba2496d8bd125
472f8f66486689816d4a45ccc5d65b692
56c704850fdedb9da5e154657a78d9d84
690d8ab008cbcd30af7e45805b8b34506
7d02c1e8fca3f0f02c1afbd0301138a6b
83a9111414f67dcea97f2cfcef0b4e673
996ac7422e7ad3585e2f937e81c75df6e
a47f11a711d29c5896fb7620eaa18be1b
bfc563e4bc6d279209adbc0fe78cd5af4
c1fdda8338807c731b11210592780ec5f
d60517fa919b54a0d2de57a9f93c99cef
ea0e03b4dae2af5b0c8ebbb3c83539961
f172b047eba77d626e169146355210c7d

AES decryption is as efficient as AES encryption, since each state transformation primitive has the same structure as its inverse. However, the sequence of application of these primitives in the loop (rounds) for decryption differs from that for encryption. For some implementations, mostly in hardware, this may be a problem. Compare this with DES for which the encryption and decryption algorithms are identical save the sequence of using the round keys (Exercise A.1). With little additional effort AES can also be furnished with this useful property of DES. All we have to do is to use a different key schedule for decryption. The necessary modifications are explored in Exercise A.9.

AES test vectors

Table A.5 provides the ciphertexts for the plaintext block

M = 00112233445566778899aabbccddeeff

under different keys.

Table A.5. AES test vectors
CipherKeyCiphertext block
AES-1280001020304050607 08090a0b0c0d0e0f69c4e0d86a7b0430 d8cdb78070b4c55a
AES-1920001020304050607 08090a0b0c0d0e0f 1011121314151617dda97ca4864cdfe0 6eaf70a0ec0d7191
AES-2560001020304050607 08090a0b0c0d0e0f 1011121314151617 18191a1b1c1d1e1f8ea2b7ca516745bf eafc49904b496089

Cryptanalysis of AES

AES has been designed so that linear and differential attacks are infeasible. Another attack known as the square attack has been proposed by Lucks [184] and Ferguson et al. [93], but at present can tackle less number of rounds than used in Rijndael encryption. Also see Gilbert and Minier [112] to know about the collision attack.

The distinct algebraic structure of AES encryption invites special algebraic attacks. One such potential attack (the XSL attack) has been proposed by Courtois and Pieprzyk [68]. Although this attack has not yet been proved to be effective, a better understanding of the algebra may, in foreseeable future, lead to disturbing consequences for the advanced standard.

For more information on AES, read the book [71] from the designers of the cipher. Also visit the following Internet sites:

http://www.esat.kuleuven.ac.be/~rijmen/rijndael/Rijndael home
http://csrc.nist.gov/CryptoToolkit/aes/index1.htmlNIST site for AES
http://www.cryptosystem.net/aes/Algebraic attacks

A.2.3. Multiple Encryption

Multiple encryption presents a way to achieve a desired level of security by using block ciphers of small key sizes. The idea is to cascade several stages of encryption and/or decryption, with different stages working under different keys. Figure A.1 illustrates double and triple encryption for a block cipher f. Each gi or hj represents either the encryption or the decryption function of f under the given key.

Figure A.1. Multiple encryption


For double encryption, we have K1K2 and both g1 and g2 are usually the encryption function. Unless fK2 ο fK1 is the same as fK for some key K and if the permutations of f are reasonably random, it appears at the first glance that double encryption increases the effective key size by a factor of two. Unfortunately, this is not the case. The meet-in-the-middle attack on double encryption works as follows.

Suppose that an adversary knows a plaintext–ciphertext pair (m, c) under the unknown keys K1, K2. We assume as before that f has block-size n and key-size r. The adversary computes for each possibility of the encrypted message xi := fi(m). She also computes for each the decrypted message . Now, (i, j) is a possible value of (K1, K2) if and only if .

A given pair (m, c) usually gives many such candidates (i, j) for (K1, K2). More precisely, if each is assumed to be a random permutation of , for a given i we have the equality for an expected number of 2r/2n values of j. Considering all possibilities for i gives an expected number of 2r × 2r/2n = 22rn candidate pairs (i, j). If f = DES, this number is 22 × 56–64 = 248.

If a second pair (m′, c′) under (K1, K2) is also known to the adversary, then for a given i the pair (i, j) is consistent with both (m, c) and (m′, c′) with probability 2r/(2n × 2n). Thus, we get an expected number of (2r × 2r)/(2n × 2n) = 22r – 2n candidates (i, j). For DES, this number is 2–16. This implies that it is very unlikely that a false candidate (i, j) satisfies both (m, c) and (m′, c′). Thus, with high probability the adversary uniquely identifies the double DES key (K1, K2) from two plaintext–ciphertext pairs.

This attack calls for O(2r) encryptions and O(2r) decryptions. With the assumption that each encryption takes roughly the same time as each decryption (as in the case of DES), the adversary spends a time for O(2r) encryptions. Moreover, she can find all the matches in O(r2r) time. This implies that double encryption increases the effective key size (over single encryption) by a few bits only. On the other hand, both the actual key size and the encryption time get doubled. In view of these shortcomings, double encryption is rarely used in practice.

For the triple encryption scheme of Figure A.1, a meet-in-the-middle attack at x or y demands an effort equivalent to O(22r) encryptions, that is, the effective key size gets doubled. It is, therefore, customary to take K1 = K3 and K2 different from this common value. The actual key size also gets doubled with this choice—one doesn’t have to remember K3 separately. It is also a common practice to take h1 and h3 the encryption function (under K1 = K3) and h2 the decryption function (under K2). One often calls this particular triple encryption an E-D-E scheme.

A.2.4. Modes of Operation

In practice, the length of the message m to be encrypted need not equal the block length n of the block cipher f. One then has to break up m into blocks of some fixed length n′ ≤ n and encrypt each block using the block cipher. In order to make the length of m an integral multiple of n′, one may have to pad extra bits to m (say, zero bits at the end). It is often necessary to store the initial size of m in a separate block, say, after the last message block. In what follows, we shall assume that the input message m gives rise to l blocks m1, m2, . . . , ml each of size n′. The corresponding ciphertext blocks c1, c2, . . . , cl will also be of bit length n′ each. The reason for choosing the block size n′ ≤ n will be clear soon.

The ECB mode

The easiest way to encrypt multiple blocks m1, . . . , ml is to take n′ = n and encrypt each block mi as ci := fK(mi). Decryption is analogous: . This mode of operation of a block cipher is called the electronic code-book or the ECB mode. Algorithms A.7 and A.8 describe this mode.

Algorithm A.7. ECB encryption

Input: The plaintext blocks m1, . . . , ml and the key K.

Output: The ciphertext c = c1 . . . cl.

Steps:

for i = 1, . . . , l { ci := fK(mi) }

Algorithm A.8. ECB decryption

Input: The ciphertext blocks c1, . . . , cl and the key K.

Output: The plaintext m = m1 . . . ml.

Steps:

for

In this mode, identical message blocks encrypt to identical ciphertext blocks (under the same key), that is, partial information about the plaintext may be leaked out. The following three modes overcome this problem.

The CBC mode

In the cipher-block chaining or the CBC mode, one takes n′ = n and each plaintext block is first XOR-ed with the previous ciphertext block and then encrypted. In order to XOR the first plaintext block, one needs an n-bit initialization vector (IV). The IV need not be kept secret and may be sent along with the ciphertext blocks.

Algorithm A.9. CBC encryption

Input: The plaintext blocks m1, . . . , ml, the key K and the IV.

Output: The ciphertext c = c1 . . . cl.

Steps:

c0 := IV.

for i = 1, . . . , l { ci := fK(mici – 1). }

Algorithm A.10. CBC decryption

Input: The ciphertext blocks c1, . . . , cl, the key K and the IV.

Output: The plaintext m = m1 . . . ml.

Steps:

c0 := IV.

for

The CFB mode

In the cipher feedback or the CFB mode, one chooses . In this mode, the plaintext blocks are not encrypted, but masked by XOR-ing with a stream of random keys generated from a (not necessarily secret) n-bit IV. In this sense, the CFB mode works like a stream cipher (see Section A.3).

Algorithm A.11. CFB encryption

Input: The plaintext blocks m1, . . . , ml, the key K and the IV.

Output: The ciphertext c = c1 . . . cl.

Steps:

k0 := IV.   /* Initialize the key stream */
for i = 1, . . . , l {
   /* Mask the current key by block encryption and the message by XOR-ing */
   ci := mi ⊕ msbn′ (fK(ki – 1)).
   /* Generate the next key from the previous key and the current ciphertext block */
   ki := lsbnn (ki – 1) ‖ ci.
}

Algorithm A.11 explains CFB encryption. The notation msbk(z) (resp. lsbk(z)) stands for the most (resp. least) significant k bits of a bit string z. For CFB decryption (Algorithm A.12), the identical key stream k0, k1, . . . , kl is generated and used to mask off the message blocks from the ciphertext blocks.

Algorithm A.12. CFB decryption

Input: The ciphertext blocks c1, . . . , cl, the key K and the IV.

Output: The plaintext m = m1 . . . ml.

Steps:

k0 := IV.
for i = 1, . . . , l {
   mi := ci ⊕ msbn (fK(ki – 1)).
   ki := lsbnn (ki – 1) ‖ ci.
}

The OFB mode

The output feedback or the OFB mode also works like a stream cipher by masking the plaintext blocks using a stream of keys. The key stream in the OFB mode is generated by successively applying the block encryption function on an n-bit (not necessarily secret) IV. Here, one chooses any .

OFB encryption is explained in Algorithm A.13. OFB decryption (Algorithm A.14) is identical, with only the roles of m and c interchanged, and requires the generation of the same key stream k0, k1, . . . , kl used during encryption.

Algorithm A.13. OFB encryption

Input: The plaintext blocks m1, . . . , ml, the key K and the IV.

Output: The ciphertext c = c1 . . . cl.

Steps:

k0 := IV.      /* Initialize the key stream */
for i = 1, . . . , l {
    ki := fK(ki–1).     /* Generate the next key in the stream */
    ci := mi ⊕ msbn (ki)    . /* Mask the plaintext block */
}

Algorithm A.14. OFB decryption

Input: The ciphertext blocks c1, . . . , cl, the key K and the IV.

Output: The plaintext m = m1 . . . ml.

Steps:

k0 := IV.     /* Initialize the key stream */
for i = 1, . . . , l {
   ki := fK(ki–1).    /* Generate the next key in the stream */
   mi := ci ⊕ msbn (ki).    /* Remove the mask from the ciphertext block */
}

Exercise Set A.2

A.1Let us use the notations of Algorithm A.2. For a message m and round keys Ki, we have the values V, Li, Ri, W, c. For another message m′ and another set of round keys , let us denote these values by V′, , , W′, c′. Show that if m′ = c and if for i = 1, . . . , 16, then and for all i = 0, 1, . . . , 16. Deduce that in this case we have c′ = m. (This shows that DES decryption is the same as DES encryption with the key schedule reversed.)
A.2For a bit string z, let denote the bit-wise complement of z. Deduce that , that is, complementing both the plaintext message and the key complements the ciphertext message. [H]
A.3A DES key K is said to be weak, if the DES key schedule on K gives K1 = K2 = · · · = K16. Show that there are exactly four weak DES keys which in hexadecimal notation are:
0101 0101 0101 0101
FEFE FEFE FEFE FEFE
1F1F 1F1F 0E0E 0E0E
E0E0 E0E0 F1F1 F1F1

A.4A DES key K is said to be anti-palindromic, if the DES key schedule on K gives for all i = 1, . . . , 16. Show that the following four DES keys (in hexadecimal notation) are anti-palindromic:
01FE 01FE 01FE 01FE
FE01 FE01 FE01 FE01
1FE0 1FE0 0EF1 0EF1
E01F E01F F10E F10E

A.5Represent , where f(X) = X8 + X4 + X3 + X + 1 (Section A.2.2).
  1. Show that multiplication by x (the octet 02) in can be computed by a left shift followed conditionally (derive the condition) by XORing with the octet 1b.

  2. Design an algorithm for multiplying two elements of using bit manipulations on octets only.

A.6The multiplication of can be made table-driven. Since this field contains 256 elements, a 256 × 256 array suffices to store all the products. That requires a storage of 64 kb. We can considerably reduce the storage by using discrete logs.
  1. Show that the multiplicative order of x (in ) is 51.

  2. Show that x + 1 is a generator of .

  3. Write a computer program to generate the table of discrete logarithms of elements of to the base x + 1 (Table A.6).

    Table A.6. Discrete-log table for AES
     0123456789abcdef
    000190132021ac64bc71b6833eedf03
    16404e00e348d81ef4c7108c8f8691cc1
    27dc21db5f9b9276a4de4a6729ac90978
    3652f8a05210fe12412f082453593da8e
    4968fdbbd36d0ce94135cd2f140468338
    566ddfd30bf068b62b325e29822889110
    67e6e48c3a3b61e423a6b2854fa853dba
    72b790a159b9f5eca4ed4ace5f373a757
    8af58a850f4ead6744faee9d5e7e6ade8
    92cd7757aeb160bf559cb5fb09ca951a0
    a7f0cf66f17c449ecd8431f2da4767bb7
    bccbb3e5afb60b1863b52a16caa55299d
    c97b2879061bedcfcbc95cfcd373f5bd1
    d5339843c41a26d47142a9e5d56f2d3ab
    e441192d923202e89b47cb8267799e3a5
    f674aeddec531fe180d638c80c0f77007

  4. Write a computer program to generate the table of powers of x + 1 (Table A.7).

    Table A.7. Power table for AES
     0123456789abcdef
    00103050f113355ff1a2e7296a1f81335
    15fe13848d87395a4f702060a1e2266aa
    2e5345ce43759eb266abed97090abe631
    353f5040c143c44cc4fd168b8d36eb2cd
    44cd467a9e03b4dd762a6f10818287888
    5839eb9d06bbddc7f8198b3ce49db769a
    6b5c457f9103050f00b1d2769bbd661a3
    7fe192b7d8792adec2f7193aee92060a0
    8fb163a4ed26db7c25de73256fa153f41
    9c35ee23d47c940c05bed2c749cbfda75
    a9fbad564acef2a7e829dbcdf7a8e8980
    b9bb6c158e82365afea256fb1c843c554
    cfc1f2163a5f407091b2d7799b0cb46ca
    d45cf4ade798b8691a8e33e42c651f30e
    e12365aee297b8d8c8f8a8594a7f20d17
    f394bdd7c8497a2fd1c246cb4c752f601

  5. Design an algorithm for multiplying two elements of using table lookup.

A.7Denote the multiplication of by ⊗ (Section A.2.2).
  1. Let α = a3y3 + a2y2 + a1y + a0 and β = b3y3 + b2y2 + b1y + b0 be elements of A and γ = c3y3 + c2y2 + c1y + c0 = α ⊗ β. Show that

    where the matrix arithmetic on the right side follows the arithmetic of .

  2. Verify that the inverse of the element of A represented by the word 03010102 (in hex) is 0b0d090e.

A.8
  1. Show that Transform (A.3) can be represented as

    where the matrix arithmetic on the right side is that of .

  2. Let denote the 8 × 8 matrix of Part (a). Prove that is invertible over with

  3. Conclude that the transformation A ↦ SubOctet(A) is invertible.

A.9
  1. Argue that the transforms SubState and ShiftRows commute with one another.

  2. Show that MixCols–1(AddKey(S, L0, L1, L2, L3)) = AddKey(MixCols–1(S), MixCols–1(L0, L1, L2, L3)) for a suitable meaning of the application of MixCols–1 on four 32-bit keys L0, L1, L2 and L3.

  3. Conclude that one can obtain a decryption key schedule in such a way that Algorithm A.15 correctly performs AES decryption. [H]

Algorithm A.15. Equivalent form of AES decryption

Input: The ciphertext message C = γ0γ1 . . . γ15 and the decryption key schedule .

Output: Plaintext message M = μ0μ1 . . . μ15.

Steps:

Convert C to the state S.                                 /* Use Transform (A.1) */

for i = Nr – 1, Nr – 2, . . . , 0 {
      S := SubState–1(S).
      S := ShiftRows–1(S).
      if (i ≠ 0) { S := MixCols–1(S). }
      
}
Convert S to the message M.                            /* Use Transform (A.2) */

A.10Show that a multiple encryption scheme with exactly k stages provides an effective security of ⌈k/2⌉ keys against the meet-in-the-middle attack.
A.11Consider a message m broken into blocks m1, . . . , ml, encrypted to c1, . . . , cl and sent to an entity.
  1. Suppose that during the transmission exactly one ciphertext block gets corrupted. Show that for the different modes of encryption, the numbers ν of blocks that are incorrectly decrypted due to this transmission error are as listed in the following table.

    Modeν
    ECB1
    CBC≤ 2
    CFB≤ 1 + ⌈n/n′⌉
    OFB1

  2. For each of the four modes, discuss the effects on decryption caused by the insertion or deletion of a ciphertext block during transmission (say, by an active adversary).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.137.67