Classical Encryption Techniques
Classical Encryption Techniques
Faculty of science
Computer science department
Classical Encryption
Techniques
Lecture 3
Classical Encryption
Techniques
• Symmetric encryption
• Secret key encryption
• Privet key encryption
Symmetric Encryption
• or conventional / secret-key / single-key
• sender and recipient share a common key
• was the only type of cryptography, prior to
invention of public-key in 1970’s
Requirements
• Two requirements for secure use of
symmetric encryption:
– a strong encryption algorithm
– a secret key known only to sender / receiver
Y = EK(X)
X = DK(Y)
• assume encryption algorithm is known
• implies a secure channel to distribute key
Cryptanalysis
• •Cryptanalysis is the process of trying to find the
• plaintext or key
• •Two main approaches
• – Brute Force ( try all possible keys)
• – Exploit weaknesses in the algorithm or key
• ( e.g. key generated from password entered by
• user, where user can enter bad password )
Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
• assume either know / recognise plaintext
Note: DES has a 56 bit key; AES key has 128 , triple DES is 168 key
More Definitions
• unconditional security
– no matter how much computer power is
available, the cipher cannot be broken since
the ciphertext provides insufficient information
to uniquely determine the corresponding
plaintext
• computational security
– given limited computing resources (e.g., time
needed for calculations is greater than age of
universe), the cipher cannot be broken
Classical Encryption
Techniques
• Substitution ciphers
• Permutation (or transposition) ciphers
• Product ciphers
Classical Encryption
Techniques
▪ Substitution techniques
The letters of the message are replaced by
other letters or by numbers or symbols.
▪ Transposition techniques
Performing some sort of permutation on the
messages letters
Classical Substitution Ciphers
• where letters of plaintext are replaced by
other letters or by numbers or symbols
• or if plaintext is viewed as a sequence of
bits, then substitution involves replacing
plaintext bit patterns with cipher text bit
patterns
• Monoalphabetic
• Polyalphabetic
• Homophonic
Substitution Cipher types
1:- Monoalphabetic Substitution
A:- Caesar Cipher
B:- Affine Cipher
C:- Rot 13 Cipher
D:- Abash Cipher
Caesar Cipher
• earliest known substitution cipher
• by Julius Caesar
• first attested use in military affairs
• replaces each letter by 3rd letter on
• example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
• What’s the key?
A:- 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
EXAMPLE
KEY=5, gcd(5,26)=1
Index:0 1 2 3 4 5 6 7 8 9 10 1112…………………
Plain: 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
Cipher: A F K P U Z E J O T Y D I N S X C H M R W B G
Plaintext: TO BE OR NOT TO BE
Ciphertext: RS FU SH NSR RS FU
• 2-Multiplication Cipher
• Decipher :The standard cipher multiply each
character by inverse key K-1, that is
• D(C)= (C*k-1) mod n
• To find multiplication inverse ,then must satisfy
the equation a*a-1 mod 26 =1 , then 5-1 is 21 , so
must find the coprime( relatively prime)number
for 5 it is 21
because 5* 21 mod 26 =1
The only possible choices for the decimation cipher
E(p)= a*p mod 26 are a=
1,3,5,7,9,11,15,17,19,21,23,25
1 inv 1 3 inv 9 5 inv 21 7 inv 15 11 inv 19 17 inv 23 25
inv 25
• 2-Multiplication Cipher
• Decryption EXAMPLE
KEY=5, then K-1 =21
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X YZ
Cipher: A F K P U Z E J O T Y D I N S X C H M R W B G
D(C)= (C*21) mod 26
Ciphertext: RS FU SH NSR RS FU
R=17 :C(17)=17*21 mod 26=19 ,then 19 is T
S=18:C(18)=18*21 mod 26=14, then 14 is O
• Plaintext: TO BE OR NOT TO BE
Note
• Check the following video to find the Multiplicative
Inverse in cryptography
• https://www.youtube.com/watch?v=J2H8KdCyP7Q&list
=RDCMUCQIVUW5Ebv23tlqdimqa1Xg&start_radio=1
3-Affine cipher
• An encipherment scheme (or algorithm) of
the form
E(p) = (k1p + k2)MOD26
Here p is the numerical equivalent of the
given plaintext letter, and k1 and k2 are
(appropriately chosen) integers
Continued
Affine Ciphers
Figure Affine cipher
3.21
Continued
Example
The affine cipher uses a pair of keys in which the first key is
from Z26* and the second is from Z26.
Example
Use an affine cipher to encrypt the message “hello” with the key
pair (7, 2).
Continued
Example
Use the affine cipher to decrypt the message “ZEBBW” with the
key pair (7, 2) in modulus 26.
To find multiplication inverse ,then must satisfy the equation a*a-1 mod 26 =1 , then 7-1
is 15 , so must find the co prime number for 7 it is 15
Solution
Example
The additive cipher is a special case of an affine cipher in which
k1 = 1. The multiplicative cipher is a special case of affine cipher
in which k2 = 0.
Monoalphabetic
Monoalphabetic Substitution Cipher
E F G I/J K
L P Q S T
U V W X Z
Encrypting and Decrypting
3. Homophonic
One-Time Pad
• if a truly random key as long as the
message is used, the cipher will be secure
• called a One-Time Pad
• is unbreakable since ciphertext bears no
statistical relationship to the plaintext
• since for any plaintext & any ciphertext
there exists a key mapping one to other
• can only use the key once though
• have problem of safe distribution of key
2:- Transposition Ciphers
• now consider classical 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
1 . Message Reversal
• It’s the simplest type of ciphering were the
first letter goes to the last and the last
comes to first place
1 4
Example:
2 5 Plaintext: the meeting date is
Blocks : theme eting datei s
3 3 Ciphertext: meeth ngiet eitda s
4 1
5 2
2. Columnar transposition
• Is another type of transposition cipher
were letters are distributed on given Matrix
with fixed length and then read out again
column by column and the columns are
chosen in some scrambled order .
• Ex:-
Encrypt the plaintext (“CRYPTOGRAPHY” )
using a 3X4 matrix and encrypting the
message by [ 2 4 1 3 ]
• Ex:-
Encrypt the plaintext (“CRYPTOGRAPHY” )
using a 3X4 matrix and encrypting the
message by [ 2 4 1 3 ]
1 2 3 4
C R Y P
T O G R
A P H Y
Ciphertext : ROPPRYCTAYGH
3 . Rail Fence cipher
•
• Write message letters out diagonally over a
• number of rows
• • Then read off cipher row by row
• • e.g.. Message : “ATTACK AT MIDNIGHT”
• write message out as:
• A T C A M D I H
• T A K T I NG T
• • Cipher text is
• ATCAMDIHTAKTINGT
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
XOR Encryption(Stream type)
Decryption Equation
D(c)=C XOR Key
EXAMPLE
The plaintext is “FAB”
Key is V
ASCII representation of the plaintext: FAB
Hexadecimal representation of the plaintext:
46 41 42
decimal representation of the plaintext:
70 65 66
Binary representation of the plaintext: 1000110
1000001 1000010
ASCII representation of the key: V
Hexadecimal representation of the key:56
decimal representation of the key: 86
Binary representation of the key: 10000110
ENCRYPTION(XOR)
Plaintext: 1000110 1000001 1000010
key : 1010110 1010110 1010110
ciphertext: 0010000 0010111 0010100
DECRYPTION(XOR)
ciphertext: 0010000 0010111 0010100
key : 1010110 1010110 1010110
Plaintext: 1000110 1000001 1000010