cns19 Lec
cns19 Lec
Network Security
Lec#5
Dr M Imran
CNS19-QUIZ#1
Time: 10 min
Marks: 10
Traditional
Symmetric-Key
Ciphers…cont’d
3.3
Classical Ciphers
Substitution Ciphers
Mono alphabetic ciphers
Poly alphabetic ciphers
Transposition Ciphers
Mono alphabetic ciphers
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:-
3.6
26 × 12 = 312.
Example: Affine cipher
Use an affine cipher to encrypt the message “hello” with the key
pair (7, 2).
Use the affine cipher to decrypt the message “ZEBBW” with the
key pair (7, 2) in modulus 26.
Into ciphertext as
Monoalphabetic substitution
Cipher
now have a total of 26! = 4 x 1026 keys
with so many keys, might think is secure
but would be !!!WRONG!!!
problem is language characteristics
Polyalphabetic Ciphers
Autokey ciphers
Vigenere cipher
Playfair cipher
Hill Cipher
Autokey Cipher
In this cipher, the key is a stream of sub keys, in
which each sub key is used to encrypt the
corresponding character in the plaintext.
The first sub key is a predetermined value
chosen from Z26
use plaintext as remaining sub keys i.e.
The 2nd, 3rd, 4th, … sub keys are the values of the
1st,2nd,3rd,4th, 5th,….plaintext charters, repectivly.
P=P1P2P3P4…… C=C1C2C3C4…..
k=k1,P1P2P3P4
Encryption: Ci=(Pi+ki)mod 26
decryption: Pi=(Ci-ki)mod 26
Vigenère Cipher
In this cipher, an initial key stream of
length m is decided. K = k1 k2 ... km
The key stream is made up by repetition of
initial key stream.
Encryption and decryption is done as in
additive key cipher.
Example of Vigenère Cipher
write the plaintext out
write the keyword repeated above it
use each key letter as a shift cipher key
encrypt the corresponding plaintext letter
eg using keyword deceptive
key: deceptive
plaintext: we are discovered save
yourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Vigenere cipher can be seen as combinations of m additive ciphers.
3.19
Playfair Key Matrix
The key is 26 alphabets letters arranged in
a 5X5 matrix of letters
Different arrangements of the letter
creates different keys
Playfair Key Matrix
based on a keyword
fill in letters of keyword (sans 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
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
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
3.2.2 Continued
Playfair Cipher
Figure 3.13 An example of a secret key in the Playfair cipher
Example 3.15
Let us encrypt the plaintext “hello” using the key in Figure 3.13.
3.24