Ciphers and Its Types

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

CIPHERS AND ITS TYPES

WHAT IS A CIPHER?
 A Cipher is an algorithm for encrypting and decrypting data.
 Ciphers are used in converting a plain text to a ciphertext.
 During the 16th century, Vigenere designed a cipher that was
supposedly the first cipher which used an encryption key.
SOME BASIC TERMINOLOGIES
 Before learning types of ciphers, we need to know some basic
terms in cryptography.
 Cryptography:- Cryptography is the art of protecting
information by transforming it into an unreadable text.
 Encryption:- The process of transforming information from
readable to unreadable format so that only authorized persons
can access it(plaintext to ciphertext).
 Decryption:- The process of transforming information from
unreadable to readable format(ciphertext to plaintext).
 Key:- String of bits used by cryptographic algorithms to convert
plaintext to ciphertext and vice versa.
 Public Key:- Key that is known to everyone.
 Private Key:- Key known to specified authorized user only.
 Symmetric Cryptography:-
 It is also called private key cryptography.
 It is the simplest kind of encryption technique that
involves only one key to encrypt and decrypt.
 Asymmetric Cryptography:-
 It is also called public key cryptography.
 It uses two different keys for encryption and
decryption .That means, if encryption is done using a
public key, decryption is done using private key and vice
versa.

TYPES OF CIPHERS

CIPHERS

ASYMMETRIC SYMMETRIC
CIPHERS
CIPHERS

MODERN TRADITIONAL
CIPHERS CIPHERS

TRANSPOSITION SUBSTITUTION
BLOCK CIPHER STREAM CIPHER
CIPHERS CIPHERS

COLUMNAR MONOALPHABE POLYALPHABETI


RAIL FENCE
TRANSPOSITION TIC C
CIPHER
CIPHER CIPHER CIPHER

CAESAR PLAYFAIR VIGENERE ONE TIME


HILL CIPHER
CIPHER CIPHER CIPHER PAD CIPHER

SYMMETRIC CIPHERS
Symmetric Ciphers use only one key for encryption and
decryption.
 These are of two types:-
1. Traditional Symmetric Ciphers
2. Modern Symmetric Ciphers
TRADITIONAL SYMMETRIC CIPHERS
 TRANSPOSITION CIPHERS
1. A transposition cipher is a method of encryption
which scrambles the positions of characters without
changing the characters themselves.
2. Transposition ciphers reorder units of plaintext
according to a regular system to produce a ciphertext
which is a permutation of the plaintext.
3. We have two Transposition Ciphers.
RAIL FENCE CIPHER
 In the rail fence cipher, the plaintext is written downwards
diagonally on successive "rails" of an imaginary fence, then
moving up when the bottom rail is reached, down again
when the top rail is reached, and so on until the whole
plaintext is written out. The ciphertext is then read off in
rows.
 Rail Fence cipher is a keyless cipher.

For Example, if the message is “GEEKSFORGEEKS” and no of


rails is “3”

The Encrypted Message is “GSGSEKFREKEOE”


 The Rail Fence Cipher algorithm is perfect for use
in randomized words.

IMPLEMENTATION

ion will be done row wise i.e. GSGSEKFREKEOE


COLUMNAR TRANSPOSITION CIPHER
 Columnar Transposition involves writing the plaintext
out in rows, and then reading the ciphertext off in
columns one by one.
 Columnar Transposition cipher is a keyed cipher.

 Write the key in number form and fill the message in


rows under key. Now write the letters in column with
least key number. Finally this gives you ciphertext.

IMPLEMENTATION

 If you find spaces fill the spaces with


dummy characters in the grid.
 SUBSTITUTION CIPHERS
1. Substitution Ciphers Encrypt the plaintext by
swapping each letter or symbol in the plaintext by a
different symbol as directed by the key.
2. It is of two types:
 Monoalphabetic Ciphers
 A Single Cipher Alphabet for each
plaintext is used throughout the process.
 The relation between a character in the
plaintext to a character in the ciphertext is
ONE TO ONE.
 EXAMPLE: CAESAR CIPHER

 Polyalphabetic Ciphers
 There is no fixed substitution.
 Each Occurance of a character may have
