0% found this document useful (0 votes)
11 views

Module 1_part_2 -Cipher Techniques(1)

Uploaded by

rahul1121838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Module 1_part_2 -Cipher Techniques(1)

Uploaded by

rahul1121838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Cryptography and

Network Security
COMP4055
Cryptography
Module 1
Part 2
Cipher Techniques
Classical Substitution Ciphers
• A substitution cipher substitutes one piece
of information for another.

–This is most frequently done by offsetting


letters of the alphabet. (a.k.a. “shift
alphabet”)
Example of cryptographic algorithm:
Caesar’s cipher
Key=3
Starting with
ABCDEFGHIJKLMNOPQRSTUVWXYZ
and sliding everything up by 3, you get
DEFGHIJKLMNOPQRSTUVWXYZABC
Using this scheme, the plaintext, “SECRET” encrypts as “VHFUHW.”
Rotational Cipher
aka Caesar Cipher

Caesar cipher is one of the simplest and most widely known


encryption techniques.
For example,
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

When encrypting, a person looks up each letter of the message in


the "plain" line and writes down the corresponding letter in the
"cipher" line.
Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD
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 J K L M N O P Q R S T U V W X Y Z A B C
 mathematically give each letter a number
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
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(k, p) = (p + k) mod (26)
p = D(k, c) = (c – k) mod (26)
ROT13(Rotate by 13 places)
 A simple letter substitution cipher that replaces a letter with the 13th
letter after it in the alphabet. ROT13 is a special case of the Caesar
cipher.

