0% found this document useful (0 votes)
23 views105 pages

Cryptography 1

Uploaded by

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

Cryptography 1

Uploaded by

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

CRYPTOGRAPHY Presented By:

Er.Lochan Raj Dahal


INTRODUCTION TO
CRYPTOGRAPHY
Cryptography is technique of securing information and communications
through use of codes so that only those person for whom the information is
intended can understand it and process it. Thus preventing unauthorized
access to information. The prefix “crypt” means “hidden” and suffix
graphy means “writing”. In Cryptography the techniques which are use to
protect information are obtained from mathematical concepts and a set of
rule based calculations known as algorithms to convert messages in ways
that make it hard to decode it. These algorithms are used for
cryptographic key generation, digital signing, verification to protect data
privacy, web browsing on internet and to protect confidential transactions
such as credit card and debit card transactions.
FEATURES OF CRYPTOGRAPHY
ARE AS FOLLOWS:
1. Confidentiality: Information can only be accessed by the person for
whom it is intended and no other person except him can access it.
2. Integrity: Information cannot be modified in storage or transition
between sender and intended receiver without any addition to
information being detected.
3. Non-repudiation: The creator/sender of information cannot deny his
intention to send information at later stage.
4. Authentication: The identities of sender and receiver are confirmed.
As well as destination/origin of information is confirmed.
TYPES OF
CRYPTOGRAPHY:
In general there are three types Of cryptography:
I. Symmetric Key Cryptography: It is an encryption system where the sender and
receiver of message use a single common key to encrypt and decrypt messages.
Symmetric Key Systems are faster and simpler but the problem is that sender and
receiver have to somehow exchange key in a secure manner. The most popular
symmetric key cryptography system is Data Encryption System(DES).
II. Hash Functions: There is no usage of any key in this algorithm. A hash value with
fixed length is calculated as per the plain text which makes it impossible for
contents of plain text to be recovered. Many operating systems use hash functions
to encrypt passwords.
III. Asymmetric Key Cryptography: Under this system a pair of keys is used to
encrypt and decrypt information. A public key is used for encryption and a private
key is used for decryption. Public key and Private Key are different. Even if the
public key is known by everyone the intended receiver can only decode it because
he alone knows the private key.
APPLICATIONS OF
CRYPTOGRAPHY:
1. Computer passwords: Cryptography is widely utilized in computer security, particularly when
creating and maintaining passwords. When a user logs in, their password is hashed and
compared to the hash that was previously stored. Passwords are hashed and encrypted before
being stored. In this technique, the passwords are encrypted so that even if a hacker gains
access to the password database, they cannot read the passwords.
2. Digital Currencies: To safeguard transactions and prevent fraud, digital currencies like Bitcoin
also use cryptography. Complex algorithms and cryptographic keys are used to safeguard
transactions, making it nearly hard to tamper with or forge the transactions.
3. Secure web browsing: Online browsing security is provided by the use of cryptography, which
shields users from eavesdropping and man-in-the-middle assaults. Public key cryptography is
used by the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols to encrypt
data sent between the web server and the client, establishing a secure channel for
communication.
4. Electronic signatures: Electronic signatures serve as the digital equivalent of a handwritten
signature and are used to sign documents. Digital signatures are created using cryptography
and can be validated using public key cryptography. In many nations, electronic signatures are
enforceable by law, and their use is expanding quickly.
APPLICATIONS OF
CRYPTOGRAPHY:
5. Authentication: Cryptography is used for authentication in many different
situations, such as when accessing a bank account, logging into a computer, or
using a secure network. Cryptographic methods are employed by authentication
protocols to confirm the user’s identity and confirm that they have the required
access rights to the resource.
6. Cryptocurrencies: Cryptography is heavily used by cryptocurrencies like Bitcoin
and Ethereum to safeguard transactions, thwart fraud, and maintain the network’s
integrity. Complex algorithms and cryptographic keys are used to safeguard
transactions, making it nearly hard to tamper with or forge the transactions.
7. End-to-End Encryption: End-to-end encryption is used to protect two-way
communications like video conversations, instant messages, and email. Even if the
message is encrypted, it assures that only the intended receivers can read the
message. End-to-end encryption is widely used in communication apps like
WhatsApp and Signal, and it provides a high level of security and privacy for users.
ADVANTAGES
1. Access Control: Cryptography can be used for access control to ensure
that only parties with the proper permissions have access to a resource.
Only those with the correct decryption key can access the resource
thanks to encryption.
2. Secure Communication: For secure online communication,
cryptography is crucial. It offers secure mechanisms for transmitting
private information like passwords, bank account numbers, and other
sensitive data over the internet.
3. Protection against attacks: Cryptography aids in the defense against
various types of assaults, including replay and man-in-the-middle attacks.
It offers strategies for spotting and stopping these assaults.
4. Compliance with legal requirements: Cryptography can assist firms in
meeting a variety of legal requirements, including data protection and
WHAT IS PRIVATE KEY
CRYPTOGRAPHY?
Private key encryption is the original type of encryption. Dating back to the
advent of cryptography, private key cryptosystems were the first and
continue to be the most common. When using private key cryptography,
both parties much each possess, or at least exchange the private key. The
word “key” can be a bit misleading — the key itself is really just the cipher
that’s used to scramble and unscramble the data being encrypted.
With an ancient cipher, like the Caesar cipher, the private key was simply a
number that corresponded to the number each alphabetical character
needed to be shifted. In current digital encryption schemes, the keys are
now prohibitively difficult algorithms that no modern computer could ever
efficiently crack.
The one thing that remains the same with all private key systems is that the
same key can both encrypt and decrypt. Private key encryption is
sometimes called symmetric encryption.
WHAT IS PRIVATE KEY
CRYPTOGRAPHY USED FOR?
Public key cryptography, in the context of SSL/TLS, is used for the
actual communication portion of the connection. Each party derives
the key during the handshake and then uses it to both encrypt and
decrypt all data that’s transmitted between them.
Private key encryption, or symmetric encryption, uses smaller keys
that are easier to compute with. These still provide adequate
computational hardness, but don’t tax the client and server as
much to use. Especially at scale, this is extremely important and
the biggest advantage of symmetric encryption.
WHAT IS PUBLIC KEY
CRYPTOGRAPHY?
Public key cryptography is actually a fairly recent creation, dating back to 1973, it uses
a public/private key pair. The keys are asymmetric, the public key is actually derived
from the private key. It can be used to encrypt while the private key can be used to
decrypt. The public key is also capable of verifying signatures left by the private key.
Public/Private key pairs are generally much larger than their symmetric counterparts.
That’s because public key cryptography is kind of like the gatekeeper, it needs to be
sufficiently robust to protect the website and the connections it’s making. Public key
cryptography is primarily used for two things:
Authentication
Key Exchange

These are both performed during the handshake. They’re critical functions. A large key
makes it harder to manipulate these functions. Once the public key cryptography is
done the two parties have authenticated and exchanged keys. Now it’s simply a matter
of actually communicating. The size of the key, though still plenty secure, can be
reduced to increase performance.
WHAT IS PUBLIC KEY
CRYPTOGRAPHY USED FOR?
As we just covered it handles authentication and key exchange. Public key
cryptography was first developed as a mechanism to securely exchange
an encryption key via an insecure channel. The first guys to nail it were
Whitfield Diffie and Martin Hellman (with an assist from Ralph Merkle) —
they created the eponymous Diffie-Hellman key exchange scheme.
Diffie-Hellman lacked authentication, though, and Ron Rivest, Adi Shamir
and Leonard Adleman figured if you’re going to send an encryption key to
someone, it might be good to make sure you know who that someone is.
Thus, the birth of RSA, which could both securely pass the key and
authenticate the entity it was passing it to.
Diffie-Hellman was later paired with digital signature algorithm (DSA) to
create a key exchange/authentication combination — a variant of which
has now replaced RSA in TLS 1.3.
VIGENERE CIPHER
 The vigenere cipher is an algorithm that is used to encrypting and
decrypting the text. The vigenere cipher is an algorithm of encrypting an
alphabetic text that uses a series of interwoven caesar ciphers. It is
based on a keyword's letters. It is an example of a polyalphabetic
substitution cipher. This algorithm is easy to understand and implement.
This algorithm was first described in 1553 by Giovan Battista Bellaso.
It uses a Vigenere table or Vigenere square for encryption and decryption
of the text. The vigenere table is also called the tabula recta.
 Two methods perform the vigenere cipher.
METHOD 1
When the vigenere table is given, the encryption and decryption are done
using the vigenere table (26 * 26 matrix) in this method.

Example: The plaintext is


"JAVATPOINT", and the key is "BEST".
To generate a new key, the given key is
repeated in a circular manner, as long as the
length of the plain text does not equal to the
new key.
Encryption
The first letter of the plaintext is combined with the first letter of the key. The column of plain text "J"
and row of key "B" intersects the alphabet of "K" in the vigenere table, so the first letter of ciphertext
is "K".
Similarly, the second letter of the plaintext is combined with the second letter of the key. The column
of plain text "A" and row of key "E" intersects the alphabet of "E" in the vigenere table, so the second
letter of ciphertext is "E".
This process continues continuously until the plaintext is finished.
Ciphertext = KENTUTGBOX
Decryption
Decryption is done by the row of keys in the vigenere table. First, select the row of the key letter, find
the ciphertext letter's position in that row, and then select the column label of the corresponding
ciphertext as the plaintext.
For example, in the row of the key is "B" and the ciphertext is "K" and this ciphertext letter appears
in the column "J", that means the first plaintext letter is "J".
Next, in the row of the key is "E" and the ciphertext is "E" and this ciphertext letter appears in the
column "A", that means the second plaintext letter is "A".
This process continues continuously until the ciphertext is finished.
Plaintext = JAVATPOINT
METHOD 2
When the vigenere table is not given, the encryption and decryption are done by Vigenar
algebraically formula in this method (convert the letters (A-Z) into the numbers (0-25)).
Formula of encryption is,
Ei = (Pi + Ki) mod 26
Formula of decryption is,
Di = (Ei - Ki) mod 26
If any case (Di) value becomes negative (-ve), in this case, we will add 26 in the negative
value.
Where,
E denotes the encryption.
D denotes the decryption.
P denotes the plaintext.
K denotes the key.
Example: The plaintext is "JAVATPOINT", and the key is "BEST".
Plaintext J A V A T P O I N T
Encryption: Ei = (Pi + Ki) modPlaintext
26 value 09 00 21 00 19 15 14 08 13 19
(P)
Key B E S T B E S T B E
Key value (K) 01 04 18 19 01 04 18 19 01 04
Ciphertext 10 04 13 19 20 19 06 01 14 23
value (E)
Ciphertext K E N T U T G B O X

Decryption: Di = (Ei - Ki) mod 26


If any case (Di) value becomes negative (-ve), in this case, we will add 26 in the negative
value. Like, the third letter of the Ciphertext
ciphertext;K E N T U T G B O X
Ciphertext 10 04 13 19 20 19 06 01 14 23
value (E)
N = 13 and S = 18
Key B E S T B E S T B E
Di = (Ei - Ki) mod 26 Key value (K) 01 04 18 19 01 04 18 19 01 04

Plaintext value 09 00 21 00 19 15 14 08 13 19
Di = (13 - 18) mod 26 (P)
Plaintext J A V A T P O I N T
Di = -5 mod 26
Di = (-5 + 26) mod 26
Di = 21
FEISTEL BLOCK CIPHER
 Feistel block cipher is a structure used to derive many symmetric block
ciphers such as DES.
 Feistel cipher proposed a structure which
implements substitution and permutation alternately to obtain cipher
text from the pain text and vice-versa.
 In the Feistel block cipher, each block has to undergo many rounds where
each round has the same function. In this context, we will discuss the
structure proposed by Feistel for developing the block ciphers.
WHAT IS FEISTEL CIPHER?
 Feistel cipher is a structure proposed by a Horst Feistel which was considered while
developing many symmetric block ciphers. Actually, the structure proposed by Feistel is
based on the Shannon structure which was proposed in 1945. The Shannon structure
shows the implementation of confusion and diffusion alternately.
 Confusion fabricates a complex relation between the cipher text and encryption
key by implementing a complex substitution algorithm. Whereas,
the diffusion fabricates a complex relation between plain text and cipher text by
implementing more complex permutation algorithm.
 The Shannon structure was successful in achieving a more complex block cipher and thus
confusion and diffusion were adopted by the Feistel structure.
 Feistel cipher proposed the structure that alternately implements substitution and
permutation. Substitution is implemented by replacing the elements of plain text or the
set of elements of plain text by the element of cipher text or set of elements of cipher text.
 A permutation is implemented by changing the order of elements of the plain text. No
element here is replaced by any other element, only the order of elements is changed.
Now, let us proceed towards the structure of Feistel cipher.
FEISTEL CIPHER STRUCTURE
To understand the Feistel cipher in a better
way observe the figure below:
Step 1: The plain text is divided into the
blocks of a fixed size and only one block
is processed at a time. So, the input to
encryption algorithm is a plain text block
and a key K.
Step 2: The plain text block is divided into two
equal halves which we will denote as
a LE0 as the left half of the plain text
block and RE0 as the right half of the
plain text block. Now, both these halves
of the plain text block (LE0 & RE0)
undergoes multiple rounds to produce
ciphertext block.
FEISTEL CIPHER STRUCTURE
 In each round, the encryption function is applied on the right half REi of the
plaintext block along with the key Ki. The result of this encryption function is
then XORed with the left half LEi. The result of XOR function becomes the new
right half for next round REi+1. Whereas, the old right half REi becomes the new
left half LEi+1 for the next round as you can see in the figure above.
 Each round executes the same function. In each round initially,
a substitution function is implemented by applying the round function or the
encryption function on the right half of the plain text block. The result of this
round function is XORed by the with the left half of the block. After this
substitution function, a permutation function is implemented by swapping
the two halves and the result of this permutation is provided to the next round.
 This is how Feistel cipher structure presents the application of substitution and
permutation alternately which is similar to the Shannon structure.
FEISTEL CIPHER DESIGN
FEATURES
The design features of Feistel cipher that are considered while implementing any block cipher are as follow:
Block Size
The block cipher is considered more secure if the block size is larger. But the larger block size can reduce the execution
speed of encryption and decryption. Generally, the block size of a block cipher is of 64-bit. But, the modern-day block
cipher such as AES has 128-bit block size.
Key Size
The security of block cipher increases with the increasing key size. But the large key size may decrease the speed of
encryption and decryption. Earlier the key of 64-bit was considered to adequate. But the modern cipher uses a key of size
128-bit.
Number of rounds
The number of rounds also increases the security of the block cipher. More are the number of rounds more complex is the
cipher.
Subkey generation function
More the subkey generation function is complex, difficult it is for a cryptanalyst to crack it.
Round Function
Complex round function enhances the security of the block cipher.
Fast Software Encryption/Decryption
The block cipher is implemented in a software application to achieve better execution speed.
Easy Analysis
The block cipher algorithm should be easy to analyze because it would ease in analyzing the cryptanalytic weakness and
develop more strength in the algorithm.
FEISTEL DECRYPTION
ALGORITHM
Feistel Cipher structure does not have a different algorithm for decryption. The
encryption and decryption function proposed by Feistel cipher are same with
some rules which are as follows:
1. The input to the decryption algorithm is a cipher text block
produced by the encryption algorithm.
2. The sequence of subkeys used in encryption are reversed.
The key Kn is used in the first round of decryption, key Kn-
1 in the second round of decryption and so on, until the last
round occurs where key K1 is used.
FEISTEL DECRYPTION
ALGORITHM
To understand the structure of decryption, look at the figure
below:
As you can observe in the figure above the cipher text
block has two halves left half (LD0) and the right half (RD0).
Where LD0 = RE16 and RD0 = LE16.
Now as in encryption algorithm, the round function is
performed on the right half of cipher block with the key
K16 and the result of the round function is XORed with the
left half of the cipher text block.
The output of the XOR function is now considered as new
right half i.e.RD1 and the RD0 swaps with LD0 and becomes
the new left half LD1 for the next round.
Each round has the same function and after the fixed
number of rounds, the plain text block is obtained.

You might also like