different substitute.
 The relation between a character in the
plaintext to a character in the cipher text
is ONE TO MANY.
 EXAMPLE:
PLAYFAIR CIPHER HILL CIPHER
VERNAM CIPHER VIGENERECIPHER

 CAESAR CIPHER
o It is a monoalphabetic cipher.
o It is also called Swift cipher or Additive cipher.
o Each letter of a given text is replaced by a letter with a
fixed number of positions down the alphabet.
o Let C=Cipher text , K=Key , P=Plain text, here
key is an integer between 1 and 25 then for
Encryption -> C = E(K,P) = (P+K)Mod26
Decryption -> P = D(K,C) = (C-K)Mod26
IMPLEMENTATION

 ATBASH CIPHER
o Atbash Cipher is a substitution cipher with just
one specific key where all the letters are reversed
that is A to Z and Z to A.
IMPLEMENTATION

 VIGENERE CIPHER
o It is a polyalphabetic substitution cipher.
o The encryption is done using two methods.
o METHOD I -> VIGENERE TABLE
 Encryption is done using 26x26 table.
 Let us consider a plaintext and a secret
string “key”. Repeat the letters of key so
that number of letters in plaintext and key
become equal.
 Let plaintext=GIVEMONEY , key=LOCK
G I V E M O N E Y
L O C K L O C K L

 Now find the point of intersection of


plaintext and the key for each letter. That
gives your Encrypted text.
 Encrypted text-> RWXOXCPOJ

IMPLEMENTATION
METHOD II -> Without Table
 Encryption E=(P+K)Mod26
 Decryption D=(E-K)Mod26
 Ex: plaintext=”sheislistening”
Key=PASCAL(15,0,18,2,0,11
)
Ciphertext=HHWKSWXSLGNTCG
 VERNAM CIPHER
o Also known as One Time Pad Cipher.
o It is same as Vigenere cipher but length of the key must
be equal to length of the plain text.
o IMPLEMENTATION
 PLAYFAIR CIPHER
o The Playfair cipher is the first practical diagraph
substitution cipher.
o It was invented in 1854 by Charles Wheatstone but was
named after Lord Playfair who promoted the use of
cipher.
o In Playfair cipher unlike traditional cipher we encrypt a
pair of alphabets (diagraphs) instead of a single alphabet.
ALGORITHM
1. Create a 5x5 matrix called “Grid Of Letters”.
2. The matrix is made by inserting the values of Key and
remaining alphabets into the matrix(row wise from
left to right) where letters I and J will be combined
together.
3. Convert the text into pair of alphabets
Ex: MODE  MO_DE
a. Pair cannot be made with same letters. Break
letters into single and add X to the previous
letter.
Ex: Hello  He lx lo
b. If the letter is standing alone in the process of
pairing add Z with the letter.
Ex: lotus  lo tu sz
4. Code will be formed using three rules:
 If both the alphabets are in the same row, replace
them with alphabets to their immediate right.
 If both the alphabets are in the same column,
replace them with alphabets immediately below
them.
 If not in same row/column , replace them with
alphabets in the same row respectively but at other
pair of corners.
 Ex: plaintext CHANDRASHILA
Key KRISHNA
K R I/J S H
N A B C D
E F G L M
O P Q T U
V W X Y Z

CHANDRASHILA CH AN DR AS HI LA
Applying Playfair Cipher:
CHDS ANBA DRAH ASCR
HIKS LAFC
CIPHERTEXT DSBAAHCRKSFC
IMPLEMENTATION
 HILL CIPHER
o Hill cipher is a polyalphabetic cipher.
o Hill cipher encrypts a group of letters called polygraph.
o This cipher uses mathematics.
o Encryption C = K*PMod26
o Decryption P = K-1*CMod26
o STEP I: Choose a key(key must be a square matrix)
o STEP II: Convert the plaintext into vectors. Number of
elements in vector is equal to number of rows in key.
o STEP III: Apply encryption formula on each vector to get
the encrypted text.
o STEP IV: Combine all the encrypted text to get ciphertext.
IMPLEMENTATION
MODERN CIPHERS
 STREAM CIPHER
 BLOCK CIPHER
STREAM CIPHER
 Stream Cipher Encrypts digital data stream byte
by byte.
 It is a symmetric key cipher.
 RC4 /Rivest cipher 4 is the most commonly
used stream cipher
 Stream cipher converts the given plaintext and
key into binary format and performs XOR
operation between them to return Ciphertext.

 Example Message 10110110


Key  01010101
(XOR)
Cipher 11100011
 1+0=0+1=1
 1+1=0+0=0

BLOCK CIPHER
 Block cipher converts plaintext to ciphertext by
taking entire plaintext block at a time using a
predominant key.
 Typically a block size of 64 bit or 128 bit is
taken.
 It is a symmetric key cipher.
 Block cipher uses Shannon’s Theory of
Confusion and Diffusion.
 Examples :-- DES, AES,2DES,3DES
Algorithms etc.
 FIESTEL CIPHER STRUCTURE
o Most of the block cipher techniques
follow this structure.
o The plaintext is divided into two equal
halves L0 and R0
o The two halves of the data pass through
N rounds of processing(dividing) and
then combine to produce ciphertext
block.
o On the right half we apply a function and
in the function we will use a subkey
generated from a master key.
o The output of this function is XORed
with the left half and then their output
will be swapped.
o If any algorithm, we divide the plaintext
into two halves and apply a function on
RHS and output of this is XORed with
LHS and its output is swapped , Then that
Algorithm is following the Fiestal
Structure.
o Number of rounds N depends on the
algorithm.
o As the number of rounds, block size, key
size, complexity of function increases ,
more complex is the ciphertext .
MODES OF OPERATION
 There are 5 modes of operation.
 ECB (ELECTRONIC CODE BOOK)
o It is the simplest mode of operation
o Plaintext is divided into number of fixed
size blocks.
o If message is not a multiple of block size,
then Padding is done.
o Take one block at a time and encrypt.
o Using the same key, encrypt the
remaining blocks.
o Finally combine all the encrypted blocks
to get the ciphertext.
 If Identical blocks appear, then this mode produces same cipher.
 Analysis of ECB Mode
o In reality, any application data usually have partial
information which can be guessed. For example, the range of
salary can be guessed. A ciphertext from ECB can allow an
attacker to guess the plaintext by trial-and-error if the
plaintext message is within predictable.
o For example, if a ciphertext from the ECB mode is known to
encrypt a salary figure, then a small number of trials will
allow an attacker to recover the figure. In general, we do not
wish to use a deterministic cipher, and hence the ECB mode
should not be used in most applications.

 CIPHER BLOCK CHAINING MODE

o CBC mode of operation provides message dependence for


generating ciphertext and makes the system non-
deterministic.
Operation
 The operation of CBC mode is depicted in the
following illustration. The steps are as follows −
 Load the n-bit Initialization Vector (IV) in the top
register.
 XOR the n-bit plaintext block with data value in top
register.
 Encrypt the result of XOR operation with underlying
block cipher with key K.
 Feed ciphertext block into top register and continue
the operation till all plaintext blocks are processed.
 For decryption, IV data is XORed with first ciphertext
block decrypted. The first ciphertext block is also fed
into to register replacing IV for decrypting next
ciphertext block.
Analysis of CBC Mode
 In CBC mode, the current plaintext block is
added to the previous ciphertext block, and then
the result is encrypted with the key. Decryption
is thus the reverse process, which involves
decrypting the current ciphertext and then
adding the previous ciphertext block to the
result.
 Advantage of CBC over ECB is that changing
IV results in different ciphertext for identical
message. On the drawback side, the error in
transmission gets propagated to few further
block during decryption due to chaining effect.
 It is worth mentioning that CBC mode forms
the basis for a well-known data origin
authentication mechanism. Thus, it has an
advantage for those applications that require
both symmetric encryption and data origin
authentication.

 CIPHER FEEDBACK MODE


o In this mode, each ciphertext block gets ‘fed back’ into the
encryption process in order to encrypt the next plaintext block.
Operation
o The operation of CFB mode is depicted in the following
illustration. For example, in the present system, a message
block has a size ‘s’ bits where 1 < s < n. The CFB mode
requires an initialization vector (IV) as the initial random n-bit
input block. The IV need not be secret. Steps of operation are −
o Load the IV in the top register.
o Encrypt the data value in top register with underlying block
cipher with key K.
o Take only ‘s’ number of most significant bits (left bits) of
output of encryption process and XOR them with ‘s’ bit
plaintext message block to generate ciphertext block.
o Feed ciphertext block into top register by shifting already
present data to the left and continue the operation till all
plaintext blocks are processed.
o Essentially, the previous ciphertext block is encrypted with the
key, and then the result is XORed to the current plaintext block.
o Similar steps are followed for decryption. Pre-decided IV is
initially loaded at the start of decryption.

Analysis of CFB Mode


o CFB mode differs significantly from ECB mode, the
ciphertext corresponding to a given plaintext block depends
not just on that plaintext block and the key, but also on the
previous ciphertext block. In other words, the ciphertext
block is dependent of message.
o CFB has a very strange feature. In this mode, user decrypts
the ciphertext using only the encryption process of the
block cipher. The decryption algorithm of the underlying
block cipher is never used.
o Apparently, CFB mode is converting a block cipher into a
type of stream cipher. The encryption algorithm is used as
a key-stream generator to produce key-stream that is placed
in the bottom register. This key stream is then XORed with
the plaintext as in case of stream cipher.
o By converting a block cipher into a stream cipher, CFB
mode provides some of the advantageous properties of a
stream cipher while retaining the advantageous properties
of a block cipher.
o On the flip side, the error of transmission gets propagated
due to changing of blocks.

 OUTPUT FEEDBACK MODE


 It involves feeding the successive output blocks from the underlying
block cipher back to it. These feedback blocks provide string of bits to
feed the encryption algorithm which act as the key-stream generator as
in case of CFB mode.
 The key stream generated is XOR-ed with the plaintext blocks. The
OFB mode requires an IV as the initial random n-bit input block. The
IV need not be secret.
 The operation is depicted in the following illustration −

 COUNTER MODE(CTR)
o It can be considered as a counter-based version of CFB mode
without the feedback.
o In this mode, both the sender and receiver need to access to a
reliable counter, which computes a new shared value each time
a ciphertext block is exchanged.
o This shared counter is not necessarily a secret value, but
challenge is that both sides must keep the counter synchronized.
Operation
Both encryption and decryption in CTR mode are depicted in
the following illustration. Steps in operation are −
 Load the initial counter value in the top register is the same for
both the sender and the receiver. It plays the same role as the IV
in CFB (and CBC) mode.
 Encrypt the contents of the counter with the key and place the
result in the bottom register.
 Take the first plaintext block P1 and XOR this to the contents of
the bottom register. The result of this is C1. Send C1 to the
receiver and update the counter. The counter update replaces the
ciphertext feedback in CFB mode.
 Continue in this manner until the last plaintext block has been
encrypted.
 The decryption is the reverse process. The ciphertext block is
XORed with the output of encrypted contents of counter value.
After decryption of each ciphertext block counter is updated as
in case of encryption.
Analysis of Counter Mode
 It does not have message dependency and hence a
ciphertext block does not depend on the previous
plaintext blocks.
 Like CFB mode, CTR mode does not involve the
decryption process of the block cipher. This is because
the CTR mode is really using the block cipher to
generate a key-stream, which is encrypted using the
XOR function. In other words, CTR mode also
converts a block cipher to a stream cipher.
 The serious disadvantage of CTR mode is that it
requires a synchronous counter at sender and receiver.
Loss of synchronization leads to incorrect recovery of
plaintext.
NOTE
 Since Ciphers are used in Symmetric Key
Cryptography, we are not discussing about
Asymmetric Key Algorithms in this PPT.

THANK YOU
BY
B. Srinivasa sai

You might also like