0% found this document useful (0 votes)
29 views60 pages

Cryptography and Cryptographic Algorithms Upto DES

Uploaded by

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

Cryptography and Cryptographic Algorithms Upto DES

Uploaded by

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

Cryptography and Cryptographic

Algorithms
Cryptography
• The word cryptography comes from two Greek words
meaning “secret writing” and is the art and science of
information hiding.
• Application in many fields like computer security, electronic
commerce, telecommunication, etc.
• In the ancient days, cryptography was mostly referred to as
encryption – the mechanism to convert the readable
plaintext into unreadable (incomprehensible) text i.e.
ciphertext, and decryption – the opposite process of
encryption i.e. conversion of ciphertext back to the
plaintext.
• The combined study of cryptography and cryptanalysis is
known as cryptology.
Cryptosystem
• Cryptosystem is a 5-tuple/quintuple (E, D, M, K,
C), where M set of plaintexts, K set of keys, C set
of ciphertexts, E set of encryption functions e: M
 K  C and D set of decryption functions d: C 
K  M.
M = {sequences of letters}
K = {i | i is an integer and 0 ≤ i ≤ 25}
E = {Ek | k  K and for all letters m, Ek(m) = (m + k) mod 26 }
D = {Dk | k  K and for all letters c, Dk(c) = (26 + c – k) mod 26}
C=M
• Example: Caesar Cipher
Encryption and Decryption
• Encryption is the process of encoding a message
so that its meaning is not obvious i.e. converting
information from one form to some other
unreadable form using some algorithm called
cipher with the help of secret message called key.
• The converting text is called is plaintext and the
converted text is called ciphertext.
• Decryption is the reverse process, transforming
an encrypted message back into its normal,
original form. In decryption process also the use
of key is important.
Encryption and Decryption
• Alternatively, the terms encode and decode or
encipher and decipher are used instead of encrypt
and decrypt. That is, we say that we encode, encrypt,
or encipher the original message to hide its meaning.
Then, we decode, decrypt, or decipher it to reveal
the original message.
Key (Cryptovariable)
• A key is a parameter or a piece of information used to
determine the output of cryptographic algorithm.
• While doing the encryption, key determines the
transformation of plaintext to the cipher text and vice
versa.
• Keys are also used in other cryptographic processes like
message authentication codes and digital signatures.
• We need to select the key in a way such that attacker
should take long enough to try all possibilities i.e.
computationally infeasible.
Cipher
• A cipher is an algorithm for performing
encryption and decryption.
• The operation of cipher depends upon the
special information called key.
• Without knowledge of the key, it should be
difficult, if not nearly impossible, to decrypt
the resulting cipher into readable plaintext.
Types of Ciphers
• Historical Ciphers
• Modern Ciphers
Historical Ciphers
• Also called classical ciphers used processes like
substitution and transposition or combination of
both called product ciphers.
• These historic ciphers use the single key for both
encryption and decryption (symmetric cipher).
• To reduce the cipher attacks, in substitution
instead of monoalphabetic - a letter for letter,
polyalphabetic- one or more letters for single
letter substitution can be used.
Historical Ciphers

Plaintext: meet me after the toga party


Ciphertext: PHHW PH DIWHU WKH WRJD SDUWB
Plaintext: the quick brown fox jumps over the lazy dog
Ciphertext: WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
Cryptanalysis
• is the study of methods for obtaining the
meaning of encrypted information, without
access to the secret information which is
normally required to do so.
• Typically, this involves finding a secret key.
• Cryptanalysis is the analytical steps to find
some weaknesses or insecurity in a
cryptographic scheme.
Cryptanalysis
• Brute-force attack: tries every possible key on
a piece of cipher text until an understandable
translation into plaintext is obtained.
• Cryptanalysis: exploits the characteristics of
the algorithm and the traces of structure or
pattern in the plaintext that survive
encryption, to attempt to break a single
message, or to deduce the key in order to
break the subsequent messages.
Basis for Cryptanalytic Attacks
• Mathematical attacks: Based on analysis of
underlying mathematics
• Statistical attacks: Make assumptions about
the distribution of letters, pairs of letters
(diagrams), triplets of letters (trigrams), etc.
and examine cipher text by correlating
properties with the assumptions.
Classical Cryptography Examples
Classical Cryptography
• Classical ciphers can be practically computed
and solved by hand.
• They are easily breakable with modern
technology.
• Some examples: Caesar Cipher, Substitution
Cipher, Transposition Cipher, Simple XOR
Cipher, Playfair Cipher etc.

