Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Classical Encryption Techniques Dr. Nermin Hamza

Similar presentations


Presentation on theme: "Lecture Classical Encryption Techniques Dr. Nermin Hamza"— Presentation transcript:

1 Lecture 2 2012 Classical Encryption Techniques Dr. Nermin Hamza

2 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.

3 Introduction (cont’d)
Cryptography DAVID KAHN at said at “coder breaker” : Cryptology was born among the Arabs. They were the first to discover and write down the methods of cryptanalysis وقد نشر مجمع اللغة العربية ، بدمشق الجزء الأول من الكتاب ”علم التعمية و استخراج المعمى ”، سنة ١٩٨٧ ونشر الجزء الثاني سنة ١٩٩7 للدكتور : محمد مراياتي ويحيى ميرعلم و محمد حسان الطيان

4 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

5 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

6 Encryption Diagram Encryption algorithm Decryption algorithm
Plain Text Cipher Text Plain Text Key Key

7 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

8 Cryptography types: Symmetric cipher Asymmetric cipher

9 Also called Secret Key Cryptography (SKC):
Symmetric cryptography : Also called Secret Key Cryptography (SKC): Uses a single key for both encryption and decryption Plain Text Plain Text Cipher Text

10 Also called Public Key Cryptography (PKC):
Asymmetric Cryptography : Also called Public Key Cryptography (PKC): Uses one key for encryption and another for decryption Plain Text Cipher Text Plain Text

11 Symmetric Encryption or conventional / private-key / single-key
sender and recipient share a common key all classical encryption algorithms are private-key was only type prior to invention of public- key in 1970’s and by far most widely used

12 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

13 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. Typically objective is to recover the key in use rather then simply to recover the plaintext of a single ciphertext. There are two general approaches: Cryptanalytic attacks 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 attacks try every possible key on a piece of ciphertext until an intelligible translation into plaintext is obtained. On average,half of all possible keys must be tried to achieve success.

14 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

15 Brute Force Search always possible to simply try every key
most basic attack, proportional to key size assume either know / recognise plaintext Key Size (bits) Number of Alternative Keys Time required at 1 decryption/µs Time required at decryptions/µs 32 232 = 4.3  109 231 µs = 35.8 minutes 2.15 milliseconds 56 256 = 7.2  1016 255 µs = 1142 years 10.01 hours 128 2128 = 3.4  1038 2127 µs = 5.4  years 5.4  1018 years 168 2168 = 3.7  1050 2167 µs = 5.9  years 5.9  1030 years 26 characters (permutation) 26! = 4  1026 2  1026 µs =  1012 years 6.4  106 years A brute-force attack involves trying every possible key until an intelligible translation of the ciphertext into plaintext is obtained. On average, half of all possible keys must be tried to achieve success. Stallings Table 2.2 shows how much time is required to conduct a brute-force attack, for various common key sizes (DES is 56, AES is 128, Triple-DES is 168, plus general mono-alphabetic cipher), where either a single system or a million parallel systems, are used.

16 The main two basic techniques
Substitution Transposition

17 Substitution Ciphers

18 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

19 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

20 Caesar Cipher then have Caesar cipher as: c = E(p) = (p + k) mod (26)
p = D(c) = (c – k) mod (26)

21 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 then have Caesar cipher as: c = E(p) = (p + 3) mod (26) If p= a= 0 , E(a) = (0+3) mod 26 = 3 = D

22 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 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 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

23 Caesar Example Let k= 10 Encrypt the following “Hello”

24 Caesar Example Let k= 10 Encrypt the following “Hello” H E L L O
(MOD 26) R O V V Y

25 Caesar Example Let k= 9 Encrypt the following “SUN”

26 Caesar Example Let k= 9 Encrypt the following “SUN” S U N 18 20 13
(MOD 26) B D W

27 Caesar Example Let the cipher text = “IFMMP” and k =1
What is the plain text? P= (C-1) mod 26 P = Hello

28 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 ciphertext, just try all shifts of letters do need to recognize when have plaintext eg. break ciphertext "GCUA VQ DTGCM"

29 Example for fun G C U A V Q D T M W O P K X N B L Y H R Z I S J E F

30 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 With only 25 possible keys, the Caesar cipher is far from secure. A dramatic increase in the key space can be achieved by allowing an arbitrary substitution, where the translation alphabet can be any permutation of the 26 alphabetic characters. See example translation alphabet, and an encrypted message using it.

31 Monoalphabetic Cipher Security
Could be another equation : (a.i +b ) mod 26

32 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

33 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

34 English Letter Frequencies
Note that all human languages have varying letter frequencies, though the number of letters and their frequencies varies. Stallings Figure 2.5 shows English letter frequencies. Seberry & Pieprzyk, "Cryptography - An Introduction to Computer Security", Prentice-Hall 1989, Appendix A has letter frequency graphs for 20 languages (most European & Japanese & Malay).

35 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

36 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

37 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 The best known, and one of the simplest, such algorithms is referred to as the Vigenère cipher, where the set of related monoalphabetic substitution rules consists of the 26 Caesar ciphers, with shifts of 0 through 25. Each cipher is denoted by a key letter, which is the ciphertext letter that substitutes for the plaintext letter ‘a’, and which are each used in turn, as shown next.

38 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:ZICVTWQNGRZGVTWAVZHCQYGLMG J Discuss this simple example from text Stallings section 2.2.

39 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

40 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

41

42 Let key = MEC Plain text : We need more supplies fast

43 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

44 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

45 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 Ciphertext: I I P Q I F Y S T Q W W B T N U I U R E U F

46 Security of Vigenère Ciphers
have multiple ciphertext letters for each plaintext letter hence letter frequencies are obscured but not totally lost

47 Play Fair The keyword written into five-by-five square , omitting repeated letters and combining I and J in one cell. Key: MANCHESTER

48 Example of play fair M A N C H E S T R B D F G I/J K L O P Q U V W X Y
Z

49 Example of play fair matrix
“playfair example" as the key

50 Example of play fair matrix
“Monarchy” R A N O M D B Y H C K I/J G F E T S Q P L Z X W V U

51 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”

52 Steps IF The letters in the same row, replace them with the letters to their immediate right respectively Ex: AR => RM R A N O M D B Y H C K I/J G F E T S Q P L Z X W V U

53 Steps IF The letters in the same column take the below letters MU => CM R A N O M D B Y H C K I/J G F E T S Q P L Z X W V U

54 Steps If the two letters are located at opposite corner of the rectangle., is replaced by the letter that lies in its own row and the column occupied by the other plain text. HS=> BP R A N O M D B Y H C K I/J G F E T S Q P L Z X W V U

55 SOLVE Key is “playfair Example”
Encrypt: “Hide the gold in the tree stump”

56 P L A Y F I R E X M B C D G H K N O Q S T U V W Z
HI DE TH EG OL DI NT HE TR EX ES TU MP BM OD ZB XD NA BE KU DM UI XM MO UV IF

57 Play Fair And then : take 2 letter from the plain text two by two and locate the letter at opposite corner of the rectangle: TH BN M A N C H E S T R B D F G I/J K L O P Q U V W X Y Z M A N C H E S T R B D F G I/J K L O P Q U V W X Y Z

58 IF The letters in the same row, replace them with the letters to their immediate right respectively
SE TS M A N C H E S T R B D F G I/J K L O P Q U V W X Y Z

59 IF The letters in the same column take the below letters CR RI
D F G I/J K L O P Q U V W X Y Z

60 Solution Solve

61 One-Time Pad if a truly random key as long as the message is used, the cipher will be secure called a One-Time pad is unbreakable since ciphertext bears no statistical relationship to the plaintext since for any plaintext & any ciphertext there exists a key mapping one to other can only use the key once though problems in generation & safe distribution of key

62 Transposition Ciphers

63 Transposition Ciphers
now consider classical transposition or permutation ciphers these hide the message by rearranging the letter order without altering the actual letters used can recognise these since have the same frequency distribution as the original text

64 Rail Fence cipher write message letters out diagonally over a number of rows then read off cipher row by row eg. write message out as: m e m a t r h t g p r y e t e f e t e o a a t giving ciphertext MEMATRHTGPRYETEFETEOAAT The simplest such cipher is the rail fence technique, in which the plaintext is written down as a sequence of diagonals and then read off as a sequence of rows. The example message is: "meet me after the toga party" with a rail fence of depth 2. This sort of thing would be trivial to cryptanalyze.

65 Reverse cipher Write the message backwards Ex:
Plain: I came I saw I conq uered Cipher: d ereu q noci w asie maci


Download ppt "Lecture Classical Encryption Techniques Dr. Nermin Hamza"

Similar presentations


Ads by Google