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

Classical Encryption Techniques

The document discusses classical encryption techniques, focusing on symmetric encryption and various types of ciphers, including substitution and transposition ciphers. It outlines the requirements for secure symmetric encryption, cryptanalysis methods, and specific examples such as the Caesar and Vigenère ciphers. Additionally, it highlights the importance of key distribution and the vulnerabilities of different cipher types to brute-force attacks.

Uploaded by

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

Classical Encryption Techniques

The document discusses classical encryption techniques, focusing on symmetric encryption and various types of ciphers, including substitution and transposition ciphers. It outlines the requirements for secure symmetric encryption, cryptanalysis methods, and specific examples such as the Caesar and Vigenère ciphers. Additionally, it highlights the importance of key distribution and the vulnerabilities of different cipher types to brute-force attacks.

Uploaded by

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

University of Duhok

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

• mathematically give each letter a number


a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y Z
13 14 15 16 17 18 19 20 21 22 23 24 25

• then have Caesar cipher as:


C = E(p) = (p + k) mod (26)
p = D(C) = (C – k) mod (26)
• EXAMPLE
• Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
• Cipher: FGHIJKLMNOPQRSTUVWXYZABCDE

Encryption by using Caesar Cipher method:


Key =3
• Plaintext: SEND HELP SOON
• Ciphertext: VHQG KHOS VRRQ
• K=5 ????
• Plaintext : SEND HELP SOON
• Ciphertext: ??????
• EXAMPLE
• KEY=5
• Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
• Cipher: FGHIJKLMNOPQRSTUVWXYZABCDE

• Plaintext: SEND HELP SOON


• Ciphertext: XJSI MJQU XTTS
Cryptanalysis of Caesar Cipher
• only have 26 possible ciphers
– A maps to A,B,..Z
• could simply try each in turn
• a brute force search
• given ciphertext, just try all shifts of letters
• e.g., break ciphertext "GCUA VQ DTGCM"
2-Multiplication Cipher

The standard alphabet multiply each character by


a key K, that is
E(p)= (p*k) mod n

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

Because additive, multiplicative, and affine ciphers have small


key domains, they are very vulnerable to brute-force attack.

A better solution is to create a mapping between each plaintext


character and the corresponding ciphertext character. Alice and
Bob can agree on a table showing the mapping for each
character.
Figure An example key for monoalphabetic substitution cipher
Monoalphabetic Cipher Security

• 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
Language Redundancy and
Cryptanalysis
• human languages are redundant
• eg "th lrd s m shphrd shll nt wnt"
• letters are not equally commonly used
• in English E is by far the most common letter
– followed by T,R,N,I,O,A,S
• other letters like Z,J,K,Q,X are fairly rare
• have tables of single, double & triple letter
frequencies for various languages
English Letter Frequencies
Example Cryptanalysis
• given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• count relative letter frequencies (see text)
• guess P & Z are e and t
• guess ZW is th and hence ZWP is the
• proceeding with trial and error finally get:
it was disclosed yesterday that several informal but
direct contacts have been made with political
representatives of the viet cong in moscow
Substitution Cipher types
2:- POLYALPHABETIC
Playfair Cipher

• Block Cipher :blocks of letters encrypted


simultaneously
• 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 (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
EXAMPLE
KEY:SUBSTITUTION
SUBTION( key with out repeat letters)
S U B T I/J
O N A C D
E F G H K
L M P Q R
V W X Y Z

Plaintext: UNIVERSITY OF DUHOK


UN IV ER SI TY OF DU HO KX
NF SZ KL US CT NE NI EC GZ
Ciphertext: NFSZKLUSCT NE
Polyalphabetic Ciphers
• another approach to improving security is to use
multiple cipher alphabets
• called polyalphabetic substitution ciphers
• makes cryptanalysis harder with more alphabets
to guess and flatter frequency distribution
• use a key to select which alphabet is used for
each letter of the message
• use each alphabet in turn
• repeat from start after end of key is reached
The Vigenère Cipher
Treat letters as numbers: [A=0, B=1, C=2, …, Z=25]
Number Theory Notation: Zn= {0, 1, …, n-1}
Definition:
Given m, a positive integer, P = C = (Z26)n, and K =
(k1, k2, … , km) a key, we define:
Encryption:
ek(p1, p2… pm) = (p1+k1, p2+k2…pm+km) (mod 26)
Decryption:
dk(c1, c2… cm) = (c1-k1, c2-k2 … cm- km) (mod 26)
Example:
Plaintext: C R Y P T O G R A P H Y
Key: LUCKLUC KLUCK
Ciphertext: N L A Z E I I B L J J I
Vigenère Cipher
• simplest polyalphabetic substitution cipher
is the Vigenère Cipher
• effectively multiple caesar ciphers
• key is multiple letters long K = k1 k2 ... kd
• ith letter specifies ith alphabet to use
• use each alphabet in turn
• repeat from start after d letters in message
• decryption simply works in reverse
Example
• write the plaintext out
• write the keyword repeated above it
• use each key letter as a caesar cipher key
• encrypt the corresponding plaintext letter
• eg using keyword deceptive
HW:-
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ????
Substitution Cipher types

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

• EX. M= We Will Meet Next Month


C= htnom txen teem lliw eW
• This type of cipher can be organized in
another way. We can classify the message
as blocks of letters
• Ex. Use blocks of 5 letters (b=5) and the
permutation function is ( f = 4,5,3,1,2)

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)

The XOR encryption is a simple


symmetric cipher that is used in many
applications.
XOR (Exclusive OR) is a bitwise
operator from binary mathematics.
The XOR operator returns a 1 when the
value of either the first bit or the
second bit is a 1.The XOR operator
returns a 0 when neither or both of the
bits are 1.
XOR Encryption(Stream type)
• Encryption Equation:

E(P)= P XOR key

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy