Lecture notes on cryptology - PDF by Bakudan

VIEWS: 200 PAGES: 49

									CSC 2106: Cryptology And
Coding Theory - BCS
By Muwonge S. Bernard
Makerere University
Faculty of Computing & IT
bmuwonge@cit.mak.ac.ug
bernard.muwonge@yahoo.com
Tel:+256776312246, +256712312246
Cryptography
     Cryptographic systems are generally grouped
     according to three facts about them:
    The mathematical operation that changes the
     plaintext into the ciphertext using the
     encryption key.
    Whether a block or a stream cipher is
     produced.
    The type of key system used - single or two
     key.
Single Key Cryptography
    Concealment Cipher
    Here, the message is present but concealed in
    some way.
    The security of such messages totally
    dependents upon the concealment trick.
    These are easily broken if one is looking for
    such devices and they do not lend themselves
    to fast ciphering and deciphering, so they are
    not used in any serious applications.
Examples
  Sir John Trevanion, was locked up in Colcester
  Castle. He had every reason to believe that he
  would be put to death just as had been his friends
  and fellow Royalists. While awaiting his doom,
  however, he was one day handed the following
  letter by his jailer.
Concealment Cipher
     Worthie Sir John:- Hope, that is ye beste comfort of ye
    afflicted, cannot much, I fear me, help you now. That I
    would saye to you, is this only: if ever I may be able to
    requite that I do owe you, stand not upon asking me.
    'Tis not much that I can do: but what I can do, bee ye
    verie sure I wille. I knowe that, if dethe comes, if
    ordinary men fear it, it frights not you, accounting it for
    a high honor, to have such a rewarde of your loyalty.
    Pray yet that you may be spared this soe bitter, cup. I
    fear not that you will grudge any sufferings; only if bie
    submission you can turn them away, 'tis the part of a
    wise man. Tell me, an if you can, to do for you
    anythinge that you wolde have done. The general goes
    back on Wednesday. Restinge your servant to
    command. - R.T.
Sir John did read the third letter after every
punctuation mark and felt some degree of
relief on knowing that the
PANEL AT EAST END OF CHAPEL
SLIDES
The prisoner asked to be allowed to pass an
hour in private repentance in the chapel. But
apparently being less devout than his jailers
believed, he spent the hour not in prayer, but
in flight.
Ex.2: Russian Nihilist secret writing.
    This combines concealment and substitution
    cipher. Consider the note below:
Russian Nihilist
Transposition Ciphers
   Here the letters of the original message remain
   the same, but their positions are scrambled in
   some systematic way.
   For example, the rail fence, in which the
   plaintext is staggered between two rows and
   then read off to give the ciphertext.
    In a two row rail fence the message
   MERCHANT TAYLORS’ SCHOOL
   becomes:
Examples

  M      R    H    N    T    Y     O    S    C    O    L

  E      C    A    T    A    L     R    S    H    O



    Which is read out as:
     MRHNTYOSCOLECATALRSHO.
    The rail fence is the simplest example of a class
     of transposition ciphers called route ciphers.
      The encryption route here is therefore to read the top
       row and then the lower.
Example
    Consider the following clear message:
    THIS IS A PHONY MESSAGE BUT IT
    SERVES ITS PURPOSE,( containing 40
    letters). Suppose we write the letters in an
    8 x 5 array, we get:
TH I S I
SA P H O
NYME S
SA G E B
UT I T S
ER V E S
I T S P U
RP O S E
Transposition Ciphers.

      In a simple columnar transposition, we can
      encipher (encrypt) the message by reading out
      by columns to get:
      TSNSU EIRHA YATRT PIPMG IVSOS
      HEETE PSIOS BSSUE.
      A diagonal transposition would yield the
      following encrypted message
      TSHNA ISYPS UAMHI ETGEO IRIES
      RTVTB PSESO PSSUE.
