Download as pdf or txt
Download as pdf or txt
You are on page 1of 148

Chapter 1.

Number theory and basic


cryptography
PROF. KANCHAN K. DOKE
Index 2

 Security types
 Security Goals
 Attacks
 Services and Mechanism
 Modular arithmetic
 Classic encryption techniques
 Substitution
 Transposition

Prof. Kanchan K. Doke


3

Computer

Security
Network
types

Internet
Prof. Kanchan K. Doke
Computer Security 4

 Computer security refers to measures and


controls that ensure the confidentiality,
integrity and availability of the
information processed and stored by a
computer.
 Eg.: protecting physical information
assets, to data security and computer
safety practices
 Computer security ensures that a
business’s data and computer systems
are safe from breaches and unauthorized
access.
Prof. Kanchan K. Doke
Network security 5

 The collection of techniques,


procedures, and tools known as
network security is intended to
keep an organization's network
safe from damage and
unwanted access.

Prof. Kanchan K. Doke


Internet security 6

 Securityintended to
keep networks, web
browsers, web apps,
websites, and other
connected devices safe
as well as user activity

Prof. Kanchan K. Doke


Security Goals 7

 Confidentiality
 Data confidentiality: Protection of data from unauthorized access and disclosure
 Privacy : Secure private information from unauthorized people
 Eg: Bank details
 Integrity
 Data integrity : Programs and information are only changed in ways that are
authorized and defined
 System integrity :The system operates as intended
 Eg. patient information
 Availability
 Ensure that systems are operational and running quickly
 Eg. authentication service Prof. Kanchan K. Doke
OSI (Open Systems Interconnection) 10
Security Architecture

 Security Architecture defines:


 A systematic approach to providing security at each
layer.
 It defines security services and security mechanisms
that can be used at each of the seven layers of the OSI
model to provide security for data transmitted over a
network.

Prof. Kanchan K. Doke


OSI (Open Systems Interconnection) 11
Security Architecture
OSI Security Security Attack:
Architecture is an attempt by a person or entity to gain
unauthorized access to disrupt or compromise the
security of a system, network, or device.

Security Service:
is a service available for maintaining the
security and safety of an organization

Security Mechanism:
is design to detect, prevent or recover from
security attack
Prof. Kanchan K. Doke
Security Attack 12

Security
Attack

Passive Active
attacks attacks

The release
Traffic Modification Denial of
of message Masquerade Repudiation Replay
analysis of messages Service
content

Prof. Kanchan K. Doke


Passive Attack 13

 Attacker
learn or make use of the messages and copy them contents of
messages without altering or destroying it
 These attacks are difficult to detect because they do not involve any
alteration of the data.

Prof. Kanchan K. Doke


Passive Attack 14

 The release of message content:


 Attacker secretly listens to a conversation or communication that is not intended for
him.
 It can be done for various purposes, such as gathering information, spying, or
blackmailing.

Prof. Kanchan K. Doke


Passive Attack 15

 Traffic analysis –
 Focuses on observing the exchange of information between two entities to extract valuable
information.
 Can’t read the message but only understand the pattern and length of encryption
 Information used by attackers to discover the geographical location and the identities of the
communicating entities, along with details regarding the frequency and duration of the
exchanged messages.

Prof. Kanchan K. Doke


Active Attack 16

 Attacker actively disrupting or altering


system, network, or device activity
 Attacker attempt to gain unauthorized
access to a system or network.
 An active attack typically aims to gain
control over the system or steal data.
 Because of the data modification, these
attacks greatly threaten the integrity and
availability of data.

Prof. Kanchan K. Doke


Active Attack 17

Active
Attacks
Masquerade
Message Modification
Replay
DOS attack
Prof. Kanchan K. Doke
Active Attack: Masquerade 18

 An attacker pretends to be someone else in order to gain access to


systems or data.

 Types
 Username and password masquerade
 IP address masquerade
 Website masquerade
 Email masquerade

Prof. Kanchan K. Doke


Active Attack: Modification of messages 19

 Some portion of a message is altered or that message is delayed or reordered to


produce an unauthorized effect
 Unauthorized parties not only gain access to data but also spoof the data by triggering
denial-of-service attacks, such as altering transmitted data packets or flooding the
network with fake data

Prof. Kanchan K. Doke


Active Attack: Replay 21

 Attacker save a copy of the data originally present on that particular network and later
on use this data for personal uses.
 Once the data is corrupted or leaked it is insecure and unsafe for the users.

Prof. Kanchan K. Doke


Active Attack: Denial of Service 22

 It makes a system or network unavailable to its intended users by overwhelming it with


traffic or requests.
 In a DoS attack, an attacker floods a target system or network with traffic or requests in
order to consume its resources, such as bandwidth, CPU cycles, or memory, and prevent
legitimate users from accessing it
 Types:
 Flood attacks
 Amplification attacks

Prof. Kanchan K. Doke


Difference Between Active and Passive 23
Attacks
Benchmark Active Attack Passive Attack

It is a type of attack in which hackers modify It is an attack in which hackers do not modify
Definition the information or the data. the information or the data.

It is a danger to the Integrity and availability of the data. Confidentiality of the data.

Causes harm to the system? Yes. No.

In this type of attack, attention is on Prevention. Detection.


In this attack, is the victim informed
No. Yes.
that he has been attacked?
Can this type of attack be easily
prohibited in comparison to the No. Yes.
other?
Can it be easily detected? Yes. No.

The duration of this type of attack is Short. Long.


The prevention possibility of this
High. Low.
type of attack is
Complexity High. Low.
Purpose To harm the system or the organization To learn about the system or the organization.
Prof. Kanchan K. Doke
Security Service 24

 The processing or communication service that is provided by a system to give a


specific kind of protection to system resource
 Security services implement security policies and are implemented by security
mechanism
 Services defined by The international Telecommunication Union-
Telecommunication Standardization sector (ITU-T) :

Security Services

Data Non-
Data integrity Authentication Access control
Confidentiality repudiation
Prof. Kanchan K. Doke
Security Services (ITU-T) 26

 Data Confidentiality –protection of data from unauthorized


disclosure
 Connection Confidentiality:
All user data on a connection link is protected.
 Connectionless Confidentiality:
All user data is protected in a single data block.
 Selective-Field Confidentiality:
Selected fields within user data on a connection or in a single data
block are kept confidential
 Traffic Flow Confidentiality:
 protecting the data obtained from traffic flow observation.Prof. Kanchan K. Doke
Security Services (ITU-T) 27

 Data Integrity - assurance that data received is as sent by an authorized


entity
 Connection Integrity with Recovery: Provides for the integrity of all user data on a
connection by detecting any modification, insertion, deletion, or replay of any data within
an entire data sequence and recover it
 Connection Integrity without Recovery: As above, but provides only detection without
recovery.
 Selective-Field Connection Integrity: Provides for the integrity of selected fields within
the user data of a data block transferred over a connection and takes the form of
determination of whether the selected fields have been modified, inserted, deleted, or
replayed.
 Connectionless Integrity: Provides for the integrity of a single connectionless data block
and may take the form of detection of data modification. Additionally, a limited form of
replay detection may be provided.
 Selective-Field Connectionless Integrity: Provides for the integrity of selected fields
Prof. Kanchan K. Doke
Security Services (ITU-T) 28

 Authentication - assurance that communicating entity is the one claimed


 Peer Entity Authentication:
 Used in association with a logical connection to provide confidence in the
