Lecture 7, 8 By Usman Zia Department of Information Technology University of Gujrat 1
Let P denote the set of all possible plaintext symbols, C denote the set of all possible cipher text symbols, and K denote the set of all possible keys ( the key space ) A symmetric-key block cipher E is a function : Moreover, for every key K in , we have invertible functions In other words, the key determines the bijective mapping of plaintext to cipher text and also determines the inverse mapping of cipher text to plaintext If | P | = | C |, then the functions DK and EK are permutations of the message space, defined by the key K Block Ciphers 2
Example: Block Cipher Encryption 3
A specific type of SP-network cipher design, called a Feistel cipher , splits the data block into two halves (e.g., 32-bits each for a 64-bit data block ) and applies a substitution function and a permutation function to these half-blocks. Suppose the input to a round is a message block M which is divided into two halves M=(L,R ). The round function F is given by F (M,K) = F ((L,R),K) = Y ( X ((L,R),K)) = Y(X( M,K)). The substitution function X is given by X ((L,R),K) = (L (+) CF (R,K),R) The function CF is called the cipher function. The permutation function Y is given by Y ((L,R)) = (R,L) This performs a swapping of halves and is clearly an involution Feistel Ciphers 4
Feistel Ciphers (3) 5
Example: Feistel Ciphers 6
The plaintext is splited into two halves and The cipher text is output as the two halves and Note that there is no swap in the last round of a Feistel cipher. This is to ensure that the cipher is an involution – i.e., we don’t need to design a separate cipher structure for decryption ; to decrypt, the same cipher structure , including cipher function, is used except that the round keys ( sub keys ) are applied in the reverse order. Feistel Ciphers (3) 7
The Data Encryption Standard (DES) was designed by IBM Research in the late 70’s and standardized by the US Government (National Bureau for Standards) It is a Feistel cipher that uses 64-bit data blocks and a 64-bit key. There are 16 rounds, and each round operates on two halves of the data block using a 48-bit sub key. It was unbroken for more than 10 years since its publication and some aspects of its design were kept secret by IBM at the request of the US National Security Agency (NSA); some people believed that IBM and NSA had hidden a trapdoor in DES that only they knew about (that they could use to crack DES) Data Encryption Standard (DES) 8
DES block cipher 9
The 32-bit input data (message) block is first bitwise permutated (i.e., the bits within the block are rearranged) This is done using the following permutation table: Output Input 1 2 3 4 5 6 7 8 58 50 42 34 26 18 10 2 9 10 11 12 13 14 15 16 60 52 44 36 28 20 12 4 17 18 19 20 21 22 23 24 62 54 46 38 30 22 14 6 25 26 27 28 29 30 31 32 64 56 48 40 32 24 16 8 33 34 35 36 37 38 39 40 57 49 41 33 25 17 9 1 41 42 43 44 45 46 47 48 59 51 43 35 27 19 11 3 49 50 51 52 53 54 55 56 61 53 45 37 29 21 13 5 57 58 59 60 61 62 63 64 63 55 47 39 31 23 15 7 Example : 35th bit of output block is equal to the 41st bit of the input block. Initial Permutation: IP 10
DES Cipher Function 11
The expansion permutation acts on the 32-bit input to the cipher function. It expands the 32-bit input block to a 48-bit output block by duplicating some input bits at specified positions Expansion Permutation: E 12 Expansion Expansion
The substitution boxes (S-boxes) map a 6-bit input block to a 4-bit output block There are 8 S-boxes, so the 48-bit input block is mapped to a 32-bit output block Substitution Boxes: S 13
The 32-bit output of the S-boxes is then bitwise permutated (i.e., the bits within the block are rearranged) This is done using the following permutation table: Output Input 1 2 3 4 16 7 20 21 5 6 7 8 29 12 28 17 9 10 11 12 1 15 23 26 13 14 15 16 5 18 31 10 17 18 19 20 2 8 24 14 21 22 23 24 32 27 3 9 25 26 27 28 19 13 30 6 29 30 31 32 22 11 4 25 Example : 25th bit of output block is equal to the 19th bit of the input block Permutation: P 17
The 32-bit output after 16 rounds is finally bitwise permutated (i.e., the bits within the block are rearranged ) This is done using the following permutation table: Output Input 1 2 3 4 5 6 7 8 40 848 16 56 24 64 32 9 10 11 12 13 14 15 16 39 7 47 15 55 23 63 31 17 18 19 20 21 22 23 24 38 6 46 14 54 22 62 30 25 26 27 28 29 30 31 32 37 5 45 13 53 21 61 29 33 34 35 36 37 38 39 40 36 4 44 12 52 20 60 28 41 42 43 44 45 46 47 48 35 3 43 11 51 19 59 27 49 50 51 52 53 54 55 56 34 2 42 10 50 18 58 26 57 58 59 60 61 62 63 64 33 1 41 9 49 17 57 25 Example : 41st bit of output block is equal to the 35th bit of the input block. Final Permutation: 18
The DES key schedule takes a 64-bit key and generates 16 48-bit sub keys , one per round. The key schedule uses two (fixed/known) permutation tables ( called PC1 and PC2) and a table of “shifts” (called LS ). DES Key Schedule 19
DES Key Schedule 20
The permutation PC1 takes the 64-bit key and produces a 56-bit key by discarding every 8th bit in the key. This means that the effective key size of DES is not 64 bits, but 56 bits (since the 8 bits that are discarded have no effect on the encryption or decryption of data ) The 56-bit effective key is then processed to produce the 16 48-bit round keys ( sub keys ) Permuted Choice 1: PC1 21
The PC1 permutation is described by the following table: Effective Key Bit Input Key Bit 1 2 3 4 5 6 7 57 49 41 33 25 17 9 8 9 10 11 12 13 14 1 58 50 42 34 26 18 15 16 17 18 19 20 21 10 2 59 51 43 35 27 22 23 24 25 26 27 28 19 11 3 60 52 44 36 29 30 31 32 33 34 35 63 55 47 39 31 23 15 36 37 38 39 40 41 42 7 62 54 46 38 30 22 43 44 45 46 47 48 49 14 6 61 53 45 37 29 50 51 52 53 54 55 56 21 13 5 28 20 12 4 Example: The 9th bit of the 56-bit effective key is the 58th bit of the original 64-bit key Permuted Choice 1: PC1 22
The 56-bit output to PC1 is then input to a loop that is iterated 16 times. Each iteration of this loop generates a 48-bit sub key Depending on the iteration, the 56-bit key is bitwise rotated to the left a fixed number of times according to the following table: Iteration 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Left Shifts 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1 Note in the third iteration, the 56-bit key is rotated 4 bits to the left compared to the original 56-bit input Iterated Left Shift: LS 23
After being bitwise rotated (shifted), the 56-bit key is input to a permutation function that selects 48 bits from the key to produce the round key ( sub key). This table, called PC2, is described as follows : Example : The 30th bit of the 48-bit subkey is the 55th bit of the 56-bit input Permuted Choice 2: PC2 Input Bit 14 17 11 24 1 5 3 28 15 6 21 10 23 19 12 4 26 8 16 7 27 20 13 2 41 52 31 37 47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32 Sub key Bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 24