The Nihilist transposition using a keyword.
      In this type of transposition, a keyword (of
     length equal to the number of columns) is
     used to permute the order that the columns are
     read out.
     This depends on the alphabetical position of
     each letter of the keyword relative to the other
     letters.
     E.g. Using the keyword CIPHER, a matrix can
     be written out to represent this message:
Example
    MERCHANT TAYLORS’ SCHOOL
          C   I   P   H   E   R
          1   4   5   3   2   6
          M   E   R   C   H   A
          N   T   T   A   Y   L
          O   R   S   S   C   H
          O   O   L   Z   Z   Z
The plaintext has been written into the
columns from left to right as normal, and the
ciphertext will be formed by reading down the
columns.
The order in which the columns are written to
form the ciphertext is determined by the key.
This matrix therefore yields the ciphertext:
MNOOHYCZCASZETRORTSLALHZ.
The security of this method of encryption can
significantly be improved by re-encrypting the
resulting cipher using another transposition.
When decrypting a route cipher, the receiver
simply enters the ciphertext into the agreed-
upon matrix according to the encryption route
and then simply reads out the plaintext.
Generally, in route ciphers the elements of the
plaintext are written on a pre-arranged route into
a matrix agreed upon by the transmitter and
receiver.
Substitution Ciphers
     A substitution cipher is one in which the units
     of the plaintext (usually letters or numbers)
     are systematically replaced with other symbols
     or groups of symbols. The actual order of the
     units of the plaintext is not changed.
     The simplest substitution cipher is one where
     the alphabet of the cipher is merely a shift of
     the plaintext alphabet, for example, A might
     be encrypted as B, C as D and so forth.
Caesar's Cipher (Simple shift/Additive – mono
alphabetic).
     Here, each letter is replaced by the letter that is 3
     positions further along in the usual lexicographical
     ordering. Thus, "A" is replaced by "D", "B" is
     replaced by "E", and so on.
     In general, a shift cipher replaces the letters by some
     cyclic shift of the alphabet.
     This is most easily done by assigning the letters
     numbers from 0 to 25. Each letter of the clear
     message is replaced by the letter whose number is
     obtained by adding the key (a number from 0 to 25)
     to the letter's number modulo 26. In the Caesar cipher
     the key is 3.
E.g. Graph Theory rots → JUDSK WKHRUB
URWV
General Shift Cipher:
x → x + a (mod 26), 0 ≤ a ≤ 25
Freemason’s Cipher
    This cipher uses special symbols as the
    replacements for the letters.
    Decrypt the following encrypted message
    using Freemason’s Cipher.
Solution: MARY I LOVE YOU TOM
 Monoalphabetic using a key word
 Any permutation of the letters can be used for the
 substitution.
 An easy way to obtain a permutation is to pick a
 keyword or phrase, and write it down, letter by letter,
 below the alphabet in normal order, using a letter
 only the first time it appears in the keyword.
 The letters of the alphabet that are not used in the
 keyword are then listed in order after the keyword.
Mono alphabetic using a key word
      Using the key phrase: THIS IS A POSSIBLE
      KEYWORD. See the table obtained below:
  A B C D E F G H I J K L MN O P Q R S T U V WX Y Z
  T H I S A P O B L E K Y WR D C F G J MN Q U V X Z
Block Substitution – Playfair Cipher
     Invented by Sir Charles Wheatstone
     Below is an example of a playfair cipher




                                            continued
The aid used to carry out the encryption is a
5 x 5 square matrix similar to a Polybius
checkerboard in that it contains all the letters
of the alphabet (I and J are treated as the same
letter);
 However a keyword is placed first and then
the remaining letters are placed in alphabetical
order.
                                       continued
If the plaintext contains an odd number of
letters, then an X is appended to the last word
to make it an even number.
Also, if any of the digraphs consist of identical
letters e.g. SUMMER, then an extra letter is
placed between them.
The following rules are used in encrypting and
decrypting the given message.
Rules:
    1. If the pair of letters are in different rows
    and columns. The rows of the ciphertext letters
    are kept the same as the rows of the plaintext
    letters, however the columns swap.
    ME → SC
    E →letter in same row (2);in column of M (1).
    M →letter in same row (1) in column of E (3).
    Plaintext letters are at two corners of a rectangle
    and the ciphertext letters are at the other two
    corners.
