Lecture Four
Total Page:16
File Type:pdf, Size:1020Kb
Lecture Four Today’s Topics . Historic Symmetric ciphers . Modern symmetric ciphers . DES, AES . Asymmetric ciphers . RSA . Next class: Protocols Example Ciphers . Shift cipher: each plaintext characters is replaced by a character k to the right. (When k=3, it’s a Caesar cipher). “Watch out for Brutus!” => “Jngpu bhg sbe Oehghf!” . Only 25 choices! Not hard to break by brute force. Substitution Cipher: each character in plaintext is replaced by a corresponding character of ciphertext. E.g., cryptograms in newspapers. plaintext code: a b c d e f g h i f k l m n o p q r s t u v w x y z ciphertext code: m n b v c x z a s d f g h j k l p o i u y t r e w q . 26! Possible pairs. Is is really that hard to break? Substitution ciphers . The Caesar cipher has a small key space, but doesn’t create a statistical independence between the plaintext and the ciphertext. The best ciphers allow no statistical attacks, thereby forcing a brute force, exhaustive search; all the security lies with the key space. As cryptographic algorithms matured, the statistical independence between the plaintext and cipher text increased. Ciphers . The caesar cipher, hill cipher, and playfair cipher all work with a single alphabet for doing substitutions . They are monoalphabetic substitutions. A more complex (and more robust) alternative is to use different substitution mappings on various portions of the plaintext. Polyalphabetic substitutions. More ciphers . Vigenère cipher: each character of plaintext is encrypted with a different a cipher key. In the simplest version, each key is a shift cipher Plaintext: a b c d e f g h i f k l m n o p q r s t u v w x y z C1(k=6): f g h i j k l m n o p q r s t u v w x y z a b c d e C2(k=20): t u v w x y z a b c d e f g h i j k l m n o p q r s Plaintext is encrypted as sequence of C1,C2,C1,C2,… . The example above has a period of 2: there are two alphabets used. Breaking the Vigenère cipher . We assume the algorithm is known. (Safest assumption!) . The ciphers keys repeat with period t. We need to find that period. Once we find the period, we can attack each shift cipher independently. (Shift ciphers are cake to break). We must look for occurrences in the ciphertext of plaintext that is repeated in a multiple of the cipher key. the man is in the plane on the ground. QER ASX AS SD QER SDFWD WE QER SDFWED . period = 10. Breaking the Vigenère cipher . themanisintheplaneontheground QERASXASSDQERSDFWDWEQERSDFWED . period = 10. Chances of this happening three times are small. More formally, we can apply statistical measures, like auto-correlation, to the ciphertext. Intuitively, guess period is no larger than L. For each letter of ciphertext, Ci , count how often Ci=Ci+T, where 1<T<L. Plot the counts for all Ts, the period will appear as a spike on the graph. Permutation (i.e., transposition) . Permuting the plaintext is another type of cipher technique; also referred to as permutation. Take the input, rearrange the output in a specific way. E.g., by writing the letters in a rectangle 1 3 2 4 5 6 7 8 <- key!(simple) t h e l a u n c h c o d e i s i n t h e d e s k = thn eoh hct lde aed uie nss cik . You can even do this twice with the same key. Better, but… . Using the technique simply is weak as it preserves the frequencies of the letters. The stronger, modern ciphers combine permutations and substitutions. Rotors . Rotor machines have a keyboard and a series of rotors to mechanically assist in the encryption of text. Each rotor is an arbitrary permutation of the alphabet . Output of one rotor is connected to the input of the next. For each character, the rotors shift like an odometer. Initial position of the rotors is the key. For one rotor, period = 26 . For two rotors, period = 262 = 676 . three, period = 263 = 17,576 . for six, 266 = 308,915,776 . Not bad! Two diagrams of the Enigma http://fn2.freenet.edmonton.ab.ca/~jsavard/crypto/roto02.htm Modern Cryptography . Symmetric key algorithm . Examples: . DES (Data Encryption Standard) . IDEA (International Data Encryption Alg.) . AES (Advanced Encryption Standard) . Public/Private key algorithm . Examples: RSA (El Gamal, Elliptical curves) Diffusion and Confusion . (remember: P= plaintext, C= ciphertext) . The operations of cryptographic algorithms can be explained with two terms: . Diffusion spreads the influence of single bits of P over as much C as possible. For instance, if we flip a bit of P, each of the bits of C should have about a ½ chance of flipping as well. Permutation is a tool for diffusion. Confusion obscures the relationship between P and C; it eliminates redundancies and statistical patterns . Substitution (that is table-look up) is a tool for confusion. Confusion alone is sufficient for security, but expensive in terms of storage. A 128-bit key-dependent lookup table of 64- bit blocks of P to C requires 1041 bytes of memory. Symmetric Key Algorithms There are two basic cipher structures: . Block ciphers . Plaintext is treated as n-bit blocks of data . Ciphertext is same length as plaintext . Can be made to behave as a stream cipher . Stream ciphers . Encrypts one bit/byte at a time . Useful if you have a never ending, bursty stream of data. Often easier to analyze mathematically . Block ciphers can be made to behave as stream ciphers Feistel Ciphers (also called Feistel Networks) . Most block ciphers are Feistel Networks . Approximate substitution cipher behavior using a combination of substitution and permutation (confusion and diffusion) . Defined in terms of . Block size . Key size . Number of rounds . Subkey generation algorithm . Round function F . Two other considerations . Speed in software/hardware . Ease of analysis Plaintext Feistel Networks L0 R0 Key1 . Consists of n –rounds. Round 1 ⊕ F . All rounds are identical. L1 R1 . Pi is broken in to two halves Li and Ri. Key i . The key K is broken in to sub- Round i ⊕ F keys Ki , one for each round. L i Ri . A round function F is applied to Ri using Ki Keyn . L = R i i-1 Round n ⊕ F . Ri = Li-1 xor F ( Ri-1 , Ki ) Ln Rn . Decryption is essentially the same as encryption using sub- L R keys Ki in reverse order. n+1 n+1 Ciphertext Feistel Networks . Often Feistel networks make use of substitution boxes, called S-boxes. (for instance, in the function F) . The strength of a Feistel network is tied to the design of it’s S-boxes. The design of the S-box can influence resistance against linear and differential cryptanalysis. In general, an S-Box substitutes p input bits for q output bits. For example: . Given bits “110011” as input and an S-box 1001 Take first and last bits “11” to choose row 3 (in decimal counting from 0) . Take middle four bits “1001”: column 9. 6 . E.g., the value from S-box 6 … 8 12 3 7 4 10 1 13 … of DES is 14 (“1110”). 11 14 1 7 6 8 … . Substitute “1110” for “110011” S-Box 6 from DES Data Encryption Standard (DES) . Adopted by the US govt in ‘76, dropped recently for AES. A 16-round Feistel-network with an initial and final permutation of the data. Block cipher: data is encrypted in 64-bit blocks . Symmetric Key algorithm, key length is 56-bits. The 56-bit key is transformed in to sixteen 48-bit subkeys. DES consists of . initial permutation of the 64 bits (from the P-box) . 16 identical "rounds" of operation where the data is confused and diffused with the key and the previous round. A final permutation (from the P-box). Same algorithm for encryption and decryption (sub-keys are used in reverse order for decryption). DES . The operation of each round is identical, taking the output of the previous round as input. During each round, the rightmost 32 bits of the input are moved to the left 32 bits of the output. Then a function f() is run on the left and right halves, and the key. The key is shifted for each round. A final permutation finishes it. Classic Feistel cipher operation! Curious about DES and f()? . What’s f()? For round i . Take 48 bits of the shifted key . Expand the right 32-bits of the data to 48 bits . XOR the two together, and then send it through the S-Box (the predefined substitution table). The S-BOX produces 32 new bits, which is XORed with the left half of the data. Then Li= Ri-1 . Ri = Li-1 ⊕ f (Ri, Ki) . Incredibly, this process is reversible. DES . An initial permutation (IP) . Key transformation . 16 rounds of: . Expansion permutation of input (Avalanche Effect) . Expands 32 bits to 48 bits, thus a single bit affects 2 substitutions. Dependency of output bits on input bits spread faster . S-box substitution (confusion) . P-box permutation (diffusion) . A final permutation (IP-1) More on DES . Exhaustive search is the best way to break it; there are 256 (about 7x1017 ) keys. Originally, complaints that the NSA fixed the S-boxes to provide a backdoor. This has never been found, the S-boxes appear to be strong against even differential cryptanalysis (Which means the NSA knew about DC before 1978.