CH 02 Basics of Cryptography
CH 02 Basics of Cryptography
Basics of Cryptography
• Symmetric Cipher Model
• Substitution Techniques
• Transportation Techniques
• Other Cipher Properties- Confusion, Diffusion, Block and Stream
Ciphers.
10-Feb-21
Symmetric cipher Model
10-Feb-21
Symmetric cipher Model
If P is the plaintext, C is the ciphertext, and K is the key,
10-Feb-21
Cryptanalysis
• Cryptography is the science and art of creating secret
codes.
• Cryptanalysis is the science and art of breaking those
codes.
10-Feb-21
1. Ciphertext-Only Attack
10-Feb-21
2. Known-Plaintext Attack
10-Feb-21
3. Chosen-Plaintext Attack
10-Feb-21
Chosen-Ciphertext Attack
10-Feb-21
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 Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs
128 2128 = 3.4 × 1038 2127 µs = 5.4 × 1024 years 5.4 × 1018 years
168 2168 = 3.7 × 1050 2167 µs = 5.9 × 1036 years 5.9 × 1030 years
26 characters 26! = 4 × 1026 2 × 1026 µs = 6.4 × 1012 years 6.4 × 106 years
(permutation)
10-Feb-21
Network security
encryption/ decryption
types of ope.used to trans. crypto. Sys. Based on way in which plain text is
Plain text to cipher text (1) no. of keys used(2) processed(3)
asymmetric
Substitution type Transposition symmetric
type Block cipher Stream cipher
Multip
Affine
licative
Mono Play fair Hill
autokey vigenere
Caesar/ Alpha cipher
10-Feb-21
additive betic
Categories of Traditional ciphers
⚫ Substitution cipher
⚫ Transposition cipher
10-Feb-21
Substitution cipher
⚫ Monoalphabetic cipher
⚫ Additive Cipher/Ceaser cipher
⚫ Multiplicative cipher
⚫ Affine cipher
10-Feb-21
Monoalphabetic cippher
⚫ 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
10-Feb-21
Monoalphabetic Cipher Security
⚫ now have a total of 26! = 4 × 1026
⚫ with so many keys, might think is secure
⚫ but would be !!!WRONG!!!
⚫ problem is language characteristics
10-Feb-21
Additive Cipher
10-Feb-21
Additive cipher(Caesar Cipher)
⚫ replaces each letter by 3rd letter on
⚫ The alphabet is wrapped around so that after Z follows
A:
10-Feb-21
Additive cipher(Caesar Cipher)
⚫ then have Caesar cipher as:
c = E(k, p) = (p + k) mod (26)
p = D(k, c) = (c – k) mod (26)
⚫ example:
c = E (3, p) = (p + 3) mod (26)
p = D(3, c) = (c – 3) mod (26)
10-Feb-21
Multiplicative Ciphers
10-Feb-21
Multiplicative Ciphers
What is the key domain for any multiplicative cipher?
• The key needs to be in Z26*.
• This set has only 12 members: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21,
23, 25.
10-Feb-21
Affine cipher
10-Feb-21
Affine cipher
• The affine cipher uses a pair of keys in which the first key is from
Z26* and the second is from Z26.
• The size of the key domain is 26 × 12 = 312.
Use an affine cipher to encrypt the message “hello” with the key
pair (7, 2).
10-Feb-21
Affine
cipher
Use the affine cipher to decrypt the message “ZEBBW” with the
key pair (7, 2) in modulus 26.
Solution
10-Feb-21
Playfair Cipher
⚫ not even the large number of keys in a monoalphabetic
multiple letters
10-Feb-21
Playfair Key Matrix
⚫ a 5X5 matrix of letters based on a keyword
⚫ fill in letters of keyword (minus duplicates)
⚫ fill rest of matrix with other letters
⚫ eg. using the keyword MONARCHY
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
10-Feb-21
Encrypting and Decrypting
⚫ plaintext is encrypted two letters at a time
1. If a pair is a repeated letter, insert filler like 'X’
2. If both letters fall in the same row, replace each
with letter to right (wrapping back to start from
end)
3. If both letters fall in the same column, replace
each with the letter below it (again wrapping to top
from bottom)
4. Otherwise each letter is replaced by the letter in
the same row and in the column of the other letter
of the pair
Wireless wi re le sx sz XG MK UL XA TX 10-Feb-21
Example
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Wireless wi re le sx sz XG MK UL XA TX
Monday mo nd ay ON RY NB
10-Feb-21
Security 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, given a few hundred letters
⚫ since still has much of plaintext structure
10-Feb-21
Vigenere
Cipher
Example
3.16
We can encrypt the message “She is listening” using
the 6-character keyword “PASCAL”.
3.29
Let us see how we can encrypt the message “She is
listening” using the 6-character keyword “PASCAL”. The
initial key stream is (15, 0, 18, 2, 0, 11). The key
stream is the repetition of this initial key stream (as
many times as needed).
3.30
Vigenere cipher can be seen as combinations of m
additive ciphers.
3.31
Using we can say that the additive cipher is a special
case of Vigenere cipher in which m = 1.
3.32
Hill Cipher
⚫ Takes two or three or more letter combinations to the same
size combinations, e.g. “the” “rqv”
⚫ Uses simple linear equations
⚫ An example of a “block” cipher encrypting a block of text at
a time
⚫ Numbered alphabet: a = 0, b = 1, c = 2, etc.
Hill cipher
C=E(K, P)=KP mod 26
P=D(K, P)=K-1C mod 26
10-Feb-21
Hill chipher Example 1
encryption
10-Feb-21
key for decryption
Decryption
10-Feb-21
Hill Cipher example2 encryption
10-Feb-21
Hill Cipher
10-Feb-21
Hill Cipher
10-Feb-21
Hill Cipher
10-Feb-21
Hill Cipher example 2 decyption
10-Feb-21
Hill Cipher
10-Feb-21
Hill chipper example 3
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
10-Feb-21
Transposition Ciphers
⚫ 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
10-Feb-21
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: “Meet me at the
park”
ciphertext “MEMATEAKETETHPR”.
10-Feb-21
Columnar transposition(without key)
⚫ Arrangement of plaintext into columns.
⚫ Example: four columns. Plaintext is written row by
row, in a table of four columns.
⚫ Plain text: meet me at the park
3.57
Alice needs to send the message “Enemy attacks
tonight” to Bob..
3.58
3.3.3 Combining Two
Approaches
Example
3.26 Figure 3.21
3.59
Key
s
In Example a single key was used in two directions for
the column exchange: downward for encryption,
upward for decryption. It is customary to create two
keys.
3.60
Using
Matrices
We can use matrices to show the encryption/decryption
process for a transposition cipher.
Example
3.27
Figure 3.24 Representation of the key as a matrix in the transposition
cipher
3.61
Columnar transposition(with key)
⚫ write letters of message out in rows over a specified number of
columns
⚫ then reorder the columns according to some key before reading
off the rows
⚫ plain text: this is css third year class
⚫ Key: 3 4 2 1 5
t h i s i
s c s s t
h i r d y
e a r c l
a s s z z
Ciphertext: ISRRSSSDCZHCIASTSHEAITYLZ
10-Feb-21
Stream Ciphers
Call the plaintext stream P, the ciphertext stream C, and
the key stream K.
10-Feb-21
Block cipher
⚫ A symmetric-key modern block cipher encrypts an
10-Feb-21
Confusion and Diffusion
⚫ Diffusion : to hide the relationship between the cipher text
and the plain text.
⚫ Diffusion implies that each symbol in the cipher text is
dependent on some or all symbols in the plain text.
⚫ This will frustrate the opponent who use cipher text
statistics to find the plain text.
⚫ Confusion: to hide the relationship between the cipher text
and the key.
⚫ If a single bit in the key is changed most or all bits in the
cipher text will also be changed.
⚫ This will frustrate the opponent who use cipher text
statistics to find the key
10-Feb-21