Rules
    2. If the pair of letters are in the same row.
    The ciphertext letters are the letters to the
    right of the plaintext letters. For example, T
    and A are in the same row so T will encrypt to
    S and A will encrypt to B, forming SB.
    3. If the pair of letters are in the same
    column. The ciphertext letters are the letters
    below the plaintext letters. For example, Y
    and L are in the same column so Y becomes A
    and L becomes R, forming AR.
                                            continued
Example

        Encrypt the phrase "Merchant Taylors’
        School“ using play fair cipher:
        We get the following:
 Plaintext:   ME RC HA NT     TA   YL   OR   SZ   SC   HO    OL

 Ciphertext: SC OF LM    BI   AB AR     PU   BX   ME   OV    RH



    The last S of "TAYLORS" is paired with a Z to separate
    it from the first S of "SCHOOL"
Polyalphabetic (Vigenère – 1586)
    The best-known polyalphabetic ciphers are the
    simple Vigenère ciphers which are named after the
    16th century French cryptographer Blaise de
    Vigenère
    In the simplest system of the Vigenère type the key is
    a word or a phrase which is repeated over and over
    again.
    The plaintext is encrypted using the table in Figure 4.
    The ciphertext letter is found at the intersection of
    the column headed by the plaintext letter and the row
    indexed by the key letter.
Vigenère Cipher
Vigenère Cipher – cont’d
    To decrypt the plaintext letter is found at the
    head of the column determined by the
    intersection of the diagonal containing the
    cipher letter and the row containing the key
    letter.
    Encrypt the following message using the
    Vigenère Cipher given the secret key: “Don’t
    stand alone”
    "Merchant Taylors School"
Solution


Plaintext:   M E R C H A N T   T A Y L O R S   S C H O OL

Key:         D ON T S T A N    D A L O N E D   O N T S TA

Ciphertext: P S E V Z T N G    W A J Z B V V   G P A G HL
Example 2
         Encrypt the following message using the
         Vigenère Cipher given the secret key:
         “I LOVE YOU”
         “U ARE DIRECTED TO KILL PETER"

 Plaintext:    UA R E D I R E C T E D T O K I L L P E T ER


 Key:          I L O V E Y O U I L O V E Y O U I L O V E YO

 Ciphertext:
Limitation(s)
     The periodicity of the repeating key leads to
     the weaknesses in this method and its
     vulnerabilities to cryptanalysis.
     This periodicity of a repeating key can be
     eliminated by the use of a running-key
     Vigenère cipher, produced when a non-
     repeating key is used.
However, even though running-key ciphers
eliminate periodicity, it is still possible to
cryptanalyse them by means of several
methods,
But the job of the cryptanalyst is made much
harder and a cryptanalyst would require a
much larger segment of ciphertext to solve a
running-key cipher than one with a repeating
key.
     Cryptology and Coding
            Theory
                    Number Theory &
                 Examples of Some Ciphers


25 – Sept - 09     MBS - FCIT               37
Number theory
      Modulo Operation:
      Question: What is 12 mod 9?
      Answer: 12 mod 9 3 or 12 3 mod 9

      Definition: Let a, r, m  (where    is a set of all
      integers) and m 0. We write

         a r mod m if m divides r – a. where m is called the
      modulus & r is called the remainder

          a=q·m+r                   0   r<m

 25 – Sept - 09     MBS - FCIT              38
Number theory…Ctd
      Example: a = 42 and m=9
                42 = 4 · 9 + 6 therefore 42   6 mod 9

 Ring:
      Definition: The ring m consists of the set m = {0, 1, 2, …, m-1}
      Two operations “+” and “ ” for all a, b      m such that
       a + b c mod m (c     m)
       a b d mod m (d       m)
      Example: m = 9       9 = {0, 1, 2, 3, 4, 5, 6, 7, 8}
        6 + 8 = 14 5 mod 9
        6 8 = 48 3 mod 9



 25 – Sept - 09          MBS - FCIT                     39