Image from ROT13 - Wikipedia


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
Key: DKVQFIBJWPESCXHTMYAUOLRGZN

Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
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
Playfair Key Matrix
a 5X5 matrix of letters based on a keyword
fill in letters of keyword (without 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 (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
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
since still has much of plaintext structure
 What is the size of key space in the substitution monoalphabetic
cipher assuming 26 letters?
26!

 How to break a substitution cipher?


Use frequency of English letters
Use frequency of pairs of letters (digrams)
English Letter Frequencies
Polyalphabetic (or Running Key)
Cipher
• The running key cipher is a type of substitution cipher
– Invented by Blaise de Vigenère in 16th century
– The cryptographic algorithm is polyalphabetic
substitution, where the secret key is repeated
along the length of plaintext/ciphertext

Plaintext: COMPUTING GIVES INSIGHT

Keyword: LUCKYLUCK YLUCK YLUCKYL

Ciphertext: NIOZSECPQ ETPGC GYMKQFE


Polyalphabetic (or Running Key)
Cipher
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
Plaintext: COMPUTING GIVES INSIGHT 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 A
C 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

Keyword: LUCKYLUCK YLUCK YLUCKYL 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


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 D

Ciphertext: NIOZSECPQ ETPGC GYMKQFE F G H I J K L M N O P Q R S T U V W X Y Z A B C D E


G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
To Encrypt: J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

Take a letter from plaintext as column and the corresponding letter M


N
N
O
O P
P Q
Q
R
R S
S T
T
U
U V
V W
W
X
X
Y
Y Z
Z A
A
B
B C
C D
D
E
E
F G
F G
H
H
I
I
J K
J K
L
L
M
from keyword as row, the ciphertext is the intersection. O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

To Decrypt: R
S
S
T
T U
U V
V
W
W X
X Y
Y
Z
Z
A B
A B
C
C
D
D E
E F
F
G
G H
H I
I
J
J
K
K
L
L
M
M
N
N O
O P
P
Q
Q
R
T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
Take a letter from the keyword, go to its row. Find the ciphertext in V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

that row. The corresponding column header is the plaintext. W


X
X
Y
Y Z
Z A
A
B
B C
C D
D
E
E
F G
F G
H
H
I
I
J K
J K
L
L M
M N
N
O
O P
P Q
Q
R
R
S
S T
T U
U
V
V
W
Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z 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

Source: h t t p : / / p a g e s . m t u . e d u / ~ s h e n e / N S F - 4 / Tu t o r i a l / V I G / V i g - B a s e . h t m l
Encryption Operations: Vernam
Cipher
 Developed at AT&T
 Uses a set of characters for encryption operations only one time and then discards
it
 Encryption process
 Values from one-time pad added to the block of text
 Resulting sum is converted to text
 When the two sets of values are added, if the resulting values exceed 26
 26 is subtracted from the total (called modulo 26 in Modular arithmetic)

• Decryption process
• Take the first letter of the ciphertext and the first letter of the key, and
subtract their value. If the result is negative, add 26

18
Encryption Operations: Vernam
Cipher (cont’d.)

19
Transposition Cipher

• Instead of replacing the characters with other characters, this cipher


simply changes the order of the characters.

• A method of encryption which scrambles the positions of


characters (transposition).
Example 1: Rail Fence Cipher

Encrypt “DCODEZIGZAG” with N=3 is : DEZCDZGAOIG

What about “hereisanexample” ?

 Reference:
https://www.dcode.fr/rail-fence-cipher
https://crypto.interactive-maths.com/rail-fence-cipher.html
Transposition Cipher Key

• The key determines the positions that the characters are moved to
– Instead of a list of alphabetic substitutions, it is a mapping order.
– Such as (1,2,3,4,5) = (3,4,5,2,1). This means that the third element is put in place of the first,
thus followed by the fourth, then the fifth, second, and finally followed by the original first
element.
– Key can be a word such as "WORLD“. Based on alphabet order, the key order is “53412"
Example 2: Columnar transposition

 In a columnar transposition, the message is written out in rows of a


fixed length, and then read out again column by column, and the
columns are chosen in some scrambled order.

Ref: Columnar Transposition Cipher - Detailed Guide 2022 - Privacy Canada


Double Transposition
 A single columnar transposition could be attacked by guessing
possible column lengths.
 To make it stronger, a double transposition was often used. This is
simply a columnar transposition applied twice. The same key can be
used for both transpositions, or two different keys can be used.

Ref: Transposition cipher - Wikipedia


Transposition Cipher
• Permutations of this cipher run in blocked matrices. This means that the message
is spread out into a matrix.
• Consider the following plaintext message.
Comp4055teachesciphers
We will encipher it using a permutation that divides the message into 5-letter
blocks, then we have
Comp4 055te aches ciphe rs
Because the numbers of the letters in the plaintext message is not a multiple of 5,
the last block must be padded. In this example, the last block is padded with x’s.
Comp4 055te aches ciphe rsxxx
Then we rearrange the letters of the blocks according to the following permutation:
12345
45132
Permutations-Cont.
The letter in the first position of the block (on the left) moves to position 3, the letter
in position 2 moves to position 5, the letter in position 3 moves to position 4, the letter
in position 4 moves to position 1, and the letter in position 5 moves to position 2.
After the permutation is applied to the first block, we have:

1 2 3 4 5
C 0 m P 4

4 5 1 3 2
p 4 C m 0
When the permutation is applied to all the blocks, we obtain:
Comp4 055te aches ciphe rsxxx
p4Cmo te055 esahc hecpi xxrxs
So, the ciphertext message is
Concealment Cipher
The concealment cipher hides a message in a longer message i.e. “a
message WITHIN a message”
• A paragraph is sent to you containing an embedded secret
message.
• Example:
– The agreed upon secret key is to use every sixth word.
– Selecting every sixth word in the paragraph will decrypt the message

“I have been trying to buy you a

nice gift like gold or an


antique but prices no are really high.”
w
Steganography
Steganography is a method of hiding data in another media so that the data's very
existence is concealed.
– Microdot, very popular in World War II
– Computer files (graphic images, MP3, or video) contain unused or insignificant areas of
data… Steganography takes advantage of these areas, replacing them with information.
– The files can then be exchanged without anyone knowing what really lies inside of them.
– Web Bugs – malicious version of Steganography.
– Can be used to insert concealed digital watermarks.

Covered more in Module 3


Product Ciphers
 ciphers using substitutions or transpositions are not secure 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 new much harder
cipher
 this is bridge from classical to modern ciphers
Rotor Machines
 Mechanical substitution ciphers
 before modern ciphers, rotor machines were most common complex
ciphers in use
 widely used in WW2
 German Enigma, Allied Hagelin, Japanese Purple
 implemented a very complex, varying substitution cipher
 used a series of cylinders, each giving one substitution, which rotated
and changed after each letter was encrypted
 with 3 cylinders have 263=17576 alphabets
Hagelin Rotor Machine
Rotor Machine Principles

You might also like