Cryptography and Cyber Security
[IT311]
Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423603
(An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune)
NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Information Technology
(NBAAccredited)
Mrs. Kanchan D. Patil
Assistant Professor
Unit 1: Security Fundamentals
• Introduction, Threats and Attacks, Security Services, Security
Mechanisms, Cipher Techniques: Substitution and Transposition, One
Time Pad, Block Ciphers, Stream Ciphers.
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Symmetric Cipher Model : Basics
• Symmetric encryption (Conventional encryption/ Single-key encryption)
was the only type of encryption in use prior to the development of
public-key encryption in the 1970s.
• Plaintext: An original message is known as the plaintext
• Ciphertext: coded message is called the ciphertext
• Encryption: The process of converting from plaintext to ciphertext is
known as enciphering or encryption
• Decryption: restoring the plaintext from the ciphertext is deciphering or
decryption
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Symmetric Cipher Model : Basics
• Cryptography: The schemes used for encryption constitute the area of
study known as cryptography and a scheme is known as a cryptographic
system or a cipher
• Cryptanalysis: Techniques used for deciphering a message without any
knowledge of the enciphering details fall into the area of cryptanalysis
• Cryptanalysis is what the layperson calls "breaking the code."
• Cryptology: The areas of cryptography and cryptanalysis together are
called cryptology
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Symmetric Cipher Model : Components
• Plaintext: This is the original intelligible message or data that is fed into
the algorithm as input
• Encryption algorithm: The encryption algorithm performs various
substitutions and transformations on the plaintext
• Secret key: The secret key is also input to the encryption algorithm
• The key is a value independent of the plaintext and of the algorithm.
• The algorithm will produce a different output depending on the
specific key being used at the time
• The exact substitutions and transformations performed by the
algorithm depend on the key
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Symmetric Cipher Model : Components
• Ciphertext: This is the scrambled message produced as output
• It depends on the plaintext and the secret key
• For a given message, two different keys will produce two different
ciphertexts
• The ciphertext is an apparently random stream of data and, as it
stands, is unintelligible
• Decryption algorithm:
• This is essentially the encryption algorithm run in reverse
• It takes the ciphertext and the secret key and produces the original
plaintext
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Simplified Model of Conventional Encryption
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Simplified Model of Conventional Encryption
• There are two requirements for secure use of conventional encryption
• A strong encryption algorithm
• Algorithm must be in such a way that even if an opponent who
knows the algorithm and has access to one or more ciphertexts
would be unable to decipher the ciphertext or figure out the key
• A secret key known only to sender / receiver
• Sender and receiver must have obtained copies of the secret key
in a secure fashion and must keep the key secure
• we do not need to keep the algorithm secret; we need to keep only the
key secret
• If someone can discover the key and knows the algorithm, all
communication using this key is readable.
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Model of Conventional Cryptosystem
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Model of Conventional Cryptosystem
• Essential elements of a symmetric encryption scheme
• A source produces a message in plaintext, X = [X1, X2, ..., XM]
• The M elements of X are letters in some finite alphabet
• Traditionally, the alphabet usually consisted of the 26 capital letters
• The binary alphabet {0, 1} can also be used
• For encryption, a key of the form K = [K1, K2, ..., KJ] is generated
• If the key is generated at the message source, then it must also be
provided to the destination by means of some secure channel.
Alternatively, a third party could generate the key and securely
deliver it to both source and destination
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Model of Conventional Cryptosystem
• With the message X and the encryption key K as input, the encryption
algorithm forms the ciphertext Y = [Y1, Y2, ..., YN]
• We can write this as Y = E(K, X)
• This notation indicates that Y is produced by using encryption
algorithm E as a function of the plaintext X, with the specific function
determined by the value of the key K
• The intended receiver, in possession of the key, is able to invert the
transformation: X = D(K, Y)
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Dimensions of Cryptosystem
• Cryptographic systems are characterized along three independent
dimensions
1. The type of operations used for transforming plaintext to ciphertext
• All encryption algorithms are based on two general principles
• Substitution: In which each element in the plaintext (bit, letter, group of
bits or letters) is mapped into another element
• Transposition: In which elements in the plaintext are rearranged
• The fundamental requirement is that no information be lost (that is, that
all operations are reversible)
• Most systems, referred to as product systems, involve multiple stages of
substitutions and transpositions
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Dimensions of Cryptosystem
• Cryptographic systems are characterized along three independent
dimensions
2. The number of keys used
• If both sender and receiver use the same key, the system is referred to
as symmetric, single-key, secret-key, or conventional encryption
• If the sender and receiver use different keys, the system is referred to as
asymmetric, two-key, or public-key encryption
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Cryptanalysis
• The objective of attacking an encryption system is to recover the key in
use rather then simply to recover the plaintext of a single ciphertext
• There are two general approaches to attacking a conventional
encryption scheme
• Cryptanalytic Attack:
• It rely on the nature of the algorithm plus some knowledge of the
general characteristics of the plaintext or even some sample
plaintextciphertext pairs
• This type of attack exploits the characteristics of the algorithm to
attempt to deduce a specific plaintext or to deduce the key being
used
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Cryptanalytic Attack
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Type of Attack Known to Cryptanalyst
Ciphertext only Encryption algorithm, Ciphertext
Known plaintext Encryption algorithm
Ciphertext
One or more plaintext-ciphertext pairs formed with the secret key
Chosen plaintext Encryption algorithm
Ciphertext
Plaintext message chosen by cryptanalyst, together with its corresponding ciphertext
generated with the secret key
Chosen ciphertext Encryption algorithm
Ciphertext
Purported ciphertext chosen by cryptanalyst, together with its corresponding decrypted
plaintext generated with the secret key
Chosen text Encryption algorithm
Ciphertext
Plaintext message chosen by cryptanalyst, together with its corresponding ciphertext
generated with the secret key Purported ciphertext chosen by cryptanalyst, together with its
corresponding decrypted plaintext generated with the secret key
Cryptanalysis
• The objective of attacking an encryption system is to recover the key in
use rather then simply to recover the plaintext of a single ciphertext
• Brute-force attack:
• The attacker tries every possible key on a piece of ciphertext until an
intelligible translation into plaintext is obtained
• On average, half of all possible keys must be tried to achieve success
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Average Time Required for Exhaustive Key
Search
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Substitution Techniques
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• A substitution technique is one in which the letters of plaintext are
replaced by other letters or by numbers or symbols
• If the plaintext is viewed as a sequence of bits, then substitution
involves replacing plaintext bit patterns with ciphertext bit patterns
• Caesar Cipher
• Monoalphabetic Cipher
• Playfair Cipher
• Hill Cipher
• Polyalphabetic Cipher
• One-Time pad
Substitution Techniques : Caesar Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• It is the earliest substitution cipher and the simplest one
• It was invented by Julius Caesar
• The Caesar cipher involves replacing each letter of the alphabet with the
letter standing three places further down the alphabet
• For example:
• plain: meet me after the toga party
• cipher: PHHW PH DIWHU WKH WRJD SDUWB
• The alphabet is wrapped around, so that the letter following Z is A
• 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: 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
Substitution Techniques : Caesar Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• We can assign value to each letter
Substitution Techniques : Caesar Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Algorithm can be expressed as follows:
• For each plaintext letter p, substitute the ciphertext letter C
C = E(3, p) = (p + 3) mod 26
• A shift may be of any amount, so that the general Caesar algorithm is
C = E(k, p) = (p + k) mod 26
where k takes on a value in the range 1 to 25
• The decryption algorithm is simply
p = D(k, C) = (C k) mod 26
Substitution Techniques : Caesar Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Disadvantage:
• If it is known that a given ciphertext is a Caesar cipher, then a brute-
force cryptanalysis is easily performed. Simply try all the 25 possible
keys
• The encryption and decryption algorithms are known
• There are only 25 keys to try
• The language of the plaintext is known and easily recognizable
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• In Caesar cipher, we are shifting the alphabets, rather than just shifting
the alphabet we could shuffle (jumble) the letters arbitrarily
• Each plaintext letter maps to a different random ciphertext letter
• Key is 26 letters long
• A permutation of a finite set of elements is an ordered sequence of all
the elements of, with each element appearing exactly once.
• For example, if S= {a,b,c} there are six permutations of S:
abc, acb, bac, bca, cab, cba
• In general, there are n! permutations of a set of n elements, because
the first element can be chosen in one of n ways, the second in n-1
ways, the third in n-3 ways, and so on
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• A single cipher alphabet (mapping from plain alphabet to cipher
alphabet) is used per message so it is referred as monoalphabetic
substitution cipher.
• Disadvantage: Even given the very large number of keys, being 10
orders of magnitude greater than the key space for DES, the
monoalphabetic substitution cipher is not secure, because it does not
clearly express the underlying language characteristics.
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• 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
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• count relative letter frequencies
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• 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 Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Disadvantage:
• If cipher text is short then its easy to crack.
• They are easy to break because they reflect the frequency data of the
original alphabet.
Substitution Techniques:Monoalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Solution:
• Homophonic Substitution Cipher
• A countermeasure is to provide multiple substitutes, known as
homophones, for a single letter.
• For example, the letter e could be assigned a number of different cipher
symbols, such as 16, 74, 35, and 21, with each homophone assigned to a
letter in rotation or randomly
• If the number of symbols assigned to each letter is proportional to the
relative frequency of that letter, then single-letter frequency information is
completely obliterated.
Substitution Techniques:Polygram Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Rather than replacing one plain text alphabet with ane cipher text alphabet
at a time, a block of alphabets is replaced with another block of alphabet
• Example:
• HELLO replaced by YUQQW but
• HELL replaced by TEUI
Substitution Techniques: Playfair Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• invented by Charles Wheatstone in 1854, but named after his friend Baron
Play-fair
• The best-known multiple-letter encryption cipher is the Play-fair, which
treats diagrams in the plaintext as single units and translates these units
into cipher text diagrams
• The Play-fair algorithm is based on the use of a 5 × 5 matrix of letters
constructed using a keyword.
• Example: solved by Lord Peter Wimsey in Dorothy Sayers’s Have His
Carcase
Substitution Techniques: Playfair Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• The keyword is monarchy.
• The matrix is constructed by filling in the letters of the keyword (minus
duplicates) from left to right and from top to bottom, and then filling in
the remainder of the matrix with the remaining letters in alphabetic
order.
• The letters I and J count as one letter.
• Plaintext is encrypted two letters at a time, according to the following
rules:
Substitution Techniques: Playfair Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Repeating plaintext letters that are in the same pair are separated with a
filler letter, such as x, so that balloon would be treated as ba lx ox on.
• Two plaintext letters that fall in the same row of the matrix are each
replaced by the letter to the right, with the first element of the row
circularly following the last. For example, ar is encrypted as RM.
• Two plaintext letters that fall in the same column are each replaced by the
letter below it, with the top element of the column circularly following the
last. For example, mu is encrypted as CM.
• Otherwise, each plaintext letter in a pair is replaced by the letter that lies in
its own row and the column occupied by the other plaintext letter. Thus, hs
becomes BP and ea becomes IM (or JM, as the encipherer wishes).
Substitution Techniques: Playfair Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Advantage:
• The Playfair cipher is a great advance over simple monoalphabetic
ciphers.
• There are only 26 letters, there are 26 × 26 = 676 digrams, that
identification of individual digrams is more difficult.
• Widely used for many years eg. by US & British military in WW1
• Disadvantage:
• it can be broken, given a few hundred letters since still has much of
plaintext structure
Substitution Techniques: Poly-alphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• improve security using multiple cipher alphabets
• make 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 general name for this approach is a poly-alphabetic substitution
cipher. following features are used:
• A set of related mono-alphabetic substitution rules is used.
• A key determines which particular rule is chosen for a given
transformation.
Substitution Techniques: Polyalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vigenère Cipher:
• simplest polyalphabetic substitution cipher
• set of related mono-alphabetic substitution rules consists of the 26
Caesar ciphers, with shifts of 0 through 25.
• Each cipher is denoted by a key letter, which is the cipher text letter that
substitutes for the plaintext letter ‘a’, and which are each used in turn
• key is multiple letters long K = k1 k2 ... kd
• ith letter specifies ith alphabet to use
• repeat from start after d letters in message
• decryption simply works in reverse
Substitution Techniques: Polyalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vigenère Cipher:
• write the plaintext out
• write the keyword repeated above it
• use each key letter as a Caesar cipher key
• encrypt the corresponding plaintext letter
Substitution Techniques: Polyalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vigenère Cipher: example using keyword deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Substitution Techniques: Polyalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vigenère Cipher: Security
• have multiple cipher text letters for each plaintext letter
• hence letter frequencies are obscured (difficult to understand) but not
totally lost
• start with letter frequencies
• see if look mono alphabetic or not
• if not, then need to determine number of alphabets, since then can
attach each
Substitution Techniques: Polyalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Disadvantage:
• The Vigenère & related polyalphabetic ciphers still do not completely
understand the underlying language characteristics.
• The key to breaking them was to identify the number of translation
alphabets, and then attack each separately.
• The key and the plain text share the same frequency distribution of
letters, a statistical technique can be applied.
Substitution Techniques: Polyaalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vernam Cipher:
• In Vigenère Cipher, The key and the plain text share the same frequency
distribution of letters, a statistical technique can be applied.
• Solution is to choose a keyword that is as long as the plaintext and has
no statistical relationship to it.
• A system was introduced by an AT&T engineer named Gilbert Vernam in
1918.
• His system works on binary data (bits) rather than letters.
• The system can be expressed as follows:
ci = pi X-OR ki
Substitution Techniques: Polyaalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vernam Cipher:
• The system can be expressed as
follows:
ci = pi X-OR ki
where,
Pi = ith binary digit of plaintext
Ki = ith binary digit of key
Ci = ith binary digit of ciphertext
Substitution Techniques: Polyaalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vernam Cipher:
• Thus, the ciphertext is generated by performing the bitwise X-OR of the
plaintext and the key.
• Because of the properties of the X-OR, decryption simply involves the
same bitwise operation:
pi = ci X-OR ki
Substitution Techniques: Polyaalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vernam Cipher:
• Plain-Text: O A K
• Key: S O N
O ==> 14 = 0 1 1 1 0
S ==> 18 = 1 0 0 1 0
Bitwise XOR Result: 1 1 1 0 0 = 28
• Since the resulting number is greater than 26, subtract 26 from it.
• Then convert the Cipher-Text character number to the Cipher-Text
character.
28 - 26 = 2 ==> C
CIPHER-TEXT: C
Substitution Techniques: Polyaalphabetic Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Vernam Cipher:
• The essence of this technique is the means of construction of the key.
• Vernam proposed the use of a running loop of tape that eventually
repeated the key, so that in fact the system worked with a very long but
repeating keyword.
• Although such a scheme, with a long key, presents formidable
cryptanalytic difficulties, it can be broken with sufficient ciphertext,
the use of known or probable plaintext sequences, or both.
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• An Army Signal Corp officer, Joseph Mauborgne, proposed an
improvement to the Vernam cipher that yields the ultimate in security
• Mauborgne suggested using a random key that is as long as the
message, so that the key need not be repeated.
• The key is to be used to encrypt and decrypt a single message, and then
is discarded.
• Each new message requires a new key of the same length as the new
message.
• Such a scheme, known as a one-time pad, is unbreakable.
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• It produces random output that bears no statistical relationship to the
plaintext. Because the cipher text contains no information whatsoever
about the plaintext, there is simply no way to break the code.
• Example: Two different decryptions using two different keys
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Input: Message = HELLO, Key = MONEY
• Output: Cipher – TSYPM, Message – HELLO
• Explanation:
• Part 1: Plain text to Ciphertext
• Plain text: H E L L O -> 7 4 11 11 14
• Key: M O N E Y -> 12 14 13 4 24
• Plain text + key: 19 18 24 15 38 -> 19 18 24 15 12 (= 38 – 26)
• Cipher Text: T S Y P M
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Part 2: Ciphertext to Message
•
• Cipher Text:T S Y P M -> 19 18 24 15 12
• Key: M O N E Y -> 12 14 13 4 24
• Cipher text – key -> 7 4 11 11 -12 -> 7 4 11 11 14
• Message: H E L L O
• Input:
• Message = SAVE,
• Key = LIFE
• Output: Cipher – DIAI
• Message – SAVE
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Security:
• The security of the one-time pad is entirely due to the randomness of
the key.
• If the stream of characters that constitute the key is truly random, then
the stream of characters that constitute the ciphertext will be truly
random. Thus, there are no patterns or regularities that a cryptanalyst
can use to attack the ciphertext.
• Advantages:
• Primarily used for low-bandwidth channels requiring very high security.
• The one-time pad is the only cryptosystem that exhibits what is referred
to as perfect secrecy.
Substitution Techniques: One Time Pad
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Difficulties:
• There is the practical problem of making large quantities of random
keys. Any heavily used system might require millions of random
characters on a regular basis. Supplying truly random characters in this
volume is a significant task.
• Even more daunting is the problem of key distribution and protection.
For every message to be sent, a key of equal length is needed by both
sender and receiver. Thus, a mammoth key distribution problem exists.
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Another interesting multi-letter cipher (polygraphic) is the Hill cipher,
developed by the mathematician Lester Hill in 1929.
• Uses the concept of Linear Algebra
• We define the inverse 𝑀−1 of a square matrix M by the equation,
𝑀 𝑀−1
= 𝑀−1
𝑀 = 𝐼
where I is the identity matrix.
• I is a square matrix that is all zeros except for ones along the main diagonal
from upper left to lower right.
• The inverse of a matrix does not always exist, but when it does, it satisfies
the preceding equation.
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• To encrypt a message, each block of n letters (considered as an n-
component vector) is multiplied by an invertible n × n matrix, against
modulus 26.
• To decrypt the message, each block is multiplied by the inverse of the
matrix used for encryption.
• The matrix used for encryption is the cipher key, and it should be chosen
randomly from the set of invertible n × n matrices (modulo 26).
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Example:
• Input :
• Plaintext: ACT
• Key: GYBNQKURP
• Output : Ciphertext: POH
• We have to encrypt the message ‘ACT’ (n=3).
• The key is ‘GYBNQKURP’ which can be written as the N X N
• matrix: Matrix is framed from the given key
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• The message message ‘ACT’ (n=3) is written as:
• The enciphered vector is given as:
• Output: ciphertext POH
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• To decrypt the message, we turn the ciphertext back into a vector, then
simply multiply by the inverse matrix of the key matrix (IFKVIVVMI in
letters).The inverse of the matrix is:
• For the Cipher-text POH
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Example:
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• To explain how the inverse of a matrix is computed, we begin by with
the concept of determinant.
• For any square matrix (m × m), the determinant equals the sum of all
the products that can be formed by taking exactly one element from
each row and exactly one element from each column, with certain of
the product terms preceded by a minus sign
• For a 2 × 2 matrix,
The determinant is K11K22- K12K21
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• If a square matrix A has a nonzero determinant, then the inverse of the
matrix is computed as
• Where, Dji is the sub-determinant formed by deleting the jth row and
the ith column of A
• det(A) is the determinant of A and (det A)^-1 is the multiplicative
inverse of (det A) mod 26
• So, for our example
• We can show that 9^-1 mod 26 = 1, because 9*3=27 mod 26 = 1
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Hill Algorithm:
• This encryption algorithm takes m successive plaintext letters and
substitutes for them m ciphertext letters.
• The substitution is determined by m linear equations in which each
character is assigned a numerical value (a = 0, b = 1, ……, z = 25)
• For m = 3, system can be described as
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Hill Algorithm:
• This can be expressed in terms of row vectors and matrices:
• where C and P are row vectors of length 3 representing the plaintext
and ciphertext, and K is a matrix representing the encryption key.
Operations are performed mod 26
Substitution Techniques: Hill Cipher
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• Example:
• Lets consider a plaintext “paymoremoney” and consider key, K
• The first three letters of the plaintext are represented by the vector
(15 0 24).
• Then (15 0 24)K = (303 303 531) mod 26 = (17 17 11) = RRL
• Continuing in this fashion, the ciphertext for the entire plaintext is
RRLMWBKASPDH
• Decryption requires inverse of matrix K
References:
Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
• William Stallings, “Cryptography and Network Security-Principles and
practice”

Unit 1_Classical Encryption Techniques.pdf

  • 1.
    Cryptography and CyberSecurity [IT311] Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423603 (An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune) NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Information Technology (NBAAccredited) Mrs. Kanchan D. Patil Assistant Professor
  • 2.
    Unit 1: SecurityFundamentals • Introduction, Threats and Attacks, Security Services, Security Mechanisms, Cipher Techniques: Substitution and Transposition, One Time Pad, Block Ciphers, Stream Ciphers. Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 3.
    Symmetric Cipher Model: Basics • Symmetric encryption (Conventional encryption/ Single-key encryption) was the only type of encryption in use prior to the development of public-key encryption in the 1970s. • Plaintext: An original message is known as the plaintext • Ciphertext: coded message is called the ciphertext • Encryption: The process of converting from plaintext to ciphertext is known as enciphering or encryption • Decryption: restoring the plaintext from the ciphertext is deciphering or decryption Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 4.
    Symmetric Cipher Model: Basics • Cryptography: The schemes used for encryption constitute the area of study known as cryptography and a scheme is known as a cryptographic system or a cipher • Cryptanalysis: Techniques used for deciphering a message without any knowledge of the enciphering details fall into the area of cryptanalysis • Cryptanalysis is what the layperson calls "breaking the code." • Cryptology: The areas of cryptography and cryptanalysis together are called cryptology Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 5.
    Symmetric Cipher Model: Components • Plaintext: This is the original intelligible message or data that is fed into the algorithm as input • Encryption algorithm: The encryption algorithm performs various substitutions and transformations on the plaintext • Secret key: The secret key is also input to the encryption algorithm • The key is a value independent of the plaintext and of the algorithm. • The algorithm will produce a different output depending on the specific key being used at the time • The exact substitutions and transformations performed by the algorithm depend on the key Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 6.
    Symmetric Cipher Model: Components • Ciphertext: This is the scrambled message produced as output • It depends on the plaintext and the secret key • For a given message, two different keys will produce two different ciphertexts • The ciphertext is an apparently random stream of data and, as it stands, is unintelligible • Decryption algorithm: • This is essentially the encryption algorithm run in reverse • It takes the ciphertext and the secret key and produces the original plaintext Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 7.
    Simplified Model ofConventional Encryption Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 8.
    Simplified Model ofConventional Encryption • There are two requirements for secure use of conventional encryption • A strong encryption algorithm • Algorithm must be in such a way that even if an opponent who knows the algorithm and has access to one or more ciphertexts would be unable to decipher the ciphertext or figure out the key • A secret key known only to sender / receiver • Sender and receiver must have obtained copies of the secret key in a secure fashion and must keep the key secure • we do not need to keep the algorithm secret; we need to keep only the key secret • If someone can discover the key and knows the algorithm, all communication using this key is readable. Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 9.
    Model of ConventionalCryptosystem Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 10.
    Model of ConventionalCryptosystem • Essential elements of a symmetric encryption scheme • A source produces a message in plaintext, X = [X1, X2, ..., XM] • The M elements of X are letters in some finite alphabet • Traditionally, the alphabet usually consisted of the 26 capital letters • The binary alphabet {0, 1} can also be used • For encryption, a key of the form K = [K1, K2, ..., KJ] is generated • If the key is generated at the message source, then it must also be provided to the destination by means of some secure channel. Alternatively, a third party could generate the key and securely deliver it to both source and destination Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 11.
    Model of ConventionalCryptosystem • With the message X and the encryption key K as input, the encryption algorithm forms the ciphertext Y = [Y1, Y2, ..., YN] • We can write this as Y = E(K, X) • This notation indicates that Y is produced by using encryption algorithm E as a function of the plaintext X, with the specific function determined by the value of the key K • The intended receiver, in possession of the key, is able to invert the transformation: X = D(K, Y) Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 12.
    Dimensions of Cryptosystem •Cryptographic systems are characterized along three independent dimensions 1. The type of operations used for transforming plaintext to ciphertext • All encryption algorithms are based on two general principles • Substitution: In which each element in the plaintext (bit, letter, group of bits or letters) is mapped into another element • Transposition: In which elements in the plaintext are rearranged • The fundamental requirement is that no information be lost (that is, that all operations are reversible) • Most systems, referred to as product systems, involve multiple stages of substitutions and transpositions Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 13.
    Dimensions of Cryptosystem •Cryptographic systems are characterized along three independent dimensions 2. The number of keys used • If both sender and receiver use the same key, the system is referred to as symmetric, single-key, secret-key, or conventional encryption • If the sender and receiver use different keys, the system is referred to as asymmetric, two-key, or public-key encryption Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 14.
    Cryptanalysis • The objectiveof attacking an encryption system is to recover the key in use rather then simply to recover the plaintext of a single ciphertext • There are two general approaches to attacking a conventional encryption scheme • Cryptanalytic Attack: • It rely on the nature of the algorithm plus some knowledge of the general characteristics of the plaintext or even some sample plaintextciphertext pairs • This type of attack exploits the characteristics of the algorithm to attempt to deduce a specific plaintext or to deduce the key being used Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 15.
    Cryptanalytic Attack Cryptography &Cyber Security Mrs. Kanchan Patil Department of Information Technology Type of Attack Known to Cryptanalyst Ciphertext only Encryption algorithm, Ciphertext Known plaintext Encryption algorithm Ciphertext One or more plaintext-ciphertext pairs formed with the secret key Chosen plaintext Encryption algorithm Ciphertext Plaintext message chosen by cryptanalyst, together with its corresponding ciphertext generated with the secret key Chosen ciphertext Encryption algorithm Ciphertext Purported ciphertext chosen by cryptanalyst, together with its corresponding decrypted plaintext generated with the secret key Chosen text Encryption algorithm Ciphertext Plaintext message chosen by cryptanalyst, together with its corresponding ciphertext generated with the secret key Purported ciphertext chosen by cryptanalyst, together with its corresponding decrypted plaintext generated with the secret key
  • 16.
    Cryptanalysis • The objectiveof attacking an encryption system is to recover the key in use rather then simply to recover the plaintext of a single ciphertext • Brute-force attack: • The attacker tries every possible key on a piece of ciphertext until an intelligible translation into plaintext is obtained • On average, half of all possible keys must be tried to achieve success Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 17.
    Average Time Requiredfor Exhaustive Key Search Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 18.
    Substitution Techniques Cryptography &Cyber Security Mrs. Kanchan Patil Department of Information Technology • A substitution technique is one in which the letters of plaintext are replaced by other letters or by numbers or symbols • If the plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with ciphertext bit patterns • Caesar Cipher • Monoalphabetic Cipher • Playfair Cipher • Hill Cipher • Polyalphabetic Cipher • One-Time pad
  • 19.
    Substitution Techniques :Caesar Cipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • It is the earliest substitution cipher and the simplest one • It was invented by Julius Caesar • The Caesar cipher involves replacing each letter of the alphabet with the letter standing three places further down the alphabet • For example: • plain: meet me after the toga party • cipher: PHHW PH DIWHU WKH WRJD SDUWB • The alphabet is wrapped around, so that the letter following Z is A • 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: 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
  • 20.
    Substitution Techniques :Caesar Cipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • We can assign value to each letter
  • 21.
    Substitution Techniques :Caesar Cipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Algorithm can be expressed as follows: • For each plaintext letter p, substitute the ciphertext letter C C = E(3, p) = (p + 3) mod 26 • A shift may be of any amount, so that the general Caesar algorithm is C = E(k, p) = (p + k) mod 26 where k takes on a value in the range 1 to 25 • The decryption algorithm is simply p = D(k, C) = (C k) mod 26
  • 22.
    Substitution Techniques :Caesar Cipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Disadvantage: • If it is known that a given ciphertext is a Caesar cipher, then a brute- force cryptanalysis is easily performed. Simply try all the 25 possible keys • The encryption and decryption algorithms are known • There are only 25 keys to try • The language of the plaintext is known and easily recognizable
  • 23.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • In Caesar cipher, we are shifting the alphabets, rather than just shifting the alphabet we could shuffle (jumble) the letters arbitrarily • Each plaintext letter maps to a different random ciphertext letter • Key is 26 letters long • A permutation of a finite set of elements is an ordered sequence of all the elements of, with each element appearing exactly once. • For example, if S= {a,b,c} there are six permutations of S: abc, acb, bac, bca, cab, cba • In general, there are n! permutations of a set of n elements, because the first element can be chosen in one of n ways, the second in n-1 ways, the third in n-3 ways, and so on
  • 24.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • A single cipher alphabet (mapping from plain alphabet to cipher alphabet) is used per message so it is referred as monoalphabetic substitution cipher. • Disadvantage: Even given the very large number of keys, being 10 orders of magnitude greater than the key space for DES, the monoalphabetic substitution cipher is not secure, because it does not clearly express the underlying language characteristics.
  • 25.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • 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
  • 26.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology
  • 27.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • Given ciphertext: UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ • count relative letter frequencies
  • 28.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • 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
  • 29.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • Disadvantage: • If cipher text is short then its easy to crack. • They are easy to break because they reflect the frequency data of the original alphabet.
  • 30.
    Substitution Techniques:Monoalphabetic Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • Solution: • Homophonic Substitution Cipher • A countermeasure is to provide multiple substitutes, known as homophones, for a single letter. • For example, the letter e could be assigned a number of different cipher symbols, such as 16, 74, 35, and 21, with each homophone assigned to a letter in rotation or randomly • If the number of symbols assigned to each letter is proportional to the relative frequency of that letter, then single-letter frequency information is completely obliterated.
  • 31.
    Substitution Techniques:Polygram Cipher Cryptography& Cyber Security Mrs. Kanchan Patil Department of Information Technology • Rather than replacing one plain text alphabet with ane cipher text alphabet at a time, a block of alphabets is replaced with another block of alphabet • Example: • HELLO replaced by YUQQW but • HELL replaced by TEUI
  • 32.
    Substitution Techniques: PlayfairCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • invented by Charles Wheatstone in 1854, but named after his friend Baron Play-fair • The best-known multiple-letter encryption cipher is the Play-fair, which treats diagrams in the plaintext as single units and translates these units into cipher text diagrams • The Play-fair algorithm is based on the use of a 5 × 5 matrix of letters constructed using a keyword. • Example: solved by Lord Peter Wimsey in Dorothy Sayers’s Have His Carcase
  • 33.
    Substitution Techniques: PlayfairCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • The keyword is monarchy. • The matrix is constructed by filling in the letters of the keyword (minus duplicates) from left to right and from top to bottom, and then filling in the remainder of the matrix with the remaining letters in alphabetic order. • The letters I and J count as one letter. • Plaintext is encrypted two letters at a time, according to the following rules:
  • 34.
    Substitution Techniques: PlayfairCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Repeating plaintext letters that are in the same pair are separated with a filler letter, such as x, so that balloon would be treated as ba lx ox on. • Two plaintext letters that fall in the same row of the matrix are each replaced by the letter to the right, with the first element of the row circularly following the last. For example, ar is encrypted as RM. • Two plaintext letters that fall in the same column are each replaced by the letter below it, with the top element of the column circularly following the last. For example, mu is encrypted as CM. • Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row and the column occupied by the other plaintext letter. Thus, hs becomes BP and ea becomes IM (or JM, as the encipherer wishes).
  • 35.
    Substitution Techniques: PlayfairCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Advantage: • The Playfair cipher is a great advance over simple monoalphabetic ciphers. • There are only 26 letters, there are 26 × 26 = 676 digrams, that identification of individual digrams is more difficult. • Widely used for many years eg. by US & British military in WW1 • Disadvantage: • it can be broken, given a few hundred letters since still has much of plaintext structure
  • 36.
    Substitution Techniques: Poly-alphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • improve security using multiple cipher alphabets • make 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 general name for this approach is a poly-alphabetic substitution cipher. following features are used: • A set of related mono-alphabetic substitution rules is used. • A key determines which particular rule is chosen for a given transformation.
  • 37.
    Substitution Techniques: PolyalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vigenère Cipher: • simplest polyalphabetic substitution cipher • set of related mono-alphabetic substitution rules consists of the 26 Caesar ciphers, with shifts of 0 through 25. • Each cipher is denoted by a key letter, which is the cipher text letter that substitutes for the plaintext letter ‘a’, and which are each used in turn • key is multiple letters long K = k1 k2 ... kd • ith letter specifies ith alphabet to use • repeat from start after d letters in message • decryption simply works in reverse
  • 38.
    Substitution Techniques: PolyalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vigenère Cipher: • write the plaintext out • write the keyword repeated above it • use each key letter as a Caesar cipher key • encrypt the corresponding plaintext letter
  • 39.
    Substitution Techniques: PolyalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vigenère Cipher: example using keyword deceptive key: deceptivedeceptivedeceptive plaintext: wearediscoveredsaveyourself ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
  • 40.
    Substitution Techniques: PolyalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vigenère Cipher: Security • have multiple cipher text letters for each plaintext letter • hence letter frequencies are obscured (difficult to understand) but not totally lost • start with letter frequencies • see if look mono alphabetic or not • if not, then need to determine number of alphabets, since then can attach each
  • 41.
    Substitution Techniques: PolyalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Disadvantage: • The Vigenère & related polyalphabetic ciphers still do not completely understand the underlying language characteristics. • The key to breaking them was to identify the number of translation alphabets, and then attack each separately. • The key and the plain text share the same frequency distribution of letters, a statistical technique can be applied.
  • 42.
    Substitution Techniques: PolyaalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vernam Cipher: • In Vigenère Cipher, The key and the plain text share the same frequency distribution of letters, a statistical technique can be applied. • Solution is to choose a keyword that is as long as the plaintext and has no statistical relationship to it. • A system was introduced by an AT&T engineer named Gilbert Vernam in 1918. • His system works on binary data (bits) rather than letters. • The system can be expressed as follows: ci = pi X-OR ki
  • 43.
    Substitution Techniques: PolyaalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vernam Cipher: • The system can be expressed as follows: ci = pi X-OR ki where, Pi = ith binary digit of plaintext Ki = ith binary digit of key Ci = ith binary digit of ciphertext
  • 44.
    Substitution Techniques: PolyaalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vernam Cipher: • Thus, the ciphertext is generated by performing the bitwise X-OR of the plaintext and the key. • Because of the properties of the X-OR, decryption simply involves the same bitwise operation: pi = ci X-OR ki
  • 45.
    Substitution Techniques: PolyaalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vernam Cipher: • Plain-Text: O A K • Key: S O N O ==> 14 = 0 1 1 1 0 S ==> 18 = 1 0 0 1 0 Bitwise XOR Result: 1 1 1 0 0 = 28 • Since the resulting number is greater than 26, subtract 26 from it. • Then convert the Cipher-Text character number to the Cipher-Text character. 28 - 26 = 2 ==> C CIPHER-TEXT: C
  • 46.
    Substitution Techniques: PolyaalphabeticCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Vernam Cipher: • The essence of this technique is the means of construction of the key. • Vernam proposed the use of a running loop of tape that eventually repeated the key, so that in fact the system worked with a very long but repeating keyword. • Although such a scheme, with a long key, presents formidable cryptanalytic difficulties, it can be broken with sufficient ciphertext, the use of known or probable plaintext sequences, or both.
  • 47.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • An Army Signal Corp officer, Joseph Mauborgne, proposed an improvement to the Vernam cipher that yields the ultimate in security • Mauborgne suggested using a random key that is as long as the message, so that the key need not be repeated. • The key is to be used to encrypt and decrypt a single message, and then is discarded. • Each new message requires a new key of the same length as the new message. • Such a scheme, known as a one-time pad, is unbreakable.
  • 48.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • It produces random output that bears no statistical relationship to the plaintext. Because the cipher text contains no information whatsoever about the plaintext, there is simply no way to break the code. • Example: Two different decryptions using two different keys
  • 49.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Input: Message = HELLO, Key = MONEY • Output: Cipher – TSYPM, Message – HELLO • Explanation: • Part 1: Plain text to Ciphertext • Plain text: H E L L O -> 7 4 11 11 14 • Key: M O N E Y -> 12 14 13 4 24 • Plain text + key: 19 18 24 15 38 -> 19 18 24 15 12 (= 38 – 26) • Cipher Text: T S Y P M
  • 50.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Part 2: Ciphertext to Message • • Cipher Text:T S Y P M -> 19 18 24 15 12 • Key: M O N E Y -> 12 14 13 4 24 • Cipher text – key -> 7 4 11 11 -12 -> 7 4 11 11 14 • Message: H E L L O • Input: • Message = SAVE, • Key = LIFE • Output: Cipher – DIAI • Message – SAVE
  • 51.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Security: • The security of the one-time pad is entirely due to the randomness of the key. • If the stream of characters that constitute the key is truly random, then the stream of characters that constitute the ciphertext will be truly random. Thus, there are no patterns or regularities that a cryptanalyst can use to attack the ciphertext. • Advantages: • Primarily used for low-bandwidth channels requiring very high security. • The one-time pad is the only cryptosystem that exhibits what is referred to as perfect secrecy.
  • 52.
    Substitution Techniques: OneTime Pad Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Difficulties: • There is the practical problem of making large quantities of random keys. Any heavily used system might require millions of random characters on a regular basis. Supplying truly random characters in this volume is a significant task. • Even more daunting is the problem of key distribution and protection. For every message to be sent, a key of equal length is needed by both sender and receiver. Thus, a mammoth key distribution problem exists.
  • 53.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Another interesting multi-letter cipher (polygraphic) is the Hill cipher, developed by the mathematician Lester Hill in 1929. • Uses the concept of Linear Algebra • We define the inverse 𝑀−1 of a square matrix M by the equation, 𝑀 𝑀−1 = 𝑀−1 𝑀 = 𝐼 where I is the identity matrix. • I is a square matrix that is all zeros except for ones along the main diagonal from upper left to lower right. • The inverse of a matrix does not always exist, but when it does, it satisfies the preceding equation.
  • 54.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • To encrypt a message, each block of n letters (considered as an n- component vector) is multiplied by an invertible n × n matrix, against modulus 26. • To decrypt the message, each block is multiplied by the inverse of the matrix used for encryption. • The matrix used for encryption is the cipher key, and it should be chosen randomly from the set of invertible n × n matrices (modulo 26).
  • 55.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Example: • Input : • Plaintext: ACT • Key: GYBNQKURP • Output : Ciphertext: POH • We have to encrypt the message ‘ACT’ (n=3). • The key is ‘GYBNQKURP’ which can be written as the N X N • matrix: Matrix is framed from the given key
  • 56.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • The message message ‘ACT’ (n=3) is written as: • The enciphered vector is given as: • Output: ciphertext POH
  • 57.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • To decrypt the message, we turn the ciphertext back into a vector, then simply multiply by the inverse matrix of the key matrix (IFKVIVVMI in letters).The inverse of the matrix is: • For the Cipher-text POH
  • 58.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Example:
  • 59.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • To explain how the inverse of a matrix is computed, we begin by with the concept of determinant. • For any square matrix (m × m), the determinant equals the sum of all the products that can be formed by taking exactly one element from each row and exactly one element from each column, with certain of the product terms preceded by a minus sign • For a 2 × 2 matrix, The determinant is K11K22- K12K21
  • 60.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • If a square matrix A has a nonzero determinant, then the inverse of the matrix is computed as • Where, Dji is the sub-determinant formed by deleting the jth row and the ith column of A • det(A) is the determinant of A and (det A)^-1 is the multiplicative inverse of (det A) mod 26 • So, for our example • We can show that 9^-1 mod 26 = 1, because 9*3=27 mod 26 = 1
  • 61.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Hill Algorithm: • This encryption algorithm takes m successive plaintext letters and substitutes for them m ciphertext letters. • The substitution is determined by m linear equations in which each character is assigned a numerical value (a = 0, b = 1, ……, z = 25) • For m = 3, system can be described as
  • 62.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Hill Algorithm: • This can be expressed in terms of row vectors and matrices: • where C and P are row vectors of length 3 representing the plaintext and ciphertext, and K is a matrix representing the encryption key. Operations are performed mod 26
  • 63.
    Substitution Techniques: HillCipher Cryptography & Cyber Security Mrs. Kanchan Patil Department of Information Technology • Example: • Lets consider a plaintext “paymoremoney” and consider key, K • The first three letters of the plaintext are represented by the vector (15 0 24). • Then (15 0 24)K = (303 303 531) mod 26 = (17 17 11) = RRL • Continuing in this fashion, the ciphertext for the entire plaintext is RRLMWBKASPDH • Decryption requires inverse of matrix K
  • 64.
    References: Cryptography & CyberSecurity Mrs. Kanchan Patil Department of Information Technology • William Stallings, “Cryptography and Network Security-Principles and practice”