Mustansiriyah University Engineering College Computer Engineering Dep Classical

  • Slides: 6
Download presentation
Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Classical Cryptography Classical cryptography algorithms can be divided into two main categories: substitution and transposition. Substitution Cipher is one in which the letters of plaintext are replaced by other letters, numbers or symbols. Examples for this type of cipher are Caesar and Polyalphabetic. q Caeser Cipher is the simplest and earliest known use of a substitution cipher, which is invented by Julius Caesar. This cipher involves replacing each letter of the alphabet with the letter standing three places further down the alphabet. For example, plaintext: meet me after the toga party ciphertext: phhw ph diwhu wkh wrjd sduwb Note that the alphabet is wrapped around, so that the letter following Z is A. We can define the transformation by listing all possibilities, as follows: plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z ciphertext: d e f g h i j k l m n o p q r s t u v w x y z a b c 1

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Let us assign a numerical equivalent to each letter: Then the encryption algorithm Ek can be expressed as follows. For each plaintext letter P, substitute the ciphertext letter C: Ci = Ek(Pi) = (Pi + 3) mod 26 Not that We define a mod n to be the remainder when a is divided by n. For example, 11 mod 7 = 4. A shift may be of any amount, so that the general Caesar algorithm is Ci = Ek(Pi) = (Pi + K) mod 26 where K is the key, which takes on a value in the range 1 to 25. The decryption algorithm Dk is Pi = Dk(Ci) = (Ci - K) mod 26 2

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Substitution Cipher q Playfair Cipher: it is a symmetric multiple-letter encryption, which treats a pair of letters in the plaintext as a single unit and translate them into a different unit in the ciphertext. - The playfair cipher starts with creating a key table. The key table is a 5× 5 grid of letters that will act as the key for encrypting the plaintext. Each of the 25 letters must be unique and one letter of the alphabet (usually Q) is omitted from the table. - The Playfair cipher uses a few simple rules for encryption. 1) If both letters are in the same column, take the letter below each one (going back to the top if at the bottom), 2) If both letters are in the same row, take the letter to the right of each one (going back to the left if at the farthest right), 3) If neither of the preceding two rules are true, form a rectangle with the two letters and take the letters on the horizontal opposite corner of the rectangle, 4) If both letters are the same (or only one letter is left), add an "X" after the first letter. 3

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Substitution Cipher Example: Let the key string be “Hello World” and we want to encrypt the message “hide the gold”. Solution: Our key table would look like this: There is an odd number of letters in the plaintext, a Z is added to the last letter and the message is split into pairs of two letters. plaintext: HI DE TH EG OL DZ ciphertext: LF GD MW DN WO CV Security of Playfair: It is a great advance over simple monoalphabetic (i. e. caeser) ciphers. Whereas there are only 26 letters, there are 26 × 26 = 676 digrams (pairs of letters), so that identification of individual digrams is more difficult. 4

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Substitution Cipher q The Hill Algorithm: This encryption algorithm takes m successive plaintext letters and substitutes them by m ciphertext letters. The substitution is determined by m linear equations in which each character is assigned a numerical value (a = 0, b = 1, …, z = 25). For m = 3, the system can be described as In general terms, the Hill system can be expressed as C = E(K , P) = P K mod 26 P = D(K , C) = C K-1 mod 26 Example: consider the plaintext “paymoremoney” and use the encryption key, Solution: The first three letters of the plaintext are represented by the vector (15 0 24). Then, (15 0 24) K = (303 531) mod 26 = (17 17 11) = RRL. Continuing in this fashion, the ciphertext for the entire plaintext is RRLMWBKASPDH. 5

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year

Mustansiriyah University Engineering College Computer Engineering Dep. Classical Cryptography Substitution Cipher Class: Third Year Course name: Data Encryption Lecturer: Fatimah Al-Ubaidy Substitution Cipher q Polyalphabetic (Vigenère) Cipher: this algorithm uses different cipher letters for different occurrences of same plaintext letter. Make cryptanalysis harder with more letters to guess. Use a key to select which cipher letter is used for each letter of the message. Repeat from start after end of key is reached. The encryption formula is defined as Ci = Ek(Pi) = (Pi + Ki mod m) mod 26 while the decryption formula is Pi = Dk(Ci) = (Ci - Ki mod m) mod 26 where m is the length of the key string. Example: Let the key string be gold. Using the encoding rule a = 0, b = 1, …, z = 25, the numerical representation of this key string is (6, 14, 11, 3). plaintext: proceed meeting as agreed key: goldgoldgo ld goldgo ciphertext: vfzfkso pkseltu lv guchkr Security of Vigenere Cipher: (1) Much more secure than Caeser cipher (2) Need to determine key size (3) Repetitions in ciphertext give clues to period. 6