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

Lecture 2-Classical Cryptography-1

Uploaded by

r.arshadr12
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lecture 2-Classical Cryptography-1

Uploaded by

r.arshadr12
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Lecture-2

Classical
Cryptography
AYESHA KANWAL-SEECS
Introduction
cryptography* → the process of making and using codes to secure information.

cryptanalysis → the process of obtaining the plaintext message from a


ciphertext message without knowing the keys used to perform the encryption.

cryptology → the field of science that encompasses cryptography and


cryptanalysis.
Bit stream cipher*: An encryption method that involves converting plaintext to
ciphertext one bit at a time.
Block cipher*: An encryption method that involves dividing the plaintext into
blocks or sets of bits and then converting the plaintext to ciphertext one block at
a time.
Cipher Methods
Substitution Cipher* → an encryption method in which one value is substituted
for another.
Example: In a “three-character substitution to the right” scheme, the plaintext
MOM would be encrypted into the ciphertext PRP.
The previous example of substitution is simple and uses:
monoalphabetic substitution → a substitution cipher that only incorporates a
single alphabet in the encryption process.

Substitution becomes very powerful if combined with other operations:


polyalphabetic substitution → a substitution cipher that incorporates two or
more alphabets in the encryption process.
Extending the previous example, consider the following single polyalphabetic
substitution cipher:
To encode the word TEXT with this cipher, you substitute:
◦ a letter from the second row for the first letter in TEXT,
◦ a letter from the third row for the second letter, and ○ so on

You get the ciphertext WKGF.


◦ Note how the plaintext letter T is transformed into a W or an F, depending on
its order of appearance in the plaintext.
1. Complexities like these make this type of encryption substantially more
difficult to decipher when one doesn’t have the algorithm (in this case, the
rows of ciphers) and the key, which is the substitution method.

2. A logical extension to this process is to randomize the cipher rows completely


in order to create a more complex operation.
Symmetric Cipher Model
Requirements
Two requirements for secure use of symmetric encryption:
◦ a strong encryption algorithm
◦ a secret key known only to sender / receiver
Y = EK(X)
X = DK(Y)
Assume encryption algorithm is known
Implies a secure channel to distribute key
Classical Substitution Ciphers
Letters of plaintext are replaced by other letters or by numbers or
symbols
Plaintext is viewed as a sequence of bits, then substitution replaces
plaintext bit patterns with ciphertext bit patterns
Caesar Cipher
Earliest known substitution cipher
Replaces each letter by 3rd letter on
Example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
Caesar Cipher
Define transformation as:
a b c d e f g h i j k l m n o p q r s t u v w x y z
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

Mathematically give each letter a number


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

Then have Caesar cipher as:


C = E(p) = (p + k) mod (26)
p = D(C) = (C – k) mod (26)
Examples
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
Link: https://www.javatpoint.com/caesar-cipher-technique
Playfair Cipher
1.Generate the key Square(5×5):
1. The key square is a 5×5 grid of alphabets that acts as the key for encrypting
the plaintext. Each of the 25 alphabets must be unique and one letter of the
alphabet (usually J) is omitted from the table (as the table can hold only 25
alphabets). If the plaintext contains J, then it is replaced by I.

2. The initial alphabets in the key square are the unique alphabets of the key
in the order in which they appear followed by the remaining letters of the
alphabet in order.

2.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.
PlainText: "instruments"
After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz’
Key = monarchy