Exponential in Zm
Example: Find i) 185 mod 12
                 ii) 79 mod 5
  i) Since 122 = 144,
            185 – 144 = 41.
            41 = 3 x 12 r 5
            185 = 5 mod 12
  ii) Since 75 = 5 x 15 and 79 – 75 = 4
            79 = 4 mod 5
  Find the following:
  129 mod 12__, 444 mod 12 __, 403 mod 3 __
  219 mod 7__, 5,245 mod 4__,719 mod 15__,
 6-Oct-09            MBS - FCIT           40
  The additive system adds its key to every letter’s
  number mod 26.
  If a plaintext letter is “f” and the key is 18. We
  take the position of “f” as 6 and add it to 18. We
  get 24 which corresponds to the letter “X.”
  If the plaintext letter is “r” and the key is 19, we
  add r’s position as 18 and add 19 and get 37.
  We find 37 mod 26 which is 11 which
  corresponds to “K.”
6-Oct-09         MBS - FCIT            41
To reverse the process (decipher), we have to do
the opposite process.
If the key was 4, we added 4 to every plaintext
position. To decipher, we need to subtract 4.
But in modulo systems, we prefer not to use
negatives. So realizing that - 4 ≡ 22mod 26, we add
22 to every letter position mod 26 in the ciphertext.
We call the deciphering key the “additive inverse.”
The additive inverse of 4 is 22 mod 26.
6-Oct-09        MBS – FCIT           42
    If the key was 19, the decipher key is -19. But
    -19 ≡ 7mod 26.
    So we add 7 to every letter position mod 26 in
    the ciphertext. So the additive inverse of 19 is
    7 mod 26.
    Find the following additive inverses of the
    following mod 26:
    15: ___,1: ___, 30: ___, 100:___, 296:___
6-Oct-09        MBS - FCIT            Continued
Prime Numbers
 Here we look at basic properties of positive
 whole numbers, especially with regard to
 multiplication.
 Some terminologies:
 Multiple:
 We say one number a is a multiple of another b
 if there is a positive integer c for which a=bc.
 Example: 35 is a multiple of 7 because .

 25 – 09 – 09   MBS – FCIT           44
  Divides:
  We say one number a divides another b if
  there is a positive integer c for which b=ac.
  In other words, b is a multiple of a.
  Example: 7 divides 35 because
  We also say b is divisible by a, and we write
  a/b (pronounced ``a divides b'').
  We can also call a a factor or divisor of b.

6-Oct-09        MBS - FCIT           45
  Factorization:
  A factorization of a number a is a way of
  writing a as a product of smaller numbers. For
  instance, 8x6x5 is a factorization of 240.
  Prime Number:
  A number p is said to be prime if it is bigger
  than 1 and its only divisors are 1 and itself.
  Composite:
  A number is composite if it is bigger than 1
  and not prime. That means it has divisors other
  than itself and 1.
6-Oct-09        MBS - FCIT           46
  Prime Factorization:
  A prime factorization of a number is a way of
  writing it as a product of prime numbers. For
  instance, 2x3x2x5x2x2 is a prime factorization
  of 240.
  Greatest Common Divisor:
  The greatest common divisor of two numbers
  a and b is the largest number d that divides
  both a and b.
   For example, the gcd of 30 and 42 is 6.

6-Oct-09       MBS - FCIT           47
  The greatest common divisor is also
  sometimes called the greatest common factor
  or highest common factor.
  Relatively Prime:
  Two numbers a and b are relatively prime if
  their greatest common divisor is 1.
  A proof that there are infinitely many prime
  numbers appeared in Euclid's Elements more
  than 2000 years ago.


6-Oct-09       MBS - FCIT          48
The Fundamental Theorem of Arithmetic
states that every number has a unique prime
factorization, subject to rearrangement of the
prime factors.
For example, the standard way of writing the
prime factorization of 240 is

								
To top