TCN - Lecture 6

Embed Size (px)

Citation preview

  • 8/7/2019 TCN - Lecture 6

    1/34

    CLASSICAL CIPHERS

    By

    Mr. Fasee UllahCUSIT

    Peshawar

  • 8/7/2019 TCN - Lecture 6

    2/34

    Agenda

    Types of classical ciphers

    Asymmetric cryptography

    Application of Asymmetric encryption

  • 8/7/2019 TCN - Lecture 6

    3/34

    Symmetric Cipher Model

    A symmetric encryption scheme has five ingredients

    Plaintext: This is the original message or data

    Encryption algorithm: The encryption algorithm performs

    various substitutions and transformations on theplaintext

    Secret key: The secret key is also input to the encryptionalgorithm

    The algorithm will produce a different output

    depending on the specific key being used at the time The exact substitutions and transformations performed

    by the algorithm depend on the key

  • 8/7/2019 TCN - Lecture 6

    4/34

    Contd

    Ciphertext: This is the scrambled message produced

    as output

    It depends on the plaintext and the secret key and,

    as it stands, is unintelligible

    Decryption algorithm: This is essentially the

    encryption algorithm run in reverse

    It takes the ciphertext and the secret key andproduces the original plaintext

  • 8/7/2019 TCN - Lecture 6

    5/34

    Classical Substitution Ciphers

    Substitution techniques use classical encryptiontechnique

    A study of these techniques enables us to explain the

    basic approaches to symmetric encryption used today Two basic block of encryption techniques are

    substitution

    Transposition

    A substitution technique is one in which the letters ofplaintext are replaced by other letters or by numbersor symbols

  • 8/7/2019 TCN - Lecture 6

    6/34

    Caesar Cipher

    earliest known substitution cipher

    by Julius Caesar

    first attested use in military affairs

    replaces each letter by 3rd letter on

    meet me after the toga party

  • 8/7/2019 TCN - Lecture 6

    7/34

    Caesar Cipher

    example:Plain text: meet me after the toga

    party

    Cipher Text: PHHWPH DIWHUWKHWRJDSDUWB

    Note: Plaintext always in lowercase;

    ciphertext is in uppercase;

    key values are in lowercase

  • 8/7/2019 TCN - Lecture 6

    8/34

    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 JK L M N O P Q R S T U V W X Y Z A B C

    mathematically give each letter a numbera 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 + k) mod (26)p = D(c) = (c k) mod (26)

  • 8/7/2019 TCN - Lecture 6

    9/34

    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"

  • 8/7/2019 TCN - Lecture 6

    10/34

    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

  • 8/7/2019 TCN - Lecture 6

    11/34

    Monoalphabetic Cipher Security

    now have a total of 26! = 4 x 1026 keys

    with so many keys, might think is secure to eliminate

    brute-force techniques

    but would be !!!WRONG!!!

    problem is language characteristics

  • 8/7/2019 TCN - Lecture 6

    12/34

    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 letterfrequencies for various languages

  • 8/7/2019 TCN - Lecture 6

    13/34

    English Letter Frequencies

  • 8/7/2019 TCN - Lecture 6

    14/34

    Relative Frequencies of letters in

    ciphertext

    P 13.33 H 5.83 F 3.33 B 1.67 C 0.00

    Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00

    S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00

    U 8.33 V 4.17 T 2.50 I 0.83 N 0.00

    O 7.50 X 4.17 A 1.67 J 0.83 R 0.00

    M 6.67

  • 8/7/2019 TCN - Lecture 6

    15/34

    Example Cryptanalysis

    given ciphertext:UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ

    VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX

    EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

    count relative letter frequencies

    guess P & Z are e and t

    guess ZW is th and hence ZWP is the

    proceeding with trial and error finally get:it was disclosed yesterday that several informal butdirect contacts have been made with political

    representatives of the viet cong in moscow

  • 8/7/2019 TCN - Lecture 6

    16/34

    Playfair Cipher

    not even the large number of keys in a

    monoalphabetic cipher provides security

    one approach to improving security was to encrypt

    multiple letters

    the Playfair Cipher is an example

    invented by Charles Wheatstone in 1854, but

    named after his friend Baron Playfair

  • 8/7/2019 TCN - Lecture 6

    17/34

    Playfair Key Matrix

    a 5X5 matrix of letters based on a keyword

    fill in letters of keyword

    fill rest of matrix with other letters eg. using the keyword MONARCHY

    MM OO NN AA RR

    CC HH YY BB DD

    EE FF GG I/JI/J KK

    LL PP QQ SS TT

    UU VV WW XX ZZ

  • 8/7/2019 TCN - Lecture 6

    18/34

    Encrypting and Decrypting

    plaintext is encrypted two letters at a time

    wrap from right side back to left, or from bottom backto top.

    1. if a pair is a repeated letter, insert a filler like 'X', eg."balloon" encrypts as "ba lx lo on"

    2. if both letters fall in the same row, replace each with letterto right eg. ar" encrypts as "RM"

    3. if both letters fall in the same column, replace each withthe letter below it (again wrapping to top from bottom), eg.mu" encrypts to "CM"

    4. otherwise each letter is replaced by the one in its row inthe column of the other letter of the pair, eg. hs" encryptsto "BP", and ea" to "IM" or "JM" (as desired)

  • 8/7/2019 TCN - Lecture 6

    19/34

    Security of Playfair Cipher

    security much improved over monoalphabetic

    since have 26 x 26 = 676 digrams

    was widely used for many years eg. by US & British military in WW1

  • 8/7/2019 TCN - Lecture 6

    20/34

    Polyalphabetic Ciphers

    polyalphabetic substitution ciphers

    improve security using multiple cipher

    alphabets make cryptanalysis harder with more

    alphabets to guess

    use a key to select which alphabet is used foreach letter of the message

    repeat from start after end of key is reached

  • 8/7/2019 TCN - Lecture 6

    21/34

    Vigenre Cipher

    simplest polyalphabetic substitution cipher

    key is multiple letters long K = k1 k2 ...

    i

    th

    letter specifies i

    th

    alphabet to use use each alphabet in turn

  • 8/7/2019 TCN - Lecture 6

    22/34

    Example of Vigenre Cipher

    write the plaintext out

    write the keyword repeated above it

    eg using keyword deceptive

    key: deceptivedeceptivedeceptive

    plaintext: wearediscoveredsaveyourself

    ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ

  • 8/7/2019 TCN - Lecture 6

    23/34

    Security of Vigenre Ciphers

    have multiple ciphertext letters for each plaintext

    letter

    hence letter frequencies are obscured

    but not totally lost

  • 8/7/2019 TCN - Lecture 6

    24/34

    One-Time Pad

    Each new message requires a new key of the same length as thenew message

    Such a technique called One Time Pad

    is unbreakable since ciphertext bears no statistical relationship to

    the plaintext can only use the key once though

    The one-time pad offers complete security but, in practice, has twofundamental difficulties:

    1. There is the practical problem of making large quantities of randomkeys

    2. And the problem of key distribution and protection, where forevery message to be sent, a key of equal length is needed byboth sender and receiver

  • 8/7/2019 TCN - Lecture 6

    25/34

    Transposition Ciphers

    now consider classical transposition or permutation

    ciphers

    these hide the message by rearranging the letter

    order

    without altering the actual letters used

  • 8/7/2019 TCN - Lecture 6

    26/34

    Rail Fence cipher

    write message letters out diagonally over a numberof 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

  • 8/7/2019 TCN - Lecture 6

    27/34

    Row Transposition Ciphers

    a more complex transposition

    write letters of message out in rows over a specifiednumber of columns

    then reorder the columns according to some keybefore reading off the rowsKey: 3 4 2 1 5 6 7

    Plaintext: a t t a c k p

    o s t p o n e

    d u n t ilt

    w o a m x y z

    Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ

  • 8/7/2019 TCN - Lecture 6

    28/34

    Product Ciphers

    ciphers using substitutions or transpositions are notsecure because of language characteristics

    hence consider using several ciphers in succession to

    make harder, but: two substitutions make a more complex substitution

    two transpositions make more complex transposition

    but a substitution followed by a transposition makes a newmuch harder cipher

    this is bridge from classical to modern ciphers

  • 8/7/2019 TCN - Lecture 6

    29/34

    Rotor Machines

    before modern ciphers, rotor machines were mostcommon complex ciphers in use

    widely used in WW2 German Enigma, Allied Hagelin, Japanese Purple

    implemented a very complex, varyingsubstitution cipher

    used a series of cylinders, each giving one

    substitution, which rotated and changed aftereach letter was encrypted with 3 cylinders have 263=17576 alphabets

  • 8/7/2019 TCN - Lecture 6

    30/34

    An Example of Rotor Machine

  • 8/7/2019 TCN - Lecture 6

    31/34

    Hagelin Rotor Machine

  • 8/7/2019 TCN - Lecture 6

    32/34

  • 8/7/2019 TCN - Lecture 6

    33/34

    Summary

    have considered:

    classical cipher techniques and terminology

    monoalphabetic substitution ciphers

    cryptanalysis using letter frequencies

    Playfair cipher

    polyalphabetic ciphers

    transposition ciphers product ciphers and rotor machines

    stenography

  • 8/7/2019 TCN - Lecture 6

    34/34

    Assignment 20/09/2010

    Explain each cipher with examples:

    Hill Cipher

    Kasiski cipher

    Autokey Cipher

    Application of Symmetric encryption