1
5
Modular Arithmetic
• Several important cryptosystems make use of
modular arithmetic. This is when the answer
to a calculation is always in the range 0 – n
where n is the modulus.
• To calculate the value of b mod n, you take
away as many multiples of n as possible until
you are left with an answer between 0 and n.
Clock Method for Modular Arithmetic
• Label 0 to (n-1) for mod n on a
clock.
• For addition count clockwise
the value of 2nd number from
the value of 1st number.
• For subtraction count anti-
clockwise the value of 2nd
number from the value of 1st
number.
• e.g. from figure we can see:
 (2+4) mod 12=6
 (2-4) mod 12=10

1
7
Reminder for Modular Arithmetic
• If “b”is positive integer and its modulo n can
be calculated as Reminder while dividing it by
n. i.e. b mod n=r, where r is reminder while
dividing “b” by “n”.
• e.g.
 14 mod 12= 2 since 14/12 we get reminder 2.
 29 mod 26= 3 since 29/26 we get reminder 2.

1
8
If b is a negative number then you add as
many multiples of m as necessary to get an
answer in the range 0 – n.

Examples
17 mod 5 = 2 7 mod 11 = 7
20 mod 3 = 2 11 mod 11 = 0
-3 mod 11 = 8 -1 mod 11 = 10
25 mod 5 = 0 -11 mod 11 = 0
Caesar Cipher
• It is developed by Julius Caesar.
• It is applicable only for English alphabets.
• It is a mono-alphabetic cipher wherein each letter of the plaintext is
substituted by another letter to form the ciphertext. It is a simplest form
of substitution cipher scheme.
• This cryptosystem is generally referred to as the Shift Cipher. The concept
is to replace each alphabet by another alphabet which is ‘shifted’ by some
fixed number between 0 and 25.
• For this type of scheme, both sender and receiver agree on a ‘secret shift
number’ for shifting the alphabet. This number which is between 0 and 25
becomes the key of encryption.
• The name ‘Caesar Cipher’ is occasionally used to describe the Shift Cipher
when the ‘shift of three’ is used.
• If m=plaintext, k=key and c=ciphertext, then
– Encryption: c=Ek(m)= (m+k) mod 26; 0≤m≤25
– Decryption: m=Dk(c)= (c-k) mod 26; 0≤c≤25

2
0
Modular Arithmetic and Caesar
Ciphers
• Since there are 26 letters in the English alphabet, let’s relate the letters a-z by numbers
0-25 as shown by the diagram below.

• Notice going from “A” to “D” was a shift of 3 letters over. Thus we can encrypt the word
“ZEAL” by relating “Z” with 25 on the wheel, adding 3 to get 2, and then we turn this
back into a letter, which gives us “C”. Similarly “E” → 4 → 7 → H… So we can get
ciphertext “CHDO”.

2
1
Caesar Cipher Cont…
• e.g. Plaintext=ANT, Key=3 then Ciphertext=?
Now, m1=A, m2=N and m3=T
k=3
We have, c=Ek(m)= (m+k) mod 26; 0≤m≤25
c1=(m1+k) mod 26=(0+3) mod 26=3=D
c2= =(m2+k) mod 26=(13+3) mod 26=16=Q
c3=(m3+k) mod 26=(19+3) mod 26=22=W
Hence, ciphertext=“DQW”

2
2
Polyalphabetic Ciphers

• The relationship between a character in the


plaintext to a character in the cipher text is
one-to-many.
Playfair Cipher
• not even the large number of keys in a
monoalphabetic cipher provides security
• one approach to improving security was to encrypt
multiple letters
• the Playfair Cipher is an example
• invented by Charles Wheatstone in 1854, but named
after his friend Baron Playfair
Playfair Cipher
• Multiletter encryption cipher.
• It is based on the use of 5x5 matrix of letters constructed using
keyword.
• e.g. keyword=“monarchy”, fill the matrix with letters without
repeating letter. The letters ‘i’ and ‘j’ are counted as one letter.
m o n a r
c h y b d
e f g i/j k
l p q s t
u v w x z
• Take letters in pair. If there is same letter repeating in single pair, they shall
be separated with a filter letter such as x. e.g in “aap”, ‘a’ and ‘a’ are in
same pair so that “aap” is treated as “ax ap”.

