400 likes | 636 Views
Chapter 3. Block Ciphers and the Advanced Encryption Standard. Outline. 3.1 Introduction 3.2 Substitution-Permutation Networks 3.3 Linear cryptanalysis 3.4 Differential cryptanalysis 3.5 The Data Encryption Standard 3.6 The Advanced Encryption Standard 3.7 Modes of Operation.
E N D
Chapter 3 Block Ciphers and the Advanced Encryption Standard
Outline • 3.1 Introduction • 3.2 Substitution-Permutation Networks • 3.3 Linear cryptanalysis • 3.4 Differential cryptanalysis • 3.5 The Data Encryption Standard • 3.6 The Advanced Encryption Standard • 3.7 Modes of Operation
3.5 The Data Encryption Standard • DES was developed at IBM, as a modification of an earlier system known as Lucifer. • DES was first published in the Federal Register of March 17, 1975. • DES was adopted as a standard for “unclassified” applications on January 15, 1977.
The Data Encryption Standard • 3.5.1 Description of DES • DES is a special type of iterated cipher called a Feistel cipher. • In a Feistel cipher, each state ui is divided into two halves of equal length, say Li and Ri. • Round function g: g(Li-1, Ri-1, Ki)=(Li, Ri), where • Invertible:
One round Overview of DES
The Data Encryption Standard • Initial permutation IP: IP(x)=L0R0 • Inverse permutation IP-1: y=IP-1(R16L16) • Note L16 and R16 are swapped before IP-1 is applied. • Each Li and Ri is 32 bits in length. • The function takes as input a 32-bit string (the right half of the current state) and a round key. • Key schedule (K1,K2,…,K16) consists of 48-bit round keys that are derived from the 56-bit key, K.
The Data Encryption Standard • Suppose we denote the first argument of f function (Figure 3.7) by A, and the second argument by J. • A is expanded to 48-bit according to a fixed expansion functionE. • Compute and write the result as concatenation of eight 6-bit strings B=B1B2B3B4B5B6B7B8. • The next step uses eight S-boxes (S1,…,S8), Given a bitstring of length 6, Bj=b1b2b3b4b5b6. b1b6 determine the row r of Sj, and b2b3b4b5 determine the column c of Sj. We compute Cj=Sj(Bj). • The bitstring C=C1C2C3C4C5C6C7C8 is permuted according to the permutation P. Then f (A,J)=P(C).
A J E E(A) + B1 B2 B3 B4 B5 B6 B7 B8 S1 S2 S3 S4 S5 S6 S7 S8 C1 C2 C3 C4 C5 C6 C7 C8 P f(A,J) Figure 3.7 The DES f function
Example 3.4 S-boxes
The Data Encryption Standard • Example 3.4: We show how to compute an output of S-box S1 with input 101000. • b1b6=10 which is 2 • b2b3b4b5=1000 which is 4 • Output is row 2 and column 4 of S1. • Note: rows are numbered 0,1,2,3 and columns are 0,1,2,…15 • So the output is 13 which is 1101 in binary.
The Data Encryption Standard • The expansion functionE is specified by the following table: • If A=(a1,a2,…,a32) then E(A)=(a32,a1,a2,a3,a4,a5,a4,…,a31,a32,a1).
The Data Encryption Standard • The permutation P is as follows: • If C=(c1,c2,…,c32) then P(C)=(c16,c7,c20,c21,c29,…,c11,c4,c25).
The Data Encryption Standard • Key scheduling:
The Data Encryption Standard • 3.5.2: Analysis of DES • The S-boxes, being the non-linear components of the cryptosystem, are vital to its security. • DES was to make differential cryptanalysis infeasible. • Differential cryptanalysis was known to IBM when they design DES, but it was kept secret for almost 20 years until Biham and Shamir invented the technique in the early 1990’s. • The most pertinent criticism of DES is that the size of the keyspace, 256, is too small.
The Data Encryption Standard • Many people try to design a special purpose machine to do exhaustive key search. • Ex: “DES Cracker” contained 1536 chips and could search 88 billion keys per second. It won RSA Laboratory’s “DES Challenge II-2” by successfully finding a DES key in 56 hours. • Other than exhaustive key search, differential cryptanalysis and linear cryptanalysis are the most important attacks. (linear attack is more efficient) • In 1994, Matsui implemented the attack by using 243 plaintext-ciphertext pairs with the same key. It took 40 days to generate the pairs and 10 days to find the key. • DES is still secure theoretically due to the extremely large number of pairs required. An adversary is impossible to collect that amount of pairs.
3.6 The Advanced Encryption Standard • On January 2, 1997, NIST began the process of choosing a replacement for DES and called the Advanced Encryption Standard, or AES. • It was required that the AES have a block length of 128 bits, and supported key lengths of 128, 192, and 256 bits. • After several AES candidate conferences were held. On Oct. 2, 2000, Rijndael was selected. • 3 main criteria: security, cost, algorithm and implementation characteristics
The Advanced Encryption Standard • 3.6.1 Description of AES • Block length: • 128 bits (Nb=4) • 192 bits (Nb=6) • 256 bits (Nb=8) • Key length: • 128 bits (Nk=4) • 192 bits (Nk=6) • 256 bits (Nk=8) • Number of rounds Nr:
The Advanced Encryption Standard • Overview of AES: • ADDROUNDKEY, which xors the RoundKey with State. • For each of the first Nr-1 rounds: perform SUBBYTES(State), SHIFTROWS(State), MIXCOLUMN(State), ADDROUNDKEY. • Final round: SUBBYTES, SHIFTROWS, ADDROUNDKEY. • All operations in AES are byte-oriented. • The plaintext x consists of 16 byte, x0,x1,…,x15. • Initially State is plaintext x (for 128-bit case):
The Advanced Encryption Standard • SUBBYTES: • It performs a substitution on each byte of State using an S-box, say . • is a 16x16 array (Figure 3.8). A byte is represented as two hexadecimal digits XY. So XY after substitution is .
Example 3.5 Figure 3.8 The AES S-box
The Advanced Encryption Standard • The AES S-box can be defined algebraically. The permutation incorporates operations in the finite field • FIELDINV: the multiplicative inverse of a filed element • BINARYTOFIELD: convert a byte to a field element • FIELDTOBINARY: inverse operation corresponds to the byte
The Advanced Encryption Standard • Algorithm 3.4: SUBBYTES(a7a6a5a4a3a2a1a0) externalFIELDINV, BINARYTOFIELD, FIELDTOBINARY BINARYTOFILED(a7a6a5a4a3a2a1a0) if thenFIELDINV(z) (a7a6a5a4a3a2a1a0) FIELDTOBINARY(z) (c7c6c5c4c3c2c1c0) (01100011) comment: In the following loop, all subscripts are to be reduced modulo 8 forto 7 do return (b7b6b5b4b3b2b1b0)
The Advanced Encryption Standard • Example 3.5: (illustrates Algorithm 3.4) • Suppose we begin with (hex) 53. In binary, it’s 01010011, which represents the field element The multiplicative inverse (in ) can be shown to be Thus we have
The Advanced Encryption Standard etc. The result is which is ED in hex. • This computation can be checked by verifying the entry in row 5 and column 3 of Figure 3.8.
The Advanced Encryption Standard • SHIFTROWS: • Row 0: no shift • Row i: shift Ci Case Nb=4 or 6
The Advanced Encryption Standard • MIXCOLUMNS: (Algorithm 3.5) • It is carried out on each of the four columns of State. • Each column of State is replaced by a new column which is formed by multiplying that column by a certain matrix of elements of the field . • FIELDMULT computes two inputs product in the field. Note: 2 is x in and 3 is x+1 in
The Advanced Encryption Standard • Algorithm 3.5: MIXCOLUMN(c) externalFIELDMULT, BINARYTOFIELD, FIELDTOBINARY for to 3 doBINARYTOFIELD(si,c) u0FIELDMULT(x,t0) FIELDMULT(x+1,t1) t2 t3 u1FIELDMULT(x,t1) FIELDMULT(x+1,t2) t3 t0 u2FIELDMULT(x,t2) FIELDMULT(x+1,t3) t0 t1 u3FIELDMULT(x,t3) FIELDMULT(x+1,t0) t1 t2 for to 3 do si,cFIELDTOBINARY(ui)
The Advanced Encryption Standard • KEYEXPANSION: (for 10-round AES) • 10-round, 128-bit key • We need 11 round keys, each of 16 bytes • Key scheduling algorithm is word-oriented (4 bytes), so a round key consists of 4 words • The concatenation of round keys is called the expanded key, which consists of 44 words, w[0], w[1],…, w[43]. • See Algorithm 3.6
The Advanced Encryption Standard • Notations of Algorithm 3.6: • Input: 128-bit key, key, key[0],…,key[15] • Output: words, w • ROTWORD: a cyclic shift of four bytes B0,B1,B2,B3 ROTWORD (B0,B1,B2,B3)= (B1,B2,B3,B0) • SUBWORD: applies the S-box to each byte SUBWORD (B0,B1,B2,B3)=(B0’,B1’,B2’,B3’) where Bi’=SUBBYTES(Bi) • RCon: an array of 10 words, RCon[1],…,RCon[10], they are constants defined at the beginning
Algorithm 3.6: KEYEXPANSION(key) externalROTWORD, SUBWORD RCon[1] 01000000 RCon[2] 02000000 RCon[3] 04000000 RCon[4] 08000000 RCon[5] 10000000 RCon[6] 20000000 RCon[7] 40000000 RCon[8] 80000000 RCon[9] 1B000000 RCon[10] 36000000 forto 3 dow[i] (key[4i],key[4i+1],key[4i+2],key[4i+3]) forto 43 dotempw[i-1] if 0 (mod 4) thentempSUBWORD(ROTWORD(temp)) RCon[1/4] w[i] w[i-4] temp return (w[0],…,w[43])
The Advanced Encryption Standard • Above are the operations need to encrypt in AES. • To decrypt, we perform all operations and the key schedule in the reverse order. • Each operation, SHIFTROWS, SUBBYTES, MIXCOLUMNS must be replaced by their inverse operations. • ADDROUNDKEY is its own reverse.
The Advanced Encryption Standard • 3.6.2 Analysis of AES • AES is secure against all known attacks. • Various aspects of design incorporate specific features to against specific attacks. • Ex1: Finite field inversion in S-box yields linear approximation and difference distribution tables close to uniform. • Ex2: MIXCOLUMNS makes it impossible to find differential and linear attacks that involve “few” active S-boxes (wide trail strategy).
3.7 Modes of Operation • Four modes of operation for DES: • Electronic codebook mode (ECB mode) • Cipher feedback mode (CFB mode) • Cipher block chaining mode (CBC mode) • Output feedback mode (OFB mode) • ECB mode corresponds to the naive use of a block cipher: • x1,x2,…of 64-bit plaintext blocks, encrypted with the same key K, producing a string of ciphertext blocks, y1,y2,…
y1 y2 x1 x2 decrypt + + dK dK IV=y0 + + IV=y0 eK eK encrypt x1 x2 y1 y2 Modes of Operation • CBC mode: • initialization vector IV and y0=IV Figure 3.9 CBC mode
x2 y2 x1 y1 IV=z0 IV=z0 eK + + + eK eK + eK y2 x2 y1 x1 encrypt decrypt Modes of Operation • OFB mode: • a synchronous stream cipher (cf. section 1.1.7) • z0=IV, then keystream z1z2… • encryption:
x2 x1 y2 y1 IV=y0 + eK + eK IV=y0 + eK + eK y2 y1 encrypt x2 x1 decrypt Modes of Operation • CFB mode: • y0=IV • keystream: • encryption: Figure 3.10 CFB mode
Modes of Operation • Some properties: • In ECB and OFB modes, changing one 64-bit plaintext block, xi, causes the corresponding ciphertext block, yi, to be altered, but other ciphertext blocks are not affected. • It is useful in some cases, like communicating on an unreliable channel. • In CBC and CFB modes, if a plaintext block xi is changed, then yi and all subsequent ciphertext blocks will be affected. • These modes can be used to produce a message authentication code (MAC). (see Chap 4)