Professional Documents
Culture Documents
Ciphers and Its Types
Ciphers and Its Types
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
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.
IMPLEMENTATION
IMPLEMENTATION
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
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:
CHDS ANBA DRAH ASCR
HIKS LAFC
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.
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.
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