2
5
Playfair Cipher Cont…
• If two plaintext letters in a pair that fall in same row of matrix, each letter is
replaced by the letter to the right, with the first element of the row circularly
following the last. e.g. “ar” is encrypted as “rm”.
• If two plaintext letters in a pair that fall in same column of matrix, each letter is
replaced by the letter beneath, with the top element of the column circularly
following the last. e.g. “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. e.g. “hs” become “bp”
and “ea” become “im” or “jm”.
• e.g. plaintext= “balloon”
We can write plaintext in letter pair as ba lx lo on
From given matrix with key, letters pairs are replaced as:
ba=ib
lx=su
lo=pm
on=na
Hence, ciphertext=“ibsupmna”
Note: 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.
For example:
PlainText: "instruments" 2
After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz' 6
Vigenere Cipher
• The Vigenere cipher is the kind of polyalphabetic cipher.
• It was design by Blaise de Vigenere, a 16th century French
mathematician.
• It was used in the American civil war and was once believed to
be unbreakable.
• A Vigenere cipher uses a different strategy to create the key
stream.
• The key stream is a repetition of an initial secret key stream of
length m, where we have 1<=m<=26.
• The Vigenere cipher is a method of encrypting alphabetic text by
using a series of different Caesar ciphers based on the letters of a
keyword.
• The Vigenere cipher uses multiple mixed alphabets, each is a shift
cipher.
Vigenere Cipher
• Plain text: Cipher text:

• Key stream:

• Encryption: mod 26

• Decryption: mod 26
Example
• We can encrypt the message “She is listening” using
the 6-character keyword “PASCAL“. The initial key
stream is (15,0,18,2,0,11). The key stream is the repetition
of this initial key stream (as many times as needed) .
• Use encryption algo:

• mod 26


Vigenere Table
• Another way to look at Vigenere ciphers is through what is called
a Vigenere Tableau, Vigenere Table or Vigenere Square.
• The first row of this table has the 26 English letters. Shows the
plain text character to be encrypted.
• Starting with the second row, each row has the letters shifted to
the left one position in a cyclic way. For example, when B is
shifted to the first position on the second row, the letter A moves
to the end.
• The first column contains the characters to be used by the key.
Plain test

K
e
y
Example:-
• Encrypt the following plain text using vigenere cipher with
given key.
• key VIG
• plain THEBOYHASTHEBALL
• cipher OPKWWECIYOPKWIRG
Rail Fence Ciphers
• The rail fence cipher (also called a zigzag cipher) is a form of
transposition cipher.
• In the rail fence cipher, the plain-text is written downwards and
diagonally on successive rails of an imaginary fence.
• When we reach the bottom rail, we traverse upwards moving
diagonally, after reaching the top rail, the direction is changed
again. Thus the alphabets of the message are written in a zig-zag
manner.
• After each alphabet has been written, the individual rows are
combined to obtain the cipher-text.
For example,

Plaintext: meet me after the toga party


m e ma tr ht gp r y
e t e f e t e oa a t
Ciphertext: MEMATRHTGPRYETEFETEOAAT
Question: Encrypt the following plaintext
ALL GOOD THINGS COME TO THOSE WHO WAIT
Modern Ciphers
Based upon input data
• Stream Ciphers: In this kind of ciphers the
plaintext is converted into ciphertext stream
by stream. So it encrypts continuous streams
of data. Like, character by character
conversion. Example: RC4, SEAL, Salsa20 etc
• Block Ciphers: Here the plaintext is converted
into ciphertext block by block. So it encrypts
of data of fixed size. Example: DES, 3DES, AES
Modern Ciphers
Based upon type of key
• Symmetric Key Algorithms (Private Key
Cryptography): These techniques use single
key for encryption as well as decryption.
• Asymmetric Key Algorithms (Public Key
Cryptography): These techniques use two
keys, namely private and public keys. One key
is used for encryption and the other is used
for decryption.
Symmetric Cryptography
• The algorithm requires same secret key for
encryption and decryption.
• Encryption and decryption are essentially
identical (symmetric algorithms)
Feistel Cipher Structure

• Horst Feistel devised the feistel cipher


– based on concept of invertible product cipher
• partitions input block into two halves
• process through multiple rounds which:
• perform a substitution on left data half
• based on round function of right half & sub key
• then have permutation swapping halves
Feistel Cipher Structure

• Virtually all conventional block encryption


