1 Review 2 Poly-Alphabetic Classical Cryptosystems
Total Page:16
File Type:pdf, Size:1020Kb
EE 595 (PMP) Introduction to Security and Privacy Lecutre #3 Introduction to Cryptanalysis. DES, AES and Modes of Operation. Lecture notes prepared by Professor Radha Poovendran Thursday, April 12, 2018 Tamara Bonaci Department of Electrical Engineering University of Washington, Seattle Outline: 1. Polyalphabetic classical cryptosystems { Vigenere cipher { Permutation cipher 2. Cryptanalysis. 3. Data Encryption Standard (DES) 4. Triple DES 5. Advanced Encryption Standard (AES) 6. Encrypting large plaintexts: Modes of operation { Electronic Code Book (ECB) mode { Cipher Block Chaining (CBC) mode { Counter (CTR) mode 1 Review Last time, we saw that the goal of a symmetric key cryptosystem is to ensure that two parties Alice and Bob can communicate confidentially using a shared secret key K. Equivalently, the goal is to ensure that a third party Eve, who does not have knowledge of the key K, cannot determine the plaintext sent by Alice to Bob. Let's recall that a cryptosystem is defined as a five-tuple (P; C; K; E; D). The set P is the set of possible plaintexts, C is the set of possible ciphertexts, and K is the set of possible keys. The sets E and D are the sets of possible encryption and decryption functions, respectively. In today's lecture, we will first consider how we can model and analyze a behavior of an attacker, trying to break a cryptosystem. We will then describe two widely-used current symmetric-key cryptosystems, namely DES and AES. For each cryptosystem, we will show the parameter values (e.g., key length) that are specified by standards bodies such as the National Institute of Standards and Technology for real-world use. We will then present block-chaining modes that can be used to encrypt longer messages while preserving the security guarantees of each of these cryptosystems. 2 Poly-alphabetic Classical Cryptosystems A polyalphabetic cryptosystem is a cryptosystem where multiple alphabetic characters are encrypted at a time. In other words, each plaintext element is equivalent to n alphabetic characters. The Vigen`ere cipher is the first polyalphabetic cryptosystem that we are encountering in this course. 1 2.1 The Vigen`ereCipher The idea behind this cryptosystem is to use a vector of n keys, i.e., K = (K1;K2; ::; Kn). n n P = C = K = (Z26) where (Z26) is an n-tuple. The difference between the Vigen`erecipher and the shift, substitution, and affine ciphers is that in the Vigen`erecipher each alphabetic character is not uniquely mapped to another alphabetic character. y = eK (x1; x2; ::; xn) = (x1 + K1; x2 + K2; ::; xn + Kn) mod 26; (1) dK (y1; y2; ::; yn) = (y1 − K1; y2 − K2; ::; yn − Kn) mod 26: (2) Example Let the plaintext be vector, and let n = 4; K = (2; 4; 6; 7). From the correspondence table we have x = (21; 4; 2; 19; 14; 17), and the cipher is shown in Table 2.1. PLAINTEXT: 21 4 2 19 14 17 KEY: 2 4 6 7 2 4 CIPHER: 23 8 8 0 16 21 XIIA QV To decrypt, we use the same keyword, but modulo subtraction is performed instead of modulo addition. The number of possible keywords of length n is 26n; so even for small n an exhaustive search attack requires a long time. 2.2 The Permutation Cipher The idea of the permutation cipher (also known as the transposition cipher) cryptosystem is to generate the ciphertext by altering the positions of the characters in the plaintext, i.e. to rearrange the alphabets using a permutation. In contrast to the substitution cipher, there is no replacement of characters (it is similar to just scrambling the letters of a word). Formally, we describe the permutation cipher cryptosystem as follows. n Let P = C = (Z26) , where n is a positive integer. K includes all permutations of f1; :::; ng. For each permutation π 2 K: y = eπ(x1; :::; xn) = (xπ(1); :::; xπ(n)) (3) x = dπ(y1; :::; yn) = (yπ−1(1); :::; yπ−1(n)): (4) π−1 denotes inverse permutation to π. Example: For illustration, let's consider n = 6, and permutation (the key) π is as follows: j 1 2 3 4 5 6 π(j) 3 5 1 6 4 2 To obtain π−1, interchange the rows, and sort the columns such that the first row is in ascending order. We obtain: For encryption, if the plaintext is followashore, we first partition the plaintext into groups of six letters as: follow j ashore. Using the above key π, we re-arrange each group of six alphabets as: LOFWLO j HRAEOS. Similarly, the ciphertext can be decrypted using the inverse permutation π−1. 2 j 1 2 3 4 5 6 π−1(j) 3 6 1 5 2 4 3 Cryptanalysis Now that we are familiar with some simple classical cryptosystems, we might be interested in how secure these cryptosystems are (or how could one go about breaking them). In doing so, we turn to cryptanalysis, and start by considering one of the most important assumptions in the modern cryptography, namely the Kerchoff's principle. 3.1 Kerchoff's Principle: The Kerchoff's principle was introduced in 1883 by A. Kerchoff, and it states that in assessing the security of a cryptosystem, one should always assume that an attacker know the details of the cryptosystem being used. In other words, an attacker knows the tuple (P; C; K; E; D) defining the cryptosystem. Therefore, the security of the system should always be based on the key, and not on the obscurity of a cryptographic algorithm. 3.2 Attack models An attacker can have different goals when attacking a channel between communicating parties. For example, an attacker may wish to: 1. Read one specific message. 2. Find the encryption/decryption key, and thus read all of the exchanged messages. 3. Corrupt Alice's message into another message in such a way that Bob thinks that Alice has sent the altered message. 4. Masquerade as Alice in order to communicate with Bob such that Bob believes he is communicating with Alice. For each of these goals, there are four main types of attacks that an attacker can use, and those types differ in the amount of information an attacker has available when trying to determine the key. Those four attack types are as follows. Type of attack Description Ciphertext only attack Eve only observes the ciphertext y Known plaintext attack Eve knows the ciphertext y corresponding to plaintext x Chosen plaintext attack Eve has temporary access to an encryption box. The encryption box takes as input any chosen plaintext x and outputs the ciphertext y Chosen ciphertext attack Eve has temporary access to a decryption box. The decryption box takes as input any chosen ciphertext y and outputs the plaintext x Based on these models, we can analyze the security of every cryptosystem. 3.3 Cryptanalysis of the Shift Cipher { Ciphertext only: Let K = 3 and the plaintext be shift. We then get VKLIW as the cipher (for a right shift). Assume Eve knows only the ciphertext V KLIW . Eve also knows that a shift cipher algorithm is used for encryption. Given the small cardinality of the key space, Eve can try all the possible 26 shifts in right direction. Upon shifting, the following plaintexts are obtained: 3 1stleft shift 2ndleft shift 3rdleft shift vkliw −! ujkhv −! tijgu −! shift, and so on. Since \shift" is the only dictionary word in the list of 26 possible words, Eve assumes that it is indeed the plaintext that was encrypted. Therefore, Eve can also infer the original key K = 3. { Known plaintext: If Eve knows a (plaintext, ciphertext) pair, then Eve can find the key by subtracting the plaintext from the ciphertext mod 26. For instance, if Eve knows that plaintext b corresponds to ciphertext E, then Eve can determine that K = 3. { Chosen plaintext: Choose letter a as plaintext; the resulting ciphertext will be the key. For example, if the ciphertext is P then K = 15: { Chosen cipher: Choose A as the ciphertext. The plaintext is then the negative of the key K: 3.4 Remarks on Letter Distribution of the English Language English language text has different frequencies for different alphabets. An estimate of relative frequencies (probabilities) of the 26 letters are as indicated in Table 3.4. Note that the letter e has the maximum relative frequency of 0.127. Table 1. Probabilities of occurrence of the 26 letters of the English language alphabet. A B C D E F G H I J K L M 0.082 0.015 0.028 0.043 0.127 0.022 0.020 0.061 0.070 0.002 0.008 0.040 0.024 N O P Q R S T U V W X Y Z 0.067 0.075 0.019 0.001 0.060 0.063 0.091 0.028 0.010 0.023 0.001 0.020 0.001 Similarly we can define frequencies of digrams, trigrams, initial letters, final letters, etc. More generally, we can then use the statistical properties of the English language to perform cryptanalysis. A key observation here that the vowels "a, e, i, o" and the letters "t, s, b, h, d" have relatively high probability of appearance in the English language. Table 3.4 indicates the rank order of vowels based on their frequencies, and Table 3.4 the rank order of consonants "t, s, d, n, h" based on their frequencies. Table 2. Rank order of the probabilities of occurrence of the vowels. E 0.0127 A 0.082 I 0.075 O 0.070 U 0.028 Table 3.