600 likes | 625 Views
Lecture 2 2013 Classical Encryption Techniques Dr. Nermin Hamza. Introduction. Cryptography Cryptography is the science of writing in-secret code and is an ancient art . The first documented use of cryptography in writing dates back to circa 1900 B.C. by Egyptian. Introduction (cont’d).
E N D
Lecture 2 2013 Classical Encryption TechniquesDr. NerminHamza
Introduction • Cryptography • Cryptography is the science of writing in-secret code and is an ancient art . • The first documented use of cryptography in writing dates back to circa 1900 B.C. by Egyptian.
Introduction (cont’d) • Cryptography • DAVID KAHN at 1976 said at “coder breaker” : • Cryptology was born among the Arabs. • They were the first to discover and write down the methods of cryptanalysis • وقد نشر مجمع اللغة العربية ، بدمشق الجزء الأول من الكتاب ”علم التعمية و استخراج المعمى ”، سنة ١٩٨٧ ونشر الجزء الثاني سنة ١٩٩7 • للدكتور : محمد مراياتي ويحيى ميرعلم و محمد حسان الطيان
Requirements • two requirements for secure use of symmetric encryption: • a strong encryption algorithm • a secret key known only to sender / receiver • mathematically have: Y = EK(X) X = DK(Y) • assume encryption algorithm is known • implies a secure channel to distribute key
Some Basic Terminology • plaintext - original message • ciphertext - coded message • cipher-algorithm : for transforming plaintext to ciphertext • key - info used in cipher known only to sender/receiver • encipher (encrypt) - converting plaintext to ciphertext • decipher (decrypt) - recovering ciphertext from plaintext
Encryption Diagram Encryption algorithm Decryption algorithm Plain Text Cipher Text Plain Text Key Key
Some Basic Terminology • cryptography - study of encryption principles/methods • cryptanalysis (codebreaking) - study of principles/ methods of deciphering ciphertext without knowing key • cryptology - field of both cryptography and cryptanalysis
Cryptography • characterize cryptographic system by: • number of keys used • single-key or private / two-key or public • type of encryption operations used • substitution / transposition / product • way in which plaintext is processed • block / stream
Cryptanalysis • objective to recover key not just message • general approaches: • cryptanalytic attack rely on the nature of the algorithm plus perhaps some knowledge of the general characteristics of the plaintext or even some sample plaintext-ciphertext pairs. • Brute-force attack try every possible key on a piece of cipher text until an intelligible translation into plaintext is obtained.
Cryptanalytic Attacks • ciphertext only • only knows algorithm & ciphertext • known plaintext • know/suspect plaintext & ciphertext • chosen plaintext • select plaintext and obtain ciphertext • chosen ciphertext • select ciphertext and obtain plaintext • chosen text • select plaintext or ciphertext to en/decrypt
Brute Force Search • always possible to simply try every key • most basic attack, proportional to key size • assume either know / recognise plaintext
Cryptography types: • Symmetric cipher • Asymmetric cipher
Symmetric cryptography : • Also called Secret Key Cryptography (SKC): Uses a single key for both encryption and decryption Plain Text Plain Text Cipher Text
Asymmetric Cryptography : • Also called Public Key Cryptography (PKC): Uses one key for encryption and another for decryption Plain Text Cipher Text Plain Text
The main two basic techniques • Substitution • Transposition
Classical Substitution Ciphers • where letters of plaintext are replaced by other letters or by numbers or symbols • or if plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with cipher text bit patterns
Caesar Cipher • earliest known substitution cipher • by Julius Caesar • first attested use in military affairs • replaces each letter by 3rd letter on • example: M e e t m e a f t e r t h e t o g a p a r t y P H H W P H D I W H U W K H W R J D S D U W B
Caesar Cipher • then have Caesar cipher as: c = E(p) = (p + k) mod (26) p = D(c) = (c – k) mod (26)
Caesar Cipher • can define transformation as: 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 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 • mathematically give each letter a number 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 0 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 • then have Caesar cipher as: c = E(p) = (p + 3) mod (26) If p= a= 0 , E(a) = (0+3) mod 26 = 3 = D
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 0 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
Caesar Example • Let k= 10 • Encrypt the following “Hello”
Caesar Example • Let k= 10 • Encrypt the following “Hello” • H E L L O 7 4 11 11 14 17 14 21 21 24 • -----------------------(MOD 26) 17 14 21 21 24 R O V V Y
Caesar Example • Let k= 9 • Encrypt the following “SUN”
Caesar Example • Let k= 9 • Encrypt the following “SUN” S U N 18 20 13 27 29 22 -----------------------(MOD 26) 1 3 22 B D W
Caesar Example • Let the cipher text = “IFMMP” and k =1 • What is the plain text? • P= (C-1) mod 26 • P = Hello
Cryptanalysis of Caesar Cipher • only have 26 possible ciphers • A maps to A,B,..Z • could simply try each in turn • a brute force search • given cipher text, just try all shifts of letters • do need to recognize when have plaintext • eg. break cipher text "GCUA VQ DTGCM"
Monoalphabetic Cipher • rather than just shifting the alphabet • could shuffle (jumble) the letters arbitrarily • each plaintext letter maps to a different random ciphertext letter • hence key is 26 letters long Plain: abcdefghijklmnopqrstuvwxyz Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN Plaintext: ifwewishtoreplaceletters Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher Security • Could be another equation : • (a.i +b ) mod 26
Monoalphabetic Cipher Security • now have a total of 26! = 4 x 1026 keys • with so many keys, might think is secure • but would be !!!WRONG!!! • problem is language characteristics
Language Redundancy and Cryptanalysis • human languages are redundant • eg "th lrd s m shphrd shll nt wnt" • letters are not equally commonly used • in English E is by far the most common letter • followed by T,R,N,I,O,A,S • other letters like Z,J,K,Q,X are fairly rare • have tables of single, double & triple letter frequencies for various languages
Use in Cryptanalysis • compare counts/plots against known values • if caesar cipher look for common peaks/troughs • peaks at: A-E-I triple, NO pair, RST triple • troughs at: JK, X-Z • for monoalphabetic must identify each letter tables of common double/triple letters help
Polyalphabetic Ciphers • polyalphabetic substitution ciphers • improve security using multiple cipher alphabets • make cryptanalysis harder with more alphabets to guess and flatter frequency distribution • use a key to select which alphabet is used for each letter of the message • use each alphabet in turn • repeat from start after end of key is reached
Vigenère Cipher • simplest polyalphabetic substitution cipher • effectively multiple caesar ciphers • key is multiple letters long K = k1 k2 ... kd • ith letter specifies ith alphabet to use • use each alphabet in turn • repeat from start after d letters in message • decryption simply works in reverse
Steps of Vigenère Cipher 1- write the plaintext out 2- Write your keyword across the top of the text you want to encipher, repeating it as many times as necessary. 3- encrypt the corresponding plaintext letter 4- eg using keyword deceptive key: deceptivedeceptivedeceptive plaintext: wearediscoveredsaveyourself ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
5- For each letter, look at the letter of the keyword above it ,and find that row in the Vigenere table. 6- Then find the column of your plaintext letter 7- Finally, trace down that column until you reach the row you found before and write down the letter in the cell where they intersect
Example • D and W Z key: d e c e p t ivedeceptivedeceptive plaintext: w e a r e d iscoveredsaveyourself ciphertext: Z I C V T W QNGRZGVTWAVZHCQYGLMGJ
Let key = MEC • Plain text : We need more supplies fast
Let key = MEC • Plain text : • We need more supplies fast • Keyword: M E C M E C M E C M E C M E C M E C M E C M • Plaintext: w e n e e d m o r e s u p p l i e s f a s t
Let key = MEC • Plain text : • We need more supplies fast • Keyword: M E C M E C M E C M E C M E C M E C M E C M • Plaintext: w e n e e d m o r e s u p p l i e s f a s t • Ciphertext: I I P Q I F Y S T Q W W B T N U I U R E U F
Security of Vigenère Ciphers • have multiple ciphertext letters for each plaintext letter • hence letter frequencies are obscured • but not totally lost
Play Fair • The keyword written into five-by-five square , omitting repeated letters and combining I and J in one cell. • Key: MANCHESTER
Example of play fair matrix • “playfair example" as the key
Example of play fair matrix • “Monarchy”
Play Fair • Break the message into two-letter group. If both letters are the same : insert X between them. If only one letter add X letter • PLAIN: “THIS SECRET MESSAGE IS ENCRYPTED”