Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPIS 312 Chapter Three: Symmetric KEY CRYPTO By Dr. Daniyal Alghazzawi 2011 Term 2.

Similar presentations


Presentation on theme: "CPIS 312 Chapter Three: Symmetric KEY CRYPTO By Dr. Daniyal Alghazzawi 2011 Term 2."— Presentation transcript:

1 CPIS 312 Chapter Three: Symmetric KEY CRYPTO By Dr. Daniyal Alghazzawi 2011 Term 2

2 Index A. Ciphers B. Classic B.1 Substitution e.g., Caesar Cipher B.2 Transposition e.g., Route Cipher B.3 Hybrid C. Modern C.1 Symmetric (Private Key) Stream Cipher e.g., RC4, A5/1 Block Cipher e.g., DES, AES C.2 Asymmetric (Public Key) e.g., RSA C.3 Hybrid

3 C. Terminology Symmetric uses same key for encryption and decryption process.  To encrypt: C = E(K, P)  To decrypt: P = D (K, E(K,P)) Asymmetric uses different key for encryption and decryption process.  To encrypt: C = E (K E,P)  To decrypt: P = D (K D, E (K E,P))

4 C.1. Symmetric Key Algorithms Other terms for symmetric-key encryption are single-key, one-key, and private-key encryption. Use of the latter term can sometimes conflict with the term private key in public key cryptography Disadvantage: key distribution Symmetric-key algorithms can be divided into:  Stream ciphers: encrypt the bits of the message one at a time  Block ciphers: take a number of bits and encrypt them as a single unit

5 C.1. Symmetric Key Algorithms 1. Stream Cipher A stream cipher is a symmetric cipher where convert one symbol of Plaintext immediately into a symbol of Ciphertext. Algorithms:  Use one of the algorithms to generate the Key Stream (S) from the Key (K)  C = P  S; where C is the ciphertext, and P is the plaintext Some kinds of errors affect the encryption of all future characters

6 1. In a synchronous stream cipher, a stream of pseudo-random digits is generated independently of the plaintext and ciphertext messages, and then combined with the plaintext (to encrypt) or the ciphertext (to decrypt). 2. Asynchronous stream ciphers use several of the previous N ciphertext digits to compute the keystream. (e.g., Cipher-Feedback Mode) C.1. Symmetric Key Algorithms 1. Stream Cipher - Types

7 1. A5/1 initialization: 1. Register X hold 19 bits of the key (x 0, x 1, x 2, …, x 18 ) 2. Register Y hold 22 bits of the key (y 0, y 1, y 2, …, y 21 ) 3. Register Z hold 23 bits of the key (z 0, z 1, z 2, …, z 22 ) 2. A5/1 key stream bit: 1. m = maj (x 8, y 10, z 10 ) 2. if (x 8 =m) then X steps 3. if (y 10 =m) then Y steps 4. if (z 10 =m) then Z steps 5. s = x 18  y 21  z 22 6. Go to step 1 C.1. Symmetric Key Algorithms 1. Stream Cipher – Example (1): A5/1

8 C.1. Symmetric Key Algorithms 1. Stream Cipher – Example (2): RC4 1. RC4 initialization: for i = 0 to 255 S[i] = i K[i] = key [ i mod N ] next i j = 0 for i = 0 to 255 j = ( j + S[i] + K[i] ) mod 256 swap ( S[i], S[j] ) next i Note: The entire algorithm is byte based. key[i] for i=0, 1, …, N-1, where key[i] is a byte

9 C.1. Symmetric Key Algorithms 1. Stream Cipher – Example (2): RC4 2. RC4 key stream byte: 1. i = j = 0 2. i = ( i + 1 ) mod 256 3. j = ( j + S[i] ) mod 256 4. swap ( S[i], S[j] ) 5. t = ( S[i] + S[j] ) mod 256 6. keystreamByte = S[t]

10 Index A. Ciphers B. Classic B.1 Substitution e.g., Caesar Cipher B.2 Transposition e.g., Route Cipher B.3 Hybrid C. Modern C.1 Symmetric (Private Key) Stream Cipher e.g., RC4, A5/1 Block Cipher e.g., DES, AES C.2 Asymmetric (Public Key) e.g., RSA C.3 Hybrid