algorithms including data encryption standard (DES)
are based on Feistel Cipher Structure.
• The plaintext is divided into
i two halves L0 and R0
Then the two halves pass through n rounds of
processing then combine to produce the cipher
block.
• Each round i has as input Li 1 and Ri 1 derived from
the previous round as well as a sub-key K i derived
from the overall K
Feistel Cipher Structure

All rounds have the same structure


A substitution is performed on the left half of the
data. This is done by applying a round function F to
the right half of the data followed by the XOR of
the output of that function and the left half of the
data.
Classical Feistel Network
Classical Feistel Network
Design Features of Feistel Network

 Block Size: (larger block means greater security) 64


bits.
 Key Size:56-128 bits.
 Number of Rounds: a single round offers inadequate
security, a typical size is 16 rounds.
 Sub-key Generation Algorithms: greater complexity
should lead to a greater difficulty of cryptanalysis.
 Round function: Again, greater complexity generally
means greater resistance to cryptanalysis.
Design Features of Feistel Network

.
 Round function: Again, greater complexity generally
means greater resistance to cryptanalysis.
 Fast Software encryption/Decryption: the speed of
execution of the algorithm is important.
 Ease of Analysis: to be able to develop a higher level
of assurance as to its strength
 Decryption: use the same algorithm with reversed
keys.
Feistel Encryption and Decryption
Data Encryption Standard (DES)
• DES is the block cipher - an algorithm that takes a
fixed-length string of plaintext bits and transforms it
through a series of complicated operations into
another ciphertext bit string of the same length.
• Product Cipher (It uses both transposition and
substitution)
• The key consists of 64 bits; however, only 56 of these
are actually used by the algorithm.
• Eight bits are used solely for checking parity, and are
thereafter discarded.
• Hence the effective key length is 56 bits, and it is
usually quoted as such.
DES
DES Round Function
• The heart of this cipher is the DES
function, f. The DES function
applies a 48-bit key to the rightmost
32 bits to produce a 32-bit output.
• Expansion Permutation Box − Since
right input is 32-bit and round key is
a 48-bit, we first need to expand
right input to 48 bits. Permutation
logic is graphically depicted in the
following illustration.

Fig. DES Round Function

Fig. Permutation Logic for Expansion Permutation Box

5
1
• The graphically depicted permutation logic is generally described as table in DES
specification illustrated as shown:

• XOR (Whitener). − After the expansion permutation, DES does XOR operation on
the expanded right section and the round key. The round key is used only in this
operation.

5
2
• Substitution Boxes. − The S-boxes carry out the real mixing
(confusion). DES uses 8 S-boxes, each with a 6-bit input and a 4-bit
output. Refer the following illustration

• The S-box rule is illustrated below −

5
3
• The output of all eight s-boxes is then combined in to 32 bit section.
• Straight Permutation − The 32 bit output of S-boxes is then subjected to
the straight permutation with rule shown in the following illustration:

5
4
Key Generation
• The round-key generator
creates sixteen 48-bit
keys out of a 56-bit cipher
key.
• The process of key
generation is depicted in
the following illustration

5
5
DES
DES Analysis
• The DES satisfies both the desired properties of block
cipher. These two properties make cipher very strong.
– Avalanche effect − A small change in plaintext results in
the very great change in the ciphertext.
– Completeness − Each bit of ciphertext depends on many
bits of plaintext.
• During the last few years, cryptanalysis have found
some weaknesses in DES when key selected are weak
keys. These keys shall be avoided.
• DES has proved to be a very well designed block cipher.
There have been no significant cryptanalytic attacks on
DES other than exhaustive key search.

5
7
Public Key Cryptography Protocol
Public Key Cryptography Protocol
• Alice and Bob agree on a public-key
cryptosystem.
• Bob sends Alice his public key.
• Alice encrypts her message with Bob's public
key and sends the ciphertext.
• Bob decrypts ciphertext using his private key.
Symmetric v/s Asymmetric
Cryptography
Secret Key (Symmetric) Public Key (Asymmetric)

Number of 1 2
keys

Protection of Must be kept secret One key must be kept secret; the other
key can be freely exposed

Best uses Cryptographic workhorse; secrecy and Key exchange, authentication


integrity data—single characters to
blocks of data, messages, files

Key Must be out-of-band Public key can be used to distribute


distribution other keys

Speed Fast Slow; typically, 10,000 times slower than


secret key

You might also like