identity of the entities connected.
 Data Origin Authentication:
 In a connectionless transfer, provides assurance that the source of received
data is as claimed. Prof. Kanchan K. Doke
Security Services (ITU-T) 29

 Non-Repudiation - protection against denial by one of the parties in a


communication
 Nonrepudiation, Origin: Proof that the message was sent by the
specified party.
 Nonrepudiation, Destination: Proof that the message was received by
the specified party Prof. Kanchan K. Doke
Security Services (ITU-T) 30

 Access Control:
 Isthe ability to limit and control the access to host systems and
applications via communications links
 The prevention of unauthorized use of a resource (i.e., this service
controls who can have access to a resource, under what conditions
access can occur, and what those accessing the resource are Prof. Kanchan K. Doke
Security Mechanism 31

 Feature designed to detect, prevent, or recover from a security attack


 Responsible for protecting a system, network, or device against
unauthorized access, tampering, or other security threats.

Security
Mechanism

Digital Authentication Traffic Routing


Encipherment Access control Data integrity Notarization
signature exchange padding control

Prof. Kanchan K. Doke


Security Mechanism 32

 Encipherment:
 This is the process of using mathematical algorithms to transform data into a
form that is not readily intelligible.
 Digital Signature:
 Data or cryptographic transformation of a data unit is appended to the data,
so that the recipient of the data unit is convinced of the source and integrity of
the data unit and this can also serve to protect the data against forgery (e.g.,
by the recipient).
 Access Control:
 A variety of mechanisms are available that enforce access rights to resources.
 Data Integrity:
 A variety of mechanisms may be used to assure the integrity of a data unit or
stream of data units.
Prof. Kanchan K. Doke
Security Mechanism 33

 Authentication Exchange:
 This is a mechanism intended to ensure the identity of an entity by means of
information exchange
 Traffic Padding:
 The insertion of bits into gaps in a data stream is called traffic padding. This
helps to prevent traffic analysis attempts.
 Routing Control:
 Routing control enables selection of particular physically secure routes for
certain data transmission and allows routing changes, especially when a
breach of security is suspected.
 Notarization:
 This is the use of a trusted third party to assure certain properties of a data
exchange.
Prof. Kanchan K. Doke
Attackers and Risks types 35

 Attackers
 Hacker: The one who is only interested in penetrating into your system. They
do not cause any harm to your system they only get satisfied by getting
access to your system.
 Intruders:These attackers intend to do damage to your system or try to
obtain the information from the system which can be used to attain
financial gain.
 Risks
 Information threat: This kind of threats modifies data on the user’s behalf to
which actually user should not access. Eg.: enabling some crucial permission
in the system.
 Service threat: This kind of threat disables the user from accessing data on
the system. Prof. Kanchan K. Doke
Network security model 36

 It demonstrates how the security services has been configured


over the network to prevent the attacker from threatening the
confidentiality or authenticity of the data being transmitted over
the network

Network Securing information over the network during


security information transmission
model
Securing information system which can be
accessed by the hacker through the network
or internet.
Prof. Kanchan K. Doke
Model for Network Security 37

Components Encryption: Transformation of the information which has


of security to be sent to the receiver.
services
Encryption key: Sharing of the secret
information between sender and receiver of which the
opponent must not any clue

Trusted third party : which should take the responsibility


of distributing the secret information (key) to both the
communicating parties and also prevent it from any
opponent.

Prof. Kanchan K. Doke


Model for Network Security.. 38
Information security
Model for Network Security.. 39
Information security
 Using this model requires us to:
1. Design a suitable algorithm for the security transformation
2. Generate the secret information (keys) used by the algorithm
3. Develop methods to distribute and share the secret information
4. Specify a protocol enabling the principals to use the
transformation and secret information for a security service

Prof. Kanchan K. Doke


Model for Network Access Security 40

 Ways to secure system from attacker


 Gatekeeper function : login-id and passwords
 Internal control: antivirus

Prof. Kanchan K. Doke


Model for Network Access Security 41

 Using this model requires us to:


1. Select appropriate gatekeeper functions to identify users
2. Implement security controls to ensure only authorised users access
designated information or resources

 Note that model does not include:


1. Monitoring of system for successful penetration
2. Monitoring of authorized users for misuse
3. Audit logging for forensic uses, etc.

Prof. Kanchan K. Doke


42

Modular Arithmetic
Greatest Common Divisor (GCD) 43

 A common problem in number theory


 GCD (a,b) of a and b is the largest number that divides evenly
into both a and b
 Eg GCD(60,24) = 12
 Often want no common factors (except 1) and hence numbers
are relatively prime
 Eg GCD(8,15) = 1
 Hence 8 & 15 are relatively prime

Prof. Kanchan K. Doke


Greatest Common Divisor 44

(GCD)…examples
Eg. GCD(12,33)=? 12 33
Divisors 1,2,3,4,6,12 1,3,11,33
Common Divisors 1,3
Greatest Common Divisor
3
(GCD)

Eg. GCD(25,150)=? 25 150

Divisors 1,5,25 1,2,3,5,6,10,15,25,30,50,75,150

Common Divisors 1,5,25


Greatest Common Divisor (GCD) 25
Prof. Kanchan K. Doke
Euclidean Algorithm 45

 An efficient way to find the gcd(a,b)


 Uses theorem that:
 Gcd(a,b) = gcd(b, a mod b)
 Euclidean algorithm to compute gcd(a,b) is:
 Prerequisite : a>b
Euclid(a,b)
1. If A = 0 then GCD(A,B)=B, since the GCD(0,B)=B, and we can stop.
2. if B = 0 then GCD(A,B)=A, since the GCD(A,0)=A, and we can stop.
3. else
1. return Euclid(b, a mod b)

Prof. Kanchan K. Doke


Euclidean Algorithm….Ex1 46

 Find GCD(50,12)
 Solution:
 Here a=50 and b=12
 GCD(a,b) =GCD(b, a mod b)
 GCD(50,12)= GCD(12, 50%12) = GCD(12, 2)
 GCD(12, 2) = GCD(2, 12%2) = GCD(2, 0) =2
 GCD(50,12) =2

Prof. Kanchan K. Doke


Euclidean Algorithm….Ex2 47

 Find GCD(83,19)
 Solution:
 Here a=83 and b=19
 GCD(a,b) =GCD(b, a mod b)
 GCD(83,19)= GCD(19, 83%19) = GCD(19, 7)
 GCD(19, 7) = GCD(7, 19%7) = GCD(7, 5)
 GCD(7,5) = GCD(5, 7%5) = GCD(5, 2)
 GCD(5, 2) = GCD(2, 5%2) = GCD(2, 1)
 GCD(2, 1) = GCD(1, 2%1) = GCD(1, 0)=1
 GCD(83,19) =1

Prof. Kanchan K. Doke


Euclidean Algorithm….Ex3 48

 Find GCD(3084,1424)
 Solution:
 Here a=3084and b=1424
 GCD(a,b) =GCD(b, a mod b)
 GCD(3084,1424)= GCD(1424, 3084%1424) = GCD(1424, 236)
 GCD(1424, 236) = GCD(236, 1424%236) = GCD(236, 8)
 GCD(236,8) = GCD(8, 236%8) = GCD(8, 4)
 GCD(8, 4) = GCD(4, 8%4) = GCD(4, 0) =4
 GCD(3084,1424) = 4

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 50

 Definition
Given an integer n, (n) = | Zn*| is the number of all numbers a
such that 0 < a < n and a is relatively prime/coprime to n
(i.e., gcd(a, n)=1).

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 51

Eg: Find Φ(II)

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 52

Eg: Find Φ(8)

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 53

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 54

 Prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199

 If n is prime then (n)=n-1


 eg.
 (5)=5-1=4 …there are 4 numbers that are lesser than 5 and relatively prime to 5
 (23)= 23-1=22…there are 22 numbers that are lesser than 23 and relatively
prime to 23
 (31)= 31-1= 30…there are 30 numbers that are lesser than 31 and relatively
prime to 31

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 55

 Eg:
Find (35)
n=35…n is the product of two prime numbers 5 and 7
So p=5 and q=7
(n)=(p-1)*(q-1) (i.e. (p) * (q))
(35)=(5-1)*(7-1)
(35)=4*6
(35)=24
There are 24 numbers that are lesser than 35 and relatively prime to 35
Find (15) and (9)
Prof. Kanchan K. Doke
Euler’s Totient Function….Phi function 56

 Find (1000)

Prof. Kanchan K. Doke


Euler’s Totient Function….Phi function 57

 Find (7000)

Prof. Kanchan K. Doke


Euler’s Theorem 58

 For every positive integer ‘a’ and ‘n’ which are said to be
relatively prime
 then aφ(n) ≡ 1 mod n.
 eg.1 Does Euler’s Theorem hold true for a=3 and n=10
 aφ(n) ≡ 1 mod n.
 3φ(10) ≡ 1 mod 10 .
 φ(10)= φ(2)* (5)=(1*4)=4 ….. (n)=(p-1)*(q-1) (i.e. (p) * (q))
 34 ≡ 1 mod 10
 81=1 mod 10
 Therefore , Euler’s Theorem hold true for a=3 and n=10
Prof. Kanchan K. Doke
Euler’s Theorem 59

 eg. 2 Does Euler’s Theorem hold true for a=2 and n=10
aφ(n) ≡ 1 mod n.
2φ(10) ≡ 1 mod 10 .
φ(10)= φ(2)* (5)=(1*4)=4 ….. (n)=(p-1)*(q-1) (i.e. (p) * (q))

 24 ≡ 1 mod 10
16=1 mod 10
Therefore , Euler’s Theorem does hold true for a=2 and
n=10
Prof. Kanchan K. Doke
Euler’s Theorem 60

 eg.3 Does Euler’s Theorem hold true for a=10 and


n=11
aφ(n) ≡ 1 mod n.
10φ(11) ≡ 1 mod 11 .
φ(11)= (11-1)=10 ….. If n is prime then φ (n)=n-1
1010 ≡ 1 mod 11
Therefore , Euler’s Theorem hold true for a=10 and
n=11
Prof. Kanchan K. Doke
Fermat’s Little Theorem 61

 Fermat's Little Theorem states that if p is a prime number and a is


an integer not divisible by p
 ap−1=1(mod p)
OR
 ap ≡ a (mod p).
 Eg. 1
 P = an integer Prime number a = an integer which is not multiple of P
 Let a = 2 and P = 5
 According to Fermat's little theorem
25-1 ≡ 1 mod(5)
24 ≡ 1 mod(5)  25 ≡ 2 mod(5)
OR  32= 2 mod(5)
16=1 mod(5)
Therefor Format’s theorem holds true for a = 2 and P = 5
Prof. Kanchan K. Doke
Fermat’s Little Theorem 62

 Eg. 2
P = an integer Prime number a = an integer which is not multiple
of P
 Let a = 2 and P = 6
 According to Fermat's little theorem
 ap−1=1(mod p)
 ap ≡ a (mod p).
 26-1 ≡ 1 mod(6)
OR  26 ≡ 2 mod(6)
 25 ≡ 1 mod(6)  64= 2 mod(6)
 32 = 1 mod(6)
 Therefor Format’s theorem does not holds true for a = 2 and P = 5

Prof. Kanchan K. Doke


Fermat’s Little Theorem 63

 Eg.
P = an integer Prime number a = an integer
which is not multiple of P
 Let a = 2 and P = 17
 According to Fermat's little theorem
 217-1 ≡ 1 mod(17)  ap ≡ a (mod p).
 216 ≡ 1 mod(17) OR  217 ≡ 2 mod(17)
 131072= 2 mod(17)
 65536= 1 mod (17)
 Therefor Format’s theorem holds true for a = 2 and P = 17

Prof. Kanchan K. Doke


The Chinese Remainder theorem 64

 Used to solve a set of different congruent equations with one


variable but different moduli which are relatively prime
 X=a1(mod m1)
X=a2(mod=m2)

X=an(mod mn)
 CRT said that above equations have unique solution of the
mouli are relatively prime

Prof. Kanchan K. Doke


The Chinese Remainder theorem 65

Prof. Kanchan K. Doke


The Chinese Remainder theorem 66

Prof. Kanchan K. Doke


The Chinese Remainder theorem 67

Prof. Kanchan K. Doke


The Chinese Remainder theorem 68

Prof. Kanchan K. Doke


The Chinese Remainder theorem 69

Prof. Kanchan K. Doke


The Chinese Remainder theorem 70

 Solve the system below using the Chinese remainder theorem:


x≡3(mod 5)
x≡5(mod 7)

 Ans: Given data,


 x≡3(mod 5) and x≡5(mod 7)
 By the Chinese Remainder Theorem, We have
N=5×7=35 N1=35/5=7 N2=35/7=5
 Now using relation,
 Nixi≡1(mod ni) => 7x1≡1(mod 5), ⇒ 2x1≡1(mod 5)
6x1≡3(mod 5) => x1=3
Prof. Kanchan K. Doke
The Chinese Remainder theorem 71

 Solve the system below using the Chinese remainder theorem:


x≡3(mod 5)
x≡5(mod 7)

Ans:
Similarly,
5x2≡1(mod 7)
15x2≡3(mod 7)
x2=3
Finally,
N=N1x1a1+N2x2a2
7×3×3+5×5×3=138
⇒138(mod 35)
⇒33(mod 35)
Prof. Kanchan K. Doke
72

Classical Encryption Technique


Terminologies in encryption 73
technique
 Plaintext - original message

 Ciphertext - coded message

 Cipher - algorithm for transforming plaintext to ciphertext

 Key - info used in cipher known only to sender/receiver

 Encipher (encrypt) - converting plaintext to ciphertext

 Decipher (decrypt) - recovering ciphertext from plaintext

 Cryptography – method of protecting information an communication through the use of code

 Cryptanalysis (codebreaking) – technique of deciphering ciphertext without knowing

encoding information

 Cryptology - field of both cryptography and cryptanalysis


Prof. Kanchan K. Doke
Terminologies in encryption 74
technique

Prof. Kanchan K. Doke


Cryptography 75

Prof. Kanchan K. Doke


Symmetric Cipher Model 76

 Components
 Plane text: original data fed as input to the algorithm
 Encryption algorithm: performs substitution and transformation on plaintext fed to it.
 E(x, k) = y
 Secrete key : It is a value/string/text file used by the encryption and decryption
algorithm to encode and decode the plain text to cipher text and vice-versa
respectively.
 Cipher Text : It is the formatted form of the plain text (x) which is unreadable for
humans, hence providing encryption during the transmission. It is completely
dependent upon the secret key provided to the encryption algorithm. Each unique
secret key produces a unique cipher text.
 Decryption Algorithm : It performs reversal of the encryption algorithm at the recipient’s
side. It also takes the secret key as input and decodes the cipher text received from the
sender based on the secret key. It produces plain text as output.
 D(y, k) = x

Prof. Kanchan K. Doke


Requirements for Encryption 77

 Encryption Algorithm:
 There is a need for a very strong encryption algorithm that
produces cipher texts in such a way that the attacker should be
unable to crack the secret key even if they have access to one or
more cipher texts.
 Secure way to share Secret Key:
 There must be a secure and robust way to share the secret key
between the sender and the receiver. It should be leak-proof so
that the attacker cannot access the secret key.

Prof. Kanchan K. Doke


Symmetric Cryptosystem Model 78

Y=E(K,X)

Prof. Kanchan K. Doke


Cryptanalysis 79

 Objectiveto recover key not just message


 General approaches:
 Cryptanalytic attack: finding the weakness of
cryptographic algorithm
 Brute-force attack: trying every possible key on
ciphertext to decrepit the message
 If either succeed all key use compromised
Prof. Kanchan K. Doke
Cryptanalytic Attacks 82

Prof. Kanchan K. Doke


Cryptanalytic Attacks 83

Prof. Kanchan K. Doke


Cryptanalytic Attacks 84

Prof. Kanchan K. Doke


Cryptanalytic Attacks 85

Prof. Kanchan K. Doke


Main Encryption Types 86

 Two main encryption types are


 Symmetric: the same key is used for both encryption and
decryption
 Asymmetric: different keys for encryption and decryption,
e.g. public-key
Encryption such as RSA.

Prof. Kanchan K. Doke


Symmetric Encryption 87

 One key is used for both encryption and decryption in symmetric encryption.
 The algorithm and key combine to encrypt the original sensitive information by
converting plaintext into ciphertext.
 Advantages
 Easier to use and implement
 Fast compared to asymmetric encryption
 Less resource utilization
 Disadvantages
 Sharing encryption keys safely is more
difficult
 Since it is unsuitable for different users, symmetric is not very scalable

Prof. Kanchan K. Doke


Asymmetric Cryptography 88
 A plain text is encrypted using two keys in asymmetric encryption
 The first of them is called a public key. It’s used to encrypt the message and it can be
publicly shared.
 The second one is the private key. Its job is to decrypt the data.
 Advantages
 There is no issue with key distribution since asymmetric
encryption uses two keys, one public and one private.
 Once again, communicating with several parties
is simple when using a pair of keys, which is how
it is more scalable in huge networks.
 Disadvantages
 Performance-wise, asymmetric encryption is
slower than symmetric encryption.
 Due to its large key sizes, asymmetric encryption
is not that simple to maintain and apply. Prof. Kanchan K. Doke
Main Encryption Types 89

 Two main encryption types are


 Symmetric: the same key is used for both encryption and
decryption
 Asymmetric: different keys for encryption and decryption,
e.g. public-key
Encryption such as RSA.
https://www.youtube.com/watch?v=E5FEqGYLL0o&list=PPSV

Prof. Kanchan K. Doke


Symmetric Vs Asymmetric Encryption 90
Key differences Symmetric encryption Asymmetric encryption
Smaller cipher text compares to original plain Larger cipher text compares to original
Size of cipher text
text file. plain text file.
Data size Used to transmit big data. Used to transmit small data.

Resource utilization Low usage of resources. High consumption of resources.

Key lengths 128 or 256-bit key size. RSA 2048-bit or higher key size.
Less secured due to use a single key for Much safer as two keys are involved in
Security
encryption. encryption and decryption.
Symmetric encryption uses a single key for Asymmetric encryption uses two keys
Number of keys
encryption and decryption. for encryption and decryption
Techniques It is an old technique. It is a modern encryption technique.
Two keys separately made for
A single key for encryption and decryption
Confidentiality encryption and decryption that
has chances of key compromised.
removes the need to share a key.
Asymmetric encryption is slower in
Speed Symmetric encryption is fast technique
terms of speed.
Algorithms RC4, AES, DES, 3DES, and QUAD. RSA, Diffie-Hellman, ECC algorithms.
Prof. Kanchan K. Doke
Cryptography 91

Classified along three independent


dimensions
The type of operations used The number of keys used The way in which the plaintext
for transforming plaintext to is processed
ciphertext • Sender and receiver uses
same key – symmetric • Block cipher – processes
• Substitution – each
• Sender and receiver input one block of elements
element in the plaintext is
each use a different key at a time
mapped into another
-asymmetric • Stream cipher – processes
element
the input elements
• Transposition – elements in
continuously
plaintext are rearranged
Prof. Kanchan K. Doke
Classical Encryption techniques 92

Classical
Encryption
techniques

Substitution Transposition
Ciphers Cipher

Prof. Kanchan K. Doke


93

Substitution Ciphers
Classical Substitution Ciphers 94

 Where letters of plaintext are replaced by other letters or by numbers or symbols


 If plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit
patterns with ciphertext bit patterns

A A
B B
C C
. .
. .
Y Y
Z Z

Prof. Kanchan K. Doke


Types of Substitution Ciphers 95

Substitution Ciphers

Monoalphabetic Polyalphabetic

Additive Multiplicative Affine Autokey Playfair Vigenere


Hill Cipher
Cipher Cipher Cipher Cipher Cipher Cipher

Prof. Kanchan K. Doke


Types of Substitution Ciphers 96

 The relationship between a symbol in the plaintext to a symbol in the ciphertext is


always one-to-one.

Substitution Ciphers

Monoalphabetic Polyalphabetic

Additive Multiplicative Affine Autokey Playfair Vigenere


Hill Cipher
Cipher Cipher Cipher Cipher Cipher Cipher

Prof. Kanchan K. Doke


Monoalphabetic Ciphers 97

 The relationship between a symbol in the plaintext to a symbol in


the ciphertext is always one-to-one.
 A character in the plain text is always changed to the same character in the
cipher text regardless of its position in the text.
 Eg1. The following shows a plaintext and its corresponding ciphertext. The cipher
is probably monoalphabetic because both l’s (els) are encrypted as O’s

 Planetext: hello Ciphertext: KHOOR

 The following shows a plaintext and its corresponding ciphertext.The cipher is not
monoalphabetic because each l’s(el) is encrypted by a different character.

 Planetext: hello Ciphertext: ABNZF


Prof. Kanchan K. Doke
Monoalphabetic Ciphers 98

 The relationship between a symbol in the plaintext to a symbol in


the ciphertext is always one-to-one.

Substitution Ciphers

Monoalphabetic Polyalphabetic

Additive Multiplicative Affine Autokey Playfair Vigenere


Hill Cipher
Cipher Cipher Cipher Cipher Cipher Cipher

Prof. Kanchan K. Doke


Additive Cipher / Caesar Cipher/ Shift Cipher 99

 The simplest monoalphabetic cipher


 Caesar cipher work by using modulo operator to encrypt & decrypt message
 Cipher has a key k, which is an integer from 0 to 25.
 In that encryption algo adds the key to the PT character
 The decryption algorithm subtracts the key from the CT character.

Prof. Kanchan K. Doke


Additive Cipher / Caesar Cipher/ Shift Cipher 100

 Eg. 1: Use the additive cipher with key = 15 to encrypt the message “HELLO”
 Solution
 Apply the encryption and decryption algorithm to the plaintext, character by character:

The formula of encryption is: E (C) = (P + K) mod 26 The formula of decryption is: D (P) = (C – K) mod 26
Plaintext: H → 07 E: (07 + 15) mod 26 Ciphertext: 22 → W Ciphertext: W → 22 D: (22 - 15) mod 26 Plaintext: 07 → H
Plaintext: E → 04 E: (04 + 15) mod 26 Ciphertext: 19 → T Ciphertext: T → 19 D: (19 - 15) mod 26 Plaintext: 04 → E
Plaintext: L → 11 E: (11 + 15) mod 26 Ciphertext: 00 → A Ciphertext: A → 00 Dn: (00 - 15) mod 26 Plaintext: 11 → L
Plaintext: L → 11 E: (11 + 15) mod 26 Ciphertext: 00 → A Ciphertext: A → 00 D: (00 - 15) mod 26 Plaintext: 11 → L
Plaintext: O → 14 E: (14 + 15) mod 26 Ciphertext: 03 → D Ciphertext: D → 03 D: (03 - 15) mod 26 Plaintext: 14 → O

The encrypted message of this plain text is "WTAAD". The decrypted message is "HELLO".

Prof. Kanchan K. Doke


Additive Cipher / Caesar Cipher/ Shift Cipher 101

 Eg. 2: Example: 1 Use the Caesar cipher to encrypt and decrypt the message
"JAVATPOINT," and the key (shift) value of this message is 3.
 Solution
The formula of encryption is: E (C) = (P + K) mod 26 The formula of decryption is:D (P) = (C – K) mod 26
Plaintext: J → 09 En: (09 + 3) mod 26 Ciphertext: 12 → M Ciphertext: M → 12 Dn: (12 - 3) mod 26 Plaintext: 09 → J
Plaintext: A → 00 En: (00 + 3) mod 26 Ciphertext: 3 → D Ciphertext: D → 03 Dn: (03 - 3) mod 26 Plaintext: 0 → A

Plaintext: V → 21 En: (21 + 3) mod 26 Ciphertext: 24 → Y Ciphertext: Y → 24 Dn: (24 - 3) mod 26 Plaintext: 21 → V
Plaintext: A → 00 En: (00 + 3) mod 26 Ciphertext: 3 → D Plaintext: A → 00 En: (00 + 3) mod 26 Ciphertext: 3 → D
Plaintext: T → 19 En: (19 + 3) mod 26 Ciphertext: 22 → W Plaintext: T → 19 En: (19 + 3) mod 26 Ciphertext: 22 → W
Plaintext: P → 15 En: (15 + 3) mod 26 Ciphertext: 18 → S Plaintext: P → 15 En: (15 + 3) mod 26 Ciphertext: 18 → S
Plaintext: O → 14 En: (14 + 3) mod 26 Ciphertext: 17 → R Plaintext: O → 14 En: (14 + 3) mod 26 Ciphertext: 17 → R
Plaintext: I → 08 En: (08 + 3) mod 26 Ciphertext: 11 → L Plaintext: I → 08 En: (08 + 3) mod 26 Ciphertext: 11 → L
Plaintext: N → 13 En: (13 + 3) mod 26 Ciphertext: 16 → Q Plaintext: N → 13 En: (13 + 3) mod 26 Ciphertext: 16 → Q
Plaintext: T → 19 En: (19 + 3) mod 26 Ciphertext: 22 → W Plaintext: T → 19 En: (19 + 3) mod 26 Ciphertext: 22 → W

The encrypted message of this plain text is The decrypted message is " JAVATPOINT ".
"MDYDWSRLQW". Prof. Kanchan K. Doke
Multiplicative Ciphers 102

 Each letter that is present in the plaintext is replaced by a corresponding letter of the
ciphertext, according to a fixed multiplication key.
 Use a large prime number as a multiplication key . i.e 1, 3, 5,7, 9, 11, 15, 17, 19, 21, 23, 25
 Encryption process :
 Multiplying the numerical value of each letter in the plaintext by the key and then taking the result
modulo the key.
 Decryption process :
 Multiplying the numerical value of each letter in the ciphertext by key inverse and then taking the
result modulo of the key

Prof. Kanchan K. Doke


Multiplicative Ciphers 103

 Find the multiplicative inverse of 7 in Z26.


 Solution The gcd (26, 7) is 1 t=t1-qt2
Initial value

q r1 r2 r t1 t2 t
3 26 7 5 0 1 -3
1 7 5 2 1 -3 4
2 5 2 1 -3 4 -11
2 2 1 0 4 -11 26
1 0 -11 26

 The multiplicative inverse of 7 = -11


 Convert it in positive form =>-11+26=15.
Prof. Kanchan K. Doke
Multiplicative Ciphers 104

 Find the multiplicative inverse of 11 in Z26.


 Solution The gcd (26, 11) is 1
Initial value

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
3 3 1 0 5 -7 26
1 0 -7 26

 The multiplicative inverse of 11 = -7


 Convert it in positive form => -7+26=19.
Prof. Kanchan K. Doke
Multiplicative Ciphers 105

 Eg. 1 use a multiplicative cipher to encrypt the message “hello” with key=7
 The formula of decryption is:D (P) = (C * K-1) mod 26
The formula of encryption is: E (C) = (P * K) mod 26  The multiplicative inverse of 7 =15.

Plaintext: H → 07 E: (07 *7) mod 26 Ciphertext: 23 → X Ciphertext: X → 23 D: (23*15) mod 26 Plaintext: 07 → H

Plaintext: E → 04 E: (04 *7) mod 26 Ciphertext: 2 →C Ciphertext: C→ 2 D: (2 *15) mod 26 Plaintext: 04 → E

Plaintext: L → 11 E: (11 *7) mod 26 Ciphertext: 25 → Z Ciphertext: Z → 25 Dn: (25 *15) mod 26 Plaintext: 11 → L

Plaintext: L → 11 E: (11 *7) mod 26 Ciphertext: 25 → Z Ciphertext: Z → 25 D: (25 *15) mod 26 Plaintext: 11 → L

Plaintext: O → 14 E: (14 *7) mod 26 Ciphertext: 20 → U Ciphertext: U → 20 D: (20 *15) mod 26 Plaintext: 14 → O

The encrypted message of this plain text is The decrypted message is "HELLO".
“XCZZU".

Prof. Kanchan K. Doke


Affine cipher 106

 We can combine additive & multiplicative ciphers to get what is called the affine cipher.
A combination of both ciphers with pair of keys.
 The first key is used with the multiplicative cipher the second key is used with the additive
cipher.
 Encryption C=(P×K1+K2) mod 26
 Decryption P=((C-K2)×K1-1)mod 26

Prof. Kanchan K. Doke


Affine cipher 107

 Eg. 1 use a Affine cipher to encrypt the message “hello” with key pair=(7,2) in modulus 26
 The formula of decryption is: P=((C-K2)×K1-1)mod 26

The formula of encryption is: C=(P×K1+K2) mod 26  The multiplicative inverse of 7 = 15.

Plaintext: H → 07 E: (07 *7+2) mod 26 Ciphertext: 25 → Z Ciphertext: 25 → Z D: ((23-2)*15) mod 26 Plaintext: 07 → H

Plaintext: E → 04 E: (04 *7+2) mod 26 Ciphertext: 4 → E Ciphertext: 4 → E D;((2 -2)*15) mod 26 Plaintext: 04 → E

Plaintext: L → 11 E: (11 *7+2) mod 26 Ciphertext: 1 → B Ciphertext: 1 → B D: ((25 -2)*15) mod 26 Plaintext: 11 → L

Plaintext: L → 11 E: (11 *7+2) mod 26 Ciphertext: 1 → B Ciphertext: 1 → B D: ((25 -2)*15) mod 26 Plaintext: 11 → L

Plaintext: O → 14 E: (14 *7+2) mod 26 Ciphertext: 22→ W Ciphertext: 22→ W D: ((20 -2)*15)mod 26 Plaintext: 14 → O

The encrypted message of this plain text is The decrypted message is "HELLO".
“ZEBBW".

Prof. Kanchan K. Doke


Polyalphabetic cipher 108

 In polyalphabetic substitution each occurrence of character may have different


substitute.
 The relation between a character in plain text to character in cipher text is one to many.
 Use stream of subkeys i.e. k = (k1, k2, k3, …)

Substitution Ciphers

Monoalphabetic Polyalphabetic

Additive Multiplicative Affine Autokey Playfair Vigenere


Hill Cipher
Cipher Cipher Cipher Cipher Cipher Cipher
Prof. Kanchan K. Doke
Autokey Cipher 109

 The key is a stream of subkeys


 The first subkey: a predetermined value secretly agreed upon by
parties.
 The second subkey: is the value of the first plaintext character
(between 0 and 25).
 The third subkey: the value of the second plaintext and so on.
𝑃 = {𝑝1, 𝑝2, 𝑝3, … , 𝑝𝑛}
 𝐾 = {𝑘1, 𝑝1, 𝑝2, 𝑝3, … , 𝑝𝑛−1}
 𝐶 = {𝑐1, 𝑐2, 𝑐3, … , 𝑐𝑛}

Encryption:
𝐶𝑖 = 𝑃𝑖 + 𝐾𝑖 𝑚𝑜𝑑 26
Decryption:
𝑃𝑖 = 𝐶𝑖 − 𝐾𝑖 𝑚𝑜𝑑 26
Prof. Kanchan K. Doke
Autokey Cipher 110
 The first subkey: a predetermined value secretly agreed upon by
parties.
 Eg. 𝑲=12; 𝑷=“attack is today”  The second subkey: is the value of the first plaintext character
(between 0 and 25).
 Encryption: 𝐶𝑖 = (𝑃𝑖 + 𝐾𝑖 ) 𝑚𝑜𝑑 26  The third subkey: the value of the second plaintext and so on.

Plaintext a t t a c k i s t o d a y
P Value 0 19 19 00 2 10 8 18 19 14 3 0 24
Key 12 00 19 19 00 2 10 8 18 19 14 3 0
C Value 12 19 12 19 02 12 18 0 11 7 17 3 24
Ciphertext m t m t c m s a l h r d y

 Decryption: 𝑃𝑖 = (𝐶𝑖 − 𝐾𝑖 ) 𝑚𝑜𝑑 26


Ciphertext m t m t c m s a l h r d y
C Value 12 19 12 19 02 12 18 0 11 7 17 3 24
Key 12 00 19 19 00 2 10 8 18 19 14 3 0
P Value 0 19 19 00 2 10 8 18 19 14 3 0 24
Plaintext a t t a c k i s t o d a y
Prof. Kanchan K. Doke
Playfair Cipher 111

 The Playfair Cipher was the first practical digraph substitution cipher.
 Manual Symmetric encryption technique
 Multiple letter encryption cipher
 The Playfair Cipher Encryption Algorithm:
 Generate the key Square(5×5)
 Grid of alphabets that acts as the key for encrypting the plaintext.
 Each of the 25 alphabets must be unique and if the plaintext contains J, then it is replaced by I. (as
the table can hold only 25 alphabets)

 Apply algorithm to encrypt the plain text:


 The plaintext is split into pairs of two letters (digraphs). If there is an odd number of letters, a Z is added
to the last letter.

Prof. Kanchan K. Doke


Playfair Cipher 113

 The Playfair Cipher Encryption Algorithm:


 Generate the key Square(5×5)
 Grid of alphabets that acts as the key for encrypting the plaintext.
 Each of the 25 alphabets must be unique and if the plaintext contains J, then it is replaced by I. (as
the table can hold only 25 alphabets)

Example 1: Keyword = MONARCHY Example 2: Keyword = PLAYFAIR

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

Prof. Kanchan K. Doke


Playfair Cipher 115

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 The plaintext is split into pairs of two letters (digraphs). If there is an odd number of
letters, a Z is added to the last letter.
 Example 1:
PlainText: "instruments"
After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz'
 Pair cannot be made with same letter. Break the letter in single and add a bogus
letter to the previous letter.
 Example 2:
Plain Text: “hello”
After Split: ‘he’ ‘lx’ ‘lo’
 If the letter is standing alone in the process of pairing, then add an extra bogus
letter with the alone letter
 Example 3:
Plain Text: “helloe”
After Split: ‘he’ ‘lx’ ‘lo’ ‘ez’
Prof. Kanchan K. Doke
Playfair Cipher 116

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Rectangle | |swap

 E.g.1 PlainText: “attack"


After Split: at ta ck M O N A R
C H Y B D
E F G I/J K
at ta ck
L P Q S T
RS
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 117

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Rectangle | |swap

 E.g.1 PlainText: “attack"


After Split: at ta ck M O N A R
C H Y B D
E F G I/J K
at ta ck
L P Q S T
RS SR
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 118

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Rectangle | |swap

 E.g.1 PlainText: “attack"


After Split: at ta ck M O N A R
C H Y B D
E F G I/J K
at ta ck
L P Q S T
RS SR DE
U V W X Z

Diagrams=RSSRDE

Prof. Kanchan K. Doke


Playfair Cipher 119

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Same row | | wrap around

 E.g.1 PlainText: “mosque"


After Split: mo sq ue M O N A R
C H Y B D
E F G I/J K
mo sq ue
L P Q S T
ON
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 120

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Same row | | wrap around

 E.g.1 PlainText: “mosque"


After Split: mo sq ue M O N A R
C H Y B D
E F G I/J K
mo sq ue
L P Q S T
ON
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 121

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Same row | | wrap around

 E.g.1 PlainText: “mosque"


After Split: mo sq ue M O N A R
C H Y B D
E F G I/J K
mo sq ue
L P Q S T
ON TS
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 122

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Same column | | wrap around

 E.g.1 PlainText: “mosque"


After Split: mo sq ue M O N A R
C H Y B D
E F G I/J K
mo sq ue
L P Q S T
ON TS
U V W X Z

Prof. Kanchan K. Doke


Playfair Cipher 123

 The Playfair Cipher Encryption Algorithm:


 Apply algorithm to encrypt the plain text: Rules for Encryption:
 Same column | | wrap around

 E.g.1 PlainText: “mosque"


After Split: mo sq ue M O N A R
C H Y B D
E F G I/J K
mo sq ue
L P Q S T
ON TS ML
U V W X Z

Diagrams=ONTSML

Prof. Kanchan K. Doke


Vigenère Cipher 124

 Simplest polyalphabetic substitution cipher


 Effectively multiple caesar ciphers
 Key is multiple letters long K = k1 k2 ... kd
 Encryption
 Ci = (Pi + Ki) mod 26
 Decryption
 Pi = (Ci - Ki) mod 26

Prof. Kanchan K. Doke


Vigenère Cipher 125

 Example: The plaintext is "JAVATPOINT", and the key is "BEST".


 Encryption: Ci = (Pi + Ki) mod 26

Plaintext J A V A T P O I N T
Plaintext value (P) 09 00 21 00 19 15 14 08 13 19
Key B E S T B E S T B E
Key value (K) 01 04 18 19 01 04 18 19 01 04
Ciphertext value (C) 10 04 13 19 20 19 06 01 14 23
Ciphertext K E N T U T G B O X

Ciphertext: KENTUTGBOX

Prof. Kanchan K. Doke


Vigenère Cipher 126

 Example: The plaintext is "JAVATPOINT", and the key is "BEST".


 Decription: Pi = (Ci - Ki) mod 26
 If any case (Di) value becomes negative (-ve), in this case, we will add 26 in the negative
value. Like, the third letter of the ciphertext;

Ciphertext K E N T U T G B O X
Ciphertext value (C) 10 04 13 19 20 19 06 01 14 23
Key B E S T B E S T B E
Key value (K) 01 04 18 19 01 04 18 19 01 04
Plaintext value (P) 09 00 21 00 19 15 14 08 13 19
Plaintext J A V A T P O I N T

Plaintext: JAVATPOINT

Prof. Kanchan K. Doke


Hill Cipher 128

 Multi letter cipher


 Encrypts a group of letters: diagraph, trigraph, polygraph
 Cipher key: The square matrix (randomly set of invertible n × n matrices (modulo 26)).
 In general terms, the hill system can be expressed as fallows
Encryption: E(P,K)=C = (P*K) mod 26 ...... K is our key matrix and P is the plaintext in vector form
Decryption: D(C,K)=P = (C*K-1 ) mod 26
K11 K12 K13
(C1,C2,C3)=(P1P2 P3) K21 K22 K23
mod 26 Encryption
K31 K32 K33

C1=(P1K11+P2K21+P3K31) mod 26
C2=(P1K12+P2K22+P3K32) mod 26
C3=(P1K13+P2K23+P3K33) mod 26 Prof. Kanchan K. Doke
Hill Cipher 129

 Multi letter cipher


 Encrypts a group of letters: diagraph, trigraph, polygraph
 Cipher key: The square matrix (randomly set of invertible n × n matrices (modulo 26)).
 In general terms, the hill system can be expressed as fallows
Encryption: E(K,P)=C = (K*P) mod 26 ...... K is our key matrix and P is the plaintext in vector form
Decryption: D(K,C)=P = (K-1 *C) mod 26
K11 K12 K13 P1
(C1,C2,C3)= K21 K22 K23 P2 mod 26 Encryption
P3
K31 K32 K33

C1=(K11P1+K12P2+K13P3) mod 26
C2=(K21P1+K22P2+K23P3) mod 26
C3=(K31P1+K32P2+P3K33) mod 26 Prof. Kanchan K. Doke
Hill Cipher 130
17 17 5
 Eg. Encrypt “pay more money” using Hill cipher with key 21 18 21
2 2 19
 E(P,K)=C = (P*K) mod 26

p a y m o r e m o n e y
15 0 24 12 14 17 4 12 14 13 4 24
 PT= pay mor emo ney
 pay
17 17 5
(C1,C2,C3)=(15 0 24) 21 18 21 mod 26
2 2 19

=(15*17+0*21+24*2 15*17+0*18+24*2 15*5+0*21+24*19) mod 26


=(303 303 531) mod 26
=(17 17 11)
=(R R L)
Prof. Kanchan K. Doke
Hill Cipher 131
17 17 5
 Eg. Encrypt “pay more money” using Hill cipher with key 21 18 21
2 2 19
 E(P,K)=C = (P*K) mod 26

p a y m o r e m o n e y
15 0 24 12 14 17 4 12 14 13 4 24
 PT= pay mor emo ney
 mor
17 17 5
(C1,C2,C3)=(12 14 17) 21 18 21 mod 26
2 2 19

=(12*17+14*21+17*2 12*17+14*18+17*2 12*5+14*21+17*19) mod 26


=(532 490 677) mod 26
=(12 22 1)
=(M W B)
Prof. Kanchan K. Doke
Hill Cipher 132
17 17 5
 Eg. Encrypt “pay more money” using Hill cipher with key 21 18 21
2 2 19
 E(P,K)=C = (P*K) mod 26

p a y m o r e m o n e y
15 0 24 12 14 17 4 12 14 13 4 24
 PT= pay mor emo ney
 emo
17 17 5
(C1,C2,C3)=(4 12 14) 21 18 21 mod 26
2 2 19

=(4*17+12*21+14*2 4*17+12*18+14*2 4*5+12*21+14*19) mod 26


=(348 312 538) mod 26
=(10 0 18)
=(K A S)
Prof. Kanchan K. Doke
Hill Cipher 133
17 17 5
 Eg. Encrypt “pay more money” using Hill cipher with key 21 18 21
2 2 19
 E(P,K)=C = (P*K) mod 26

p a y m o r e m o n e y
15 0 24 12 14 17 4 12 14 13 4 24
 PT= pay mor emo ney
 ney
17 17 5
(C1,C2,C3)=(13 4 24) 21 18 21 mod 26
2 2 19

=(13*17+4*21+24*2 13*17+4*18+24*2 13*5+4*21+24*19) mod 26


=(353 341 605) mod 26
=(15 3 7)
=(P D H)
Prof. Kanchan K. Doke
Hill Cipher 134
17 17 5
 Eg. Encrypt “pay more money” using Hill cipher with key 21 18 21
2 2 19
 E(P,K)=C = (P*K) mod 26

p a y m o r e m o n e y
15 0 24 12 14 17 4 12 14 13 4 24
 PT= pay mor emo ney
 ney
17 17 5
(C1,C2,C3)=(13 4 24) 21 18 21 mod 26
2 2 19

=(13*17+4*21+24*2 13*17+4*18+24*2 13*5+4*21+24*19) mod 26


=(353 341 605) mod 26
=(15 3 7)
PT p =(Pa D H)y m o r e m o n e y
CT R R L M W B K A S P D H Prof. Kanchan K. Doke
Hill Cipher 135

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

key matrix The key matrix


Now split the plaintext “short example” into digraphs

Convert the plaintext column vectors in to the number matrix.

Prof. Kanchan K. Doke


Hill Cipher 136

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


Prof. Kanchan K. Doke


Hill Cipher 137

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


Prof. Kanchan K. Doke


Hill Cipher 138

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


Prof. Kanchan K. Doke


Hill Cipher 139

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


Prof. Kanchan K. Doke


Hill Cipher 140

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


Prof. Kanchan K. Doke


Hill Cipher 141

 Eg. 2 Encrypt the plaintext message "short example" using the keyword hill

The key matrix plaintext column vectors


This gives us a final ciphertext


of "APADJ TFTWLFJ".

Prof. Kanchan K. Doke


142

Transposition Cipher
Transposition Ciphers 143

 Transposition cipher does not substitute one symbol with another


 The positions of letters/numbers/symbols in plain text is changed with one
another.
 The order of alphabets in the plaintext is rearranged to form a cipher text.

Transposition
Cipher

Keyed
Keyless Keyed Double Vernam
Columnar
Transposition Transposition Transposition Transposition
Transposition
Prof. Kanchan K. Doke
Keyless Transposition Ciphers 144

 Simple transposition ciphers, which were used in the past, are keyless.
 Methods:
1. Rail Fence Cipher : write the plaintext in a zig-zag pattern in two rows and form the
ciphertext by reading off the letters from the first row followed by the second.
 Algorithm:
 First write down plain text message as a sequence of diagonals.
 Read the plain text written in first step as a sequence of rows.

2. Simple Columnar Transposition: the message is written into the table rows of fixed
length and then read out column by column
 Algorithm:
 Write the plain text message row by row in a rectangle of predefinedsize.(length of key)
 Read the message column by column according t the selected orderthus obtained message is a
cipher text.
Prof. Kanchan K. Doke
Keyless Transposition Ciphers 145

 Simple transposition ciphers, which were used in the past, are keyless.
 Methods:
1. Rail Fence Cipher : write the plaintext in a zig-zag pattern in two rows and form the
ciphertext by reading off the letters from the first row followed by the second.
 Algorithm:
 First write down plain text message as a sequence of diagonals.
 Read the plain text written in first step as a sequence of rows.

 Eg. Plain text: come home tomorrow


c m h m t m r o
o e o e o o r w
 Cipher text: cmhmtmrooeoeoorw
Prof. Kanchan K. Doke
Keyless Transposition Ciphers 146

 Simple transposition ciphers, which were used in the past, are keyless.
 Methods:
2. Simple Columnar Transposition: the message is written into the table rows of fixed
length and then read out column by column
 Algorithm:
 Write the plain text message row by row in a rectangle of predefined size.(length of key)
 Read the message column by column according t the selected order thus obtained message is a
cipher text.

 Eg. plain text: hello world


h e l l
o w o r
l d

 Cipher text : holewdlolr


Prof. Kanchan K. Doke
Keyed Transposition Ciphers 147

 Divide the plaintext into groups of predetermined size, called blocks, and then use a key to permute
the characters in each block separately
 If in the grouping a block falls short of character then add ‘z’
 Eg. Plain text: “enemy attacks tonight” block size 5 and key is 31452
 enemy attac kston ightz

Encrypt 3 1 4 5 2
Decrypt
1 2 3 4 5

PT block e n e m y PT block a t t a c PT block i g h t z


CT e e m y n CT t a a c t CT h i t z g

 Cipher text: eemyntaacthitzg


Prof. Kanchan K. Doke
Keyed Columnar Transposition 148
cipher
 Combines keyless an keyed
transposition cipher
 Algorithm:
1. Text is written row by row into
the table
2. Permutation done by recording
the columns
3. New table is read column by
column
 Keyless:1st and 3rd step
 Keyed: 2nd step
Prof. Kanchan K. Doke
Double Transposition Ciphers 149
 Single columnar transposition can be attack by guessing possible column lengths.
 Therefore to make it stronger double transposition is used.
 This is simple columnar transposition technique applied twice.
 Here same key can be used for transposition or two different keys can be used.
 Algorithm:
 Arrange the plaintext into as many columns as per the letters in the first key
 Rearrange the columns based on the key.
 The letters of the key will be placed in alphabetical order and appropriate columns will be moved with
the key letters
 The ciphertext is now written out by writing the letters starting at the top left and going down each
column
 Use the ciphertext from the previous transposition for the plaintext in the second transposition with the
second key
 Place the key letters into alphabetical order and move the corresponding columns with each letter
 Write out the letters starting at the top left and going down each column to obtain the final ciphertext.
Prof. Kanchan K. Doke
Double Transposition Ciphers 150

Prof. Kanchan K. Doke


Double Transposition Ciphers 151

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 1. Arrange the plaintext into as many columns as there are letters in the first key
W I T C H
1 2 3 4 5
_______________________________________________

s h e t u
r n e d m
e i n t o
a n e w r
i g o t b
e t t e r
Prof. Kanchan K. Doke
Double Transposition Ciphers 152

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 2. Rearrange the columns based on the key. The letters of the key will be placed in
alphabetical order and appropriate columns will be moved with the key letters

W I T C H C H I T W
1 2 3 4 5 4 5 2 3 1
_______________________________________________ ___________________________________________
s h e t u t u h e s
r n e d m d m n e r
e i n t o t o i n e
a n e w r w r n e a
i g o t b t b g o i
e t t e r e r t t e

Prof. Kanchan K. Doke


Double Transposition Ciphers 153

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 3. The ciphertext is now written out by writing the letters starting at the top left and going
down each column
 Ciphertext after first transposition: tdtwteumorbrhningteeneotsreaie

C H I T W
4 5 2 3 1
___________________________________________
t u h e s
d m n e r
t o i n e
w r n e a
t b g o i
e r t t e
Prof. Kanchan K. Doke
Double Transposition Ciphers 154

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 4. Use the ciphertext from the previous transposition for the plaintext in the second
transposition with the second key (ciphertext : tdtwteumorbrhningteeneotsreaie)

C H I T W F L O A T
4 5 2 3 1 1 2 3 4 5
___________________________________________ ________________________________________________
t u h e s t d t w t
d m n e r e u m o r
t o i n e b r h n i
w r n e a n g t e e
t b g o i n e o t s
e r t t e
r e a i e Prof. Kanchan K. Doke
Double Transposition Ciphers 155

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 5. Place the key letters into alphabetical order and move the corresponding columns with
each letter

F L O A T A F L O T
1 2 3 4 5 4 1 2 3 5
________________________________________________
___________________________
t d t w t w t d t t
e u m o r o e u m r
b r h n i n b r h i
n g t e e e n g t e
n e o t s t n e o s
r e a i e i r e a e Prof. Kanchan K. Doke
Double Transposition Ciphers 156

 Eg. Plaintext: she turned me into a newr I got better


Keys: Witch, Float
 Step 5. Place the key letters into alphabetical order and move the corresponding columns with each letter
A F L O T
4 1 2 3 5
___________________________
w t d t t
o e u m r
n b r h i
e n g t e
t n e o s
i r e a e
 Step 6. write out the letters starting at the top left and going down each column to obtain the final ciphertext.
 Final Ciphertext: WONETITEBNNRDURGEETMHTOATRIESE
Prof. Kanchan K. Doke
158

Block and stream cipher


1. STREAM CIPHERS
2. BLOCK CIPHERS
Stream Ciphers 159

 Call the plaintext stream P, the ciphertext stream C, and the key stream K.

Prof. Kanchan K. Doke


Block Ciphers 162

 In a block cipher, a group of plaintext symbols of size m (m > 1) are encrypted together creating a
group of ciphertext of the same size. A single key is used to encrypt the whole block even if the key is
made of multiple values.

 Eg.
 Playfair ciphers are block ciphers. The size of the block is m = 2. Two characters are encrypted together.
 From the definition of the block cipher, it is clear that every block cipher is a polyalphabetic cipher because
each character in a ciphertext block depends on all characters in the plaintext block. Prof. Kanchan K. Doke

You might also like