11 C.1. Symmetric Key Algorithms 2. Block Cipher Encrypts a group of plaintext symbols as one block.  It works on blocks of plaintext and produce blocks of ciphertext  The columnar transposition is an example of block ciphers A block cipher might take a 128-bit block of plaintext as input, and output.

12 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES Runs 16 rounds for each block of the plaintext  Each block consists of 64 bits. It uses a 56-bit key. In each round of DES: A. Key: 1. Dividing them into 2 halves (28bit each) 2. Bit-shift left 3. Compress the key (56bit → 48bit) B. Block of the Plaintext: 1. Dividing them into L i and R i (32bit each) 2. Expansion permutation (32bit → 48bit) 3. Addition of subkey (48bit  48bit) 4. S-boxes (map 6bits → 4bits) 5. P-box (change permutation)

13 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES A. Key: 1. Divide the key into 2 parts according to Parity-bit drop table : 2. Bit-shift left according to the round number:

14 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES 3. Compress the key (56bit → 48bit)

15 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES B. Plaintext 1. Expansion Permutation

16 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES 2. Addition of Subkey: For each round i, we have the right part of the plaintext R i after the expansion, and the subkey for this round K i (both of them are 48 bits.) Find: K i  R i

17 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES 3. S-boxes: The main purpose of S-boxes is to offer protection against cryptanalytic. There are 8 distinct S-boxes that are used in each round. In: 6 bits × 8 S-box = 48 bits Out: 4 bits × 8 S-box = 32 bits

18 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES If the input to S-box 1 is 100011. What is the output? 1100 S-box 1

19 4. P-boxes: For each round i, there are 32 bits out from the S-Boxes. Change their permutation to: C.1. Symmetric Key Algorithms 2. Block Cipher – Example (1): DES

20 5. Constructing the ciphertext : For each round i L(i) = R(i-1) R(i) = L(i-1)  P(S(E(R(i-1))  K(i)))

21 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (2): 3DES Triple DES – effectively increases the key length. It uses two keys and three stages: C = E (P, K) ; encrypt the plaintext P with the key K P = D (C, K) ; for decryption It takes 2 55 key search to attack DES Moving to encryption with two keys according to: 1. C = E (E (P, K 1 ), K 2 ) is not secure, WHY? require 2 55 to break 2. C = E (D (E (P,K 1 ), K 2 ), K 1 ) Triple DES encryption Triple DES decryption

22 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES Block size: 128, 192 or 256 bits Key length: 128, 192 or 256 bits (independent of block size) 10 to 14 rounds (depends on key length) Each round uses 4 functions A. ByteSub (nonlinear layer) B. ShiftRow (linear mixing layer) C. MixColumn (nonlinear layer) D. AddRoundKey (key addition layer) FYI

23 A. ByteSub: 1. Assume 192 bits (4x6 bytes) (24x2x4 bits) block 2. ByteSub is AES’s “S-box” C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES FYI

24 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES First 4 bits of input Last 4 bits of input FYI

25 B. ShiftRow: Cyclic shift rows C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES FYI

26 C. MixColumn: Nonlinear, invertible operation applied to each column C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES FYI

27 D. AES AddRoundKey: XOR subkey with block RoundKey (subkey) determined by key schedule algorithm C.1. Symmetric Key Algorithms 2. Block Cipher – Example (3): AES BlockSubkey FYI

28 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (4): TES 64 bit block, 128 bit key Assumes 32-bit arithmetic Number of rounds is variable (32 is considered secure) Uses “weak” round function, so large number rounds required FYI

29 C.1. Symmetric Key Algorithms 2. Block Cipher – Example (4): TES Encryption Assuming 32 rounds: (K[0],K[1],K[2],K[3]) = 128 bit key (L,R) = plaintext (64-bit block) delta = 0x9e3779b9 sum = 0 for i = 1 to 32 sum += delta L += ((R >5)+K[1]) R += ((L >5)+K[3]) next i ciphertext = (L,R) FYI

30 C.1. Symmetric Key Algorithms 2. Block Cipher – Modes 1: ECB ECB (Electronic Codebook) Mode  Suppose we have multiple plaintext block P 0, P 1, P 2, …, P N, and a fixed key K We encrypt using the formula: C i = E(P i, K)for i = 0, 1, 2, …, N We decrypt using the formula: P i = D(C i, K) for i = 0, 1, 2, …, N  Problem: in case C i = C j the attacker knows that P i = P j Solution: add a random text to the plaintexts P i = P j, so C i ≠ C j