1. Pair cannot be made with same letter. Break the letter in single
and add a dummy letter to the previous letter.
Plain Text: “hello”
After Split: ‘he’ ‘lx’ ‘lo’
Here ‘x’ is the dummy letter.
2. If the letter is standing alone in the process of pairing, then
add an extra dummy letter with the alone letter
Plain Text: “helloe”
AfterSplit: ‘he’ ‘lx’ ‘lo’ ‘ez’
Here ‘z’ is the dummy letter.
Rules for encryption
If both the letters are in the same column: Take the letter
below each one (going back to the top if at the bottom).
If both the letters are in the same row: Take the letter to
the right of each one (going back to the leftmost if at the
rightmost position).
If neither of the above rules is true: Form a rectangle with
the two letters and take the letters on the horizontal opposite
corner of the rectangle.
Diagraph: "me"
Encrypted Text: cl
Encryption:
m -> c
e -> l
Diagraph: "st"
Encrypted Text: tl
Encryption:
s -> t
t -> l
Diagraph: "nt"
Encrypted Text: rq
Encryption:
n -> r
t -> q
Example
Suppose, the plaintext is COMMUNICATE and the key that we will use to
encipher the plaintext is COMPUTER. The key can be any word or phrase.
Let's encipher the message COMMUNICATE.
1. First, split the plaintext into digraph (by rule 2) i.e. CO MX MU NI CA TE.
2. Construct a 5*5 key-matrix (by rule 3). In our case, the key is COMPUTER.
• The first digraph is CO. The pair appears in the same row. By using Rule 4(i) CO gets
encipher into OM.
• The second digraph is MX. The pair appears in the same column. By using Rule 4(ii) MX gets
encipher into RM.
• The third digraph is MU. The pair appears in the same row. By using Rule 4(i) MU gets
encipher into PC.
• The fourth digraph is NI. The pair appears in different rows and different columns. By
using Rule 4(iii) NI gets encipher into SG.
• The fifth digraph is CA. The pair appears in different rows and different columns. By
using Rule 4(iii) CA gets encipher into PT.
• The sixth digraph is TE. The pair appears in the same row. By using Rule 4(i) TE gets
encipher into ER.
Therefore, the plaintext COMMUNICATE gets encipher (encrypted) into OMRMPCSGPTER.
How to decrypt?
Decryption of Playfair
Decrypting the Playfair cipher is as simple as doing the same process in
reverse.
Rules for Decryption:
If both the letters are in the same column: Take the letter above each
one (going back to the bottom if at the top).
If both the letters are in the same row: Take the letter to the left of each
one (going back to the rightmost if at the leftmost position).
If neither of the above rules is true: Form a rectangle with the two letters
and take the letters on the horizontal opposite corner of the rectangle.
Example
Keyword = keyword
Message = “Why, don’t you?”

Cipher text = ?
Vigenère Cipher
Vigenere Cipher is a method of encrypting alphabetic text. It uses a
simple form of polyalphabetic substitution. A polyalphabetic cipher
is any cipher based on substitution, using multiple substitution
alphabets. The encryption of the original text is done using the
Vigenère square or Vigenère table.
•The table consists of the alphabets written out 26 times in different
rows, each alphabet shifted cyclically to the left compared to the
previous alphabet, corresponding to the 26 possible Caesar Ciphers.
•At different points in the encryption process, the cipher uses a
different alphabet from one of the rows.
•The alphabet used at each point depends on a repeating keyword.
Examples
Input : Plaintext : GEEKSFORGEEKS
Keyword : AYUSH
Output : Ciphertext : GCYCZFMLYLEIM
For generating key, the given keyword is repeated in a circular manner until it
matches the length of the plain text.
The keyword "AYUSH" generates the key "AYUSHAYUSHAYU"
The plain text is then encrypted using the process explained below.
Encryption:
The first letter of the plaintext, G is paired with A, the first letter
of the key. So use row G and column A of the Vigenère square,
namely G. Similarly, for the second letter of the plaintext, the
second letter of the key is used, the letter at row E, and column
Y is C. The rest of the plaintext is enciphered in a similar fashion.
Decryption:
Decryption is performed by going to the row in the table
corresponding to the key, finding the position of the ciphertext
letter in this row, and then using the column’s label as the
plaintext. For example, in row A (from AYUSH), the ciphertext G
appears in column G, which is the first plaintext letter. Next, we
go to row Y (from AYUSH), locate the ciphertext C which is found
in column E, thus E is the second plaintext letter.
Message: "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
Keyword: "CRYPTOGRAPHY“

Output : Ciphertext ?
Hill Cipher
•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).
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 nxn matrix:

The message ‘ACT’ is written as vector:


The enciphered vector is given as:

which corresponds to ciphertext of ‘POH’


Decryption
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 used in the previous example is:
Class activity-2
Please submit in the group of two students.
Use keyword letters = HILL
The plaintext "short example“.

Encrypt the above plaintext and then decrypt to generate the same plaintext.

You might also like