# Cryptography - PowerPoint PPT Presentation Download Presentation Cryptography

Cryptography Download Presentation ## Cryptography

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Cryptography Instructor: Dania Alomar

2. Cryptology

3. Cryptology • Cryptography • The art and science of keeping message secure. • Cryptography comes from Greek and it means hidden/secret (crypto) and writing (graphy) • Cryptanalysis • The art and science of breaking the code. • Cryptology • The branch of mathematics encompassing both cryptography and cryptanalysis. Its practitioners are Cryptologists

4. Encryption and Decryption • The original message is called Plaintext. • The process of disguising a message in such a way to hide its substance, is called Encryption. • The encrypted message is called Ciphertext • The Encryption is done using the specified key: C = EK(P) or E(K, P) • Decryption It takes the ciphertext and the secret key and produces the original plaintext. C = EK(P) P = DK(C) P C C P

5. Algorithm and keys • Cipher • A cryptographic algorithm for performing encryption or decryption .It is a mathematical function used for both encryption and decryption. • Key & Key Space • The key is a value independent of the plaintext and of the algorithm • The security of modern cryptosystem is based on a Key: which could be one of any large values. • The range of possible key values is called the Key Space. • Both encryption and decryption depends upon the Key. • The algorithm will produce a different output depending on the specific key being used at the time

6. Types Of Cryptography Secret Key Cryptography • Each two parties share the same key • Problem: How to distribute keys. • Public Key Cryptography • Each individual has two keys: • private key (not revealed to anyone) • public key (make it known to everyone) • Problem: How to authenticate encryption encryption Plaintext Plaintext ciphertext ciphertext Public key Private key Key ciphertext ciphertext Plaintext Plaintext decryption decryption

7. Cryptography Services • Confidentiality • Prevent unauthorized disclosure of information • Integrity • Prevent unauthorized modification of information • Authentication • To verify the identity of subject • Non-repudiation • Protect from deniability

8. Kerckhoffs Principle • Basic assumption • The algorithm is completely known to the attacker • Only the key is secret • Also known as Kerckhoffs Principle • Crypto algorithms are not secret • Why do we make this assumption? • Secret algorithms never remain secret • Better to find weaknesses beforehand

9. Cryptanalysis • The objective of attacking an encryption system is to recover the key in use rather than simply to recover the plaintext of a single ciphertext. • General approaches: • cryptanalytic attack • brute-force attack

10. Brute-Force Attack • Try every key to decipher the ciphertext. • On average, need to try half of all possible keys • Time needed proportional to size of key space

11. Cryptanalytic Attacks • May be classified by how much information needed by the attacker: • Ciphertext-only attack • Known-plaintext attack • Chosen-plaintext attack • Chosen-ciphertext attack

12. Ciphertext-only attack • Given: a ciphertext c • Q: what is the plaintext m? • An encryption scheme is completely insecure if it cannot resist ciphertext-only attacks.

13. Known-plaintext attack • Is an attack where a cryptanalyst has access to a plaintext and the corresponding ciphertext and seeks to discover a correlation between the two. • Given: (m1,c1), (m2,c2), …, (mk,ck) and a new ciphertext c. • Q: what is the plaintext of c? • Q: what is the secret key in use?

14. Chosen-plaintext attack • Is an attack where a cryptanalyst can encrypt a plaintext of his choosing and study the resulting ciphertext. This is most common against asymmetric cryptography, where a cryptanalyst has access to a public key • Given: (m1,c1), (m2,c2), …, (mk,ck), where m1,m2, …, mk are chosen by the adversary; and a new ciphertext c. • Q: what is the plaintext of c, or what is the secret key?

15. Chosen-ciphertext attack • Is an attack where a cryptanalyst chooses a ciphertext and attempts to find a matching plaintext. • Given: (m1,c1), (m2,c2), …, (mk,ck), where c1,c2, …, ck are chosen by the adversary; and a new ciphertext c. • Q: what is the plaintext of c, or what is the secret key?

16. Arithmetic modulo m The integer modulo m, denoted by Zm is the set of integers {0,1,2,..,m-1} where addition, subtraction and multiplication is performed modulo m.

17. Classical Ciphers • Substitution cipher • Replacing each element of the plaintext with another element. • Transposition (or permutation) cipher • Rearranging the order of the elements of the plaintext. • Product cipher • Using multiple stages of substitutions and transpositions

18. Substitution cipher • Monoalphabetic cipher • Uses fixed substitution over the entire message. • Polyalphabetic cipher • Uses a number of substitutions at different times in the message, where a unit from the plaintext is mapped to one of several possibilities in the ciphertext and vice-versa.

19. Monoalphabetic Ciphers • The ciphers for which, once a key is chosen, each alphabetic character is mapped to a unique alphabetic character. • Examples of mono alphabetic ciphers include Caesar cipher, SimpleSubstitution Cipher and Affine cipher.

20. Caesar Cipher • Invented by Julius Caesar . • Each letter is replaced by the letter three positions (with wrap around) further down the alphabet. • Plain: 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 Cipher: 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 • Example: ohio state  RKLR VWDWH • Extension (Shift Cipher): Instead of 3 use any number Kbetween 1 and 25. e.g., for K=1, HAL  IBM.

21. Caesar Cipher • Mathematically, map letters to numbers: a, b, c, ..., x, y, z 0, 1, 2, ..., 23, 24, 25 • Then the general Caesar cipher is: c = EK(p) = (p + k) mod 26 p = DK(c) = (c – k) mod 26 • Cryptanalysis of Caesar Cipher • Key space: {0, 1, ..., 25} • Vulnerable to brute-force attacks.