31 C.1. Symmetric Key Algorithms 2. Block Cipher – Modes 2: CBC CBC (Cipher Block Chaining) Mode  The ciphertext from a block is used to obscure the plaintext of the next block before it is encrypted. The formulas are: C i = E(P i  C i-1, K)for i = 0, 1, 2, …, N P i = D(C i, K)  C i-1 for i = 0, 1, 2, …, N  What is about C 0 ; we don’t have C -1 ?  An initialization vector, or IV, is used to take the place of C -1.  IV should be randomly selected, and it sends as the first block.  Problem: if a single-bit error causes two entire blocks to be garbled; it is a big problem in wireless environment. Solution: Use stream ciphers.

32 C.1. Symmetric Key Algorithms 2. Block Cipher – Advantages (Integrity) Block ciphers used for confidentiality and integrity. A message authentication code, or MAC, uses a block cipher to ensure data integrity by encrypting the data un CBC mode, and use the final block only, called MAC. C 0 = E(P 0  IV, K), C 1 = E(P 1  C 0, K), … C N-1 = E(P N-1  C N-2, K) = MAC The recipient repeats the process on the plaintext and re-calculate the MAC.

33 Confusion: the interceptor should not be able to predict what will happen to the ciphertext by changing one character in the plaintext  An algorithm providing good confusion has a complex functional relationship between the plaintext/key pair and the ciphertext  Question: Does Caesar cipher provide good confusion? Diffusion: distributing the information from single plaintext letters over the entire output  Good diffusion means that the interceptor needs access to much of the ciphertext to be able to infer the algorithm  Question: Which one provides better diffusion?  Substitution cipher or Transposition cipher Confusion and Diffusion

34 C.1. Symmetric Key Algorithms Stream Cipher vs. Block Cipher

35 C.1. Symmetric Key Algorithms Other Examples

36 Conclusion Modern symmetric ciphers come in two variants: block ciphers and stream ciphers. The mostly used block cipher is used to be DES. To use a block cipher one needs to also specify a mode of operation:  The simplest mode is ECB mode, which has problems associated with it:  same plaintext will always generate same ciphertext;  suffers from possible insertion/deletion attacks.  Hence it is common to use a more advanced mode such as CBC mode.

37 Conclusion Symmetrical cryptography is reasonably secure, more efficient, and more suitable for encryption of large messages - provide message confidentiality. But it has key exchange problem and does not support non-repudiation.

38 Real Story  Human Fallibility Led to Cracked Codes:: Enigma Machine 26 letters

39 Real Story Kahn describes the history of the Enigma machine, a mechanical tool used by the Germans in World War II to scramble messages and prevent the enemy from understanding them. Enigma was based on revolving wheels, or rotors, that were wired together and connected to a typewriter keyboard. There were so many ways to encrypt a message that even if 1,000 analysts tried four different ways each minute, all day, every day, it would have taken the team 1.8 billion years to test them all. So how did the Allies break the encryption? First, they made use of the likely chatter over the wires about each day's events. By guessing that the Germans would be discussing certain places or issues, the Allies found sections of scrambled text that they could relate to the original messages, or cleartext. Next, they concentrated on Luftwaffe messages. Counting on the likelihood that the Luftwaffe signalmen were not as well trained as those in the Army or Navy, the Allies watched for slip-ups that increased the odds of understanding the encrypted messages. For instance, Luftwaffe signalmen often used "a girlfriend's name for a key setting or beginning a second message with the same setting as that left at the ending of the first." Such knowledge enabled the Allies to determine some of the Luftwaffe's plans during the Battle of Britain. Thus, sophisticated technology can be trumped when control protocols are not followed carefully and completely.  Human Fallibility Led to Cracked Codes: (Cont.)

40  Symmetric & Asymmetric  Block & Stream Cipher  key distribution  key stream bit / key stream byte  Initialization Vector  Confusion & Diffusion  MAC Terms and Concepts 40


Download ppt "CPIS 312 Chapter Three: Symmetric KEY CRYPTO By Dr. Daniyal Alghazzawi 2011 Term 2."

Similar presentations


Ads by Google