Instructor: Dania Alomar

40
Cryptography INSTRUCTOR: DANIA ALOMAR

description

Cryptology Cryptology Cryptography Cryptanalysis “The art and science of keeping message secure” Cryptanalysis “The art and science of breaking the code “

Transcript of Instructor: Dania Alomar

Page 1: Instructor: Dania Alomar

CryptographyINSTRUCTOR: DANIA ALOMAR

Page 2: Instructor: Dania Alomar

CryptologyCryptology

Cryptography“The art and science of

keeping message secure”

Cryptanalysis“The art and science of

breaking the code“

Page 3: Instructor: Dania Alomar

Cryptology•Cryptography

The art and science of keeping message secure.Cryptography comes from Greek and it means hidden/secret (crypto) and writing (graphy)

•CryptanalysisThe art and science of breaking the code.

•CryptologyThe branch of mathematics encompassing both cryptography and cryptanalysis. Its

practitioners are Cryptologists

Page 4: Instructor: Dania Alomar

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 C

P = DK(C)

C P

Page 5: Instructor: Dania Alomar

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

Page 6: Instructor: Dania Alomar

Types Of CryptographySecret Key Cryptography

Each two parties share the same key

Problem: How to distribute keys.

Public Key CryptographyEach individual has two keys: • private key (not revealed to anyone) • public key (make it known to

everyone)

Problem: How to authenticate

Plaintext ciphertextencryption

ciphertext Plaintextdecryption

KeyPlaintext ciphertext

encryption

ciphertext Plaintextdecryption

Public keyPrivate key

Page 7: Instructor: Dania Alomar

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

Page 8: Instructor: Dania Alomar

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

Page 9: Instructor: Dania Alomar

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

Page 10: Instructor: Dania Alomar

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

Page 11: Instructor: Dania Alomar

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

Page 12: Instructor: Dania Alomar

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.

Page 13: Instructor: Dania Alomar

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?

Page 14: Instructor: Dania Alomar

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?

Page 15: Instructor: Dania Alomar

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?

Page 16: Instructor: Dania Alomar

Arithmetic modulo mThe 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.

Page 17: Instructor: Dania Alomar

Classical Ciphers•Substitution cipheroReplacing each element of the plaintext with another element.

•Transposition (or permutation) cipheroRearranging the order of the elements of the plaintext.

•Product cipheroUsing multiple stages of substitutions and transpositions

Page 18: Instructor: Dania Alomar

Substitution cipher•Monoalphabetic ciphero Uses fixed substitution over the entire message.

•Polyalphabetic cipheroUses 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.

Page 19: Instructor: Dania Alomar

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, Simple Substitution Cipher and Affine cipher.

Page 20: Instructor: Dania Alomar

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 K between 1 and 25.

e.g., for K=1, HAL IBM.

Page 21: Instructor: Dania Alomar

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 26p = DK(c) = (c – k) mod 26

• Cryptanalysis of Caesar Cipher oKey space: {0, 1, ..., 25} oVulnerable to brute-force attacks.

Page 22: Instructor: Dania Alomar

Simple Substitution Cipher •Shuffle the letters and map each plaintext letter to a different random ciphertext letter.

•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 : abcdefghijklmnopqrstuvwxyzcipher alphabet: phqgiumeaylnofdxjkrcvstzwb

plaintext : defend the east wall of the castleciphertext: giuifg cei iprc tpnn du cei qprcni

cipher alphabet: zebracdfghijklmnopqstuvwxy

Page 23: Instructor: Dania Alomar

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.

Page 24: Instructor: Dania Alomar

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

Page 25: Instructor: Dania Alomar

English Letter Frequencies

Page 26: Instructor: Dania Alomar

Cryptanalysis of Simple Substitution Cipher

Given ciphertext:UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

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

= theProceeding with trial and error finally get:it was disclosed yesterday that several informal butdirect contacts have been made with politicalrepresentatives of the viet cong in moscow

Page 27: Instructor: Dania Alomar

Cont.Letter frequencies in ciphertext

Page 28: Instructor: Dania Alomar

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.

Page 29: Instructor: Dania Alomar

Vigenere Cipher

Page 30: Instructor: Dania Alomar

Playfair Cipher•Invented by Charles Wheatstone in 1854, but named after his friend Baron Playfair who 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)

Page 31: Instructor: Dania Alomar

Cont.•plaintext is encrypted two letters at a time

1. if a pair is a repeated letter, insert filler like 'X’ so that balloon would be treated as ba lx lo on.

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

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

4. 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 pd is encrypted as AB.

Page 32: Instructor: Dania Alomar

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

Page 33: Instructor: Dania Alomar

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.

Page 34: Instructor: Dania Alomar

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

Page 35: Instructor: Dania Alomar

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

Page 36: Instructor: Dania Alomar

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.

Page 37: Instructor: Dania Alomar

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

Page 38: Instructor: Dania Alomar

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: 3 4 2 1 5 6 7

Plaintext:

Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ

Page 39: Instructor: Dania Alomar

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: 3 4 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.

Page 40: Instructor: Dania Alomar

Reading “Cryptography and Network Security Principles and Practices”, Fourth Edition by William Stallings

Part one, Chapter 2