22. Simple Substitution Cipher • Shuffle the letters and map each plaintext letter to a different random ciphertextletter. • Keys for the simple substitution cipher usually consist of 26 letters (compared to the caeser cipher's single number). An example key is: • An example encryption using the above key: • When generating keys it is popular to use a key word, e.g. 'zebra' to generate it, since it is much easier to remember a key word compared to a random jumble of 26 characters. Using the keyword 'zebra', the key would become: plain alphabet : abcdefghijklmnopqrstuvwxyz cipher alphabet: phqgiumeaylnofdxjkrcvstzwb plaintext : defend the east wall of the castle ciphertext: giuifgceiiprctpnn du ceiqprcni cipher alphabet: zebracdfghijklmnopqstuvwxy

23. Cryptanalysis of Simple Substitution Cipher • Now we have a total of 26! = 4 x 1026 keys. • With so many keys, it is secure against brute-force attacks. • But not secure against some cryptanalytic attacks. • Problem is language characteristics.

24. Language Statistics and Cryptanalysis • Human languages are not random. • Letters are not equally frequently 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. • There are tables of single, double & triple letter frequencies for various languages

25. English Letter Frequencies

26. Cryptanalysis of Simple Substitution Cipher • Given ciphertext: UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ • Count relative letter frequencies (see next page) • Guess {P, Z} = {e, t} • Of double letters, ZW has highest frequency, so guess ZW = th and hence ZWP = the • Proceeding with trial and error finally get: it was disclosed yesterday that several informal but direct contacts have been made with political representatives of the vietcong in moscow

27. Cont. Letter frequencies in ciphertext

28. Polyalphabetic Ciphers • The use of multiple substitution alphabets will mean that a plaintext letter can encrypt to different ciphertext letters, thus causing the letter frequency distribution to appear “flatter”. • A cipher that uses multiple substitution alphabets is called a polyalphabetic substitution cipher. The Vigenere Cipher, Playfair and Hill Cipher are examples of polyalphabetic ciphers.

29. Vigenere Cipher

30. Playfair Cipher • Invented by Charles Wheatstone in 1854, but named after his friend Baron Playfairwho promoted the use of the cipher. • The Playfair algorithm is based on the use of a 5 × 5 matrix of letters constructed using a keyword. • Example using the key word “PLAYFAIR EXAMPLE” • The matrix is constructed by filling in the letters of the keyword (minus duplicates) from left to right and from top to bottom, and then filling in the remainder of the matrix with the remaining letters in alphabetic order. The letters I and J count as one letter. (plain IJ will be Ix Ix)

31. Cont. • plaintext is encrypted two letters at a time • if a pair is a repeated letter, insert filler like 'X’ so that balloon would be treated as ba lx lo on. • if both letters fall in the same row, replace each with letter to right (wrapping back to start from end). For example, lx is encrypted as RM. • if both letters fall in the same column, replace each with the letter below it (again wrapping to top from bottom). For example, ru is encrypted as CL. • Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row and the column occupied by the other plaintext letter. For example pdis encrypted as AB.

32. Cont. • Encrypting the message "Hide the gold in the tree stump": Plain text: HI DE TH EG OL DI NT HE TR EX ES TU MP Cipher text: BM OD ZB XD NA BE KU DM UI XM MO UV IF • Decrypt this message: DIKZSARLBN

33. Cryptanalysis of Playfair Cipher • security much improved over monoalphabetic since have 26 x 26 = 676 digrams. • would need a 676 entry frequency table to analyse (verses 26 for a monoalphabetic) and correspondingly more ciphertext • was widely used for many years • eg. by US & British military in WW1 • it can be broken, it leaves much of the structure of the plaintext language intact. A few hundred letters of ciphertext are generally sufficient.

34. Transposition Ciphers • Also called permutationciphers. • Shuffle the plaintext, without altering the actual letters used. • Example: rail fence,Row Transposition Ciphers

35. rail fence • The simplest permutation technique, in which the plaintext is written down as a sequence of diagonals and then read off as a sequence of rows. • Example, to encipher the message "defend the east wall“ with a rail fence of depth 2, we write the following: • The encrypted message is : DFNTEATALEEDHESWL

36. rail fence • For the plaintext we used, "defend the east wall", with a key of 3, we write the following: • Note that at the end of the message we have inserted two "X“ (so that there are the same number of letters on the top row, as on the bottom row). • Decryption: • The decryption process for the Rail Fence Cipher involves reconstructing the diagonal grid used to encrypt the message.

37. Decrypt rail fence • We start by making a grid with as many rows as the key is, and as many columns as the length of the ciphertext. • For example, if you receive the ciphertext"TEKOOHRACIRMNREATANFTETYTGHH", encrypted with a key of 4. • From this we can now read the plaintext off following the diagonals to get "they are attacking from the north".

38. Row Transposition Ciphers • Plaintext is written row by row in a rectangle. • Ciphertext: write out the columns in an order specified by a key. Key: 34 2 1 5 6 7 Plaintext: Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ

39. Decrypt Row Transposition Ciphers • To decrypt a message we must know the number of columns. The number of rows is length of the message divided by the number of columns. • Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ • Key: 34 2 1 5 6 7 • Number of columns is 7 and length of message is 28=> 28/7= 4 rows. • Divide cipher text into block of 4 , rearrange blocks based on key.

40. Reading • “Cryptography and Network Security Principles and Practices”, Fourth Edition by William Stallings • Part one, Chapter 2