Unit No - 2 - Cryptography
Unit No - 2 - Cryptography
Unit No - 2 - Cryptography
Cryptography
• In today’s age of computers cryptography is often associated with the two process i.e.
Encryption : plain text is converted to cipher text and hence this process is known as encryption.
Decryption: The process of conversion of cipher text to plain text this is known as decryption.
Features Of Cryptography are as follows:
1. Confidentiality:
• The principle specifies that only the sender and receiver will be able to access the information
shared between them.
• Confidentiality is important to protect sensitive information from being disclosed to unauthorized
parties. This includes protecting data at rest, in transit, and in use.
• Common techniques used to maintain confidentiality include encryption, access controls, and data
masking.
• 2. Integrity:
• is important to ensure that information has not been tampered with or modified in an unauthorized
way.
• Integrity gives the assurance that the information received is exact and accurate.
• If the content of the message is changed after the sender sends it but before reaching the intended
receiver, then it is said that the integrity of the message is lost.
• This includes protecting data from unauthorized modification, deletion or addition.
• Common techniques used to maintain integrity include digital signatures, message authentication
codes, and data hashing.
3. Availability:
• Is important to ensure that information and systems are accessible to authorized users when they
need them.
• Common techniques used to maintain availability include load balancing, redundancy, and disaster
recovery planning.
4. Authentication:
• Authentication is the mechanism to identify the user or system or the entity.
• Is important to ensure that information and communication come from a trusted source.
• This includes protecting against impersonation, spoofing and other types of identity fraud.
• Common techniques used to establish authenticity include authentication, digital certificates, and
biometric identification.
5. Non-repudiation:
• Non-repudiation is important to ensure that a party cannot deny having sent or received a message
or transaction.
• In some cases the sender sends the message and later denies it. But the non-repudiation does not
allow the sender to refuse the receiver.
• This includes protecting against message tampering and replay attacks.
• Common techniques used to establish non-repudiation include digital signatures, message
authentication codes and timestamps.
• The Symmetric Cipher Model:
• 3. Encryption Algorithm (E): It takes the plain text and the secret key as inputs and
produces Cipher Text as output.
• It implies several techniques such as substitutions and transformations on the plain
text using the secret key.
• 4. Cipher Text (y): It is the formatted form of the plain text (x) which is
unreadable for humans.
• 1. Encryption Algorithm: There is a need for a very strong encryption algorithm that produces cipher
texts in such a way that the attacker should be unable to crack the secret key even if they have access to
one or more cipher texts.
• 2. Secure way to share Secret Key: There must be a secure and robust way to share the secret key
between the sender and the receiver. It should be leakproof so that the attacker cannot access the
secret key.
Encryption Techniques:
• There are Two Encryption Techniques:
• 1. Substitution Technique
• 2. Transposition Technique:
• 1. Substitution Technique:
• Substitution technique is a classical encryption technique where the characters
present in the original message are replaced by the other characters or numbers or
by symbols.
• If the plain text (original message) is considered as the string of bits, then the
substitution technique would replace bit pattern of plain text with the bit pattern of
cipher text.
• There are different types of Substitution Techniques are as follows:
1. Caesar Cipher
2. Monoalphabetic Cipher
3. Playfair Cipher
4. Hill Cipher
5. Polyalphabetic Cipher
6. One-Time Pad
1. Caeser Cipher:
• It is one of the technique in which , the letters of the plain text are replaced by other
letters.
• In this substitution technique, to encrypt the plain text, each alphabet of the plain text is
replaced by the alphabet three places further it.
• And to decrypt the cipher text each alphabet of cipher text is replaced by the alphabet
three places before it.
• Let us take a simple example:
• Look at the example above, we have replaced, ‘m’ with ‘p’ which occur three
places after, ‘m’. Similarly, ‘e’ is replaced with ‘h’ which occurs in three places
after ‘e’.
2.Playfair - cipher
• Playfair cipher is a substitution cipher which involves a 5X5 matrix. Let us discuss
the technique of this Playfair cipher with the help of an example:
• Key: NETWORK
• Now, we have to convert this plain text to ciphertext using the given key. We will
discuss the further process in steps.
• 1. fill the table with the key alphabets.
• 3. If you have find any repeated letters, you have to write only once.and ignore the repetition.
• 4. so, now fill the box, with all the alphabets, which are not available in key.
• 5. This is 5*5 Matrix table, so we have to write only 25 letters, so, here one letter should be match
with another letter, we can match I/J in a single box.
• Steps to solve the example:
3. If pair of Plain text letters are in same row replace them with right most
letter.
4. If pair of Plain text letters are in same column then replace with downside
(Beneath ) Position.
5. If Plain text letters are in different row and column , then they replaced with the
diagonal Position.
• Plain Text: HELLO
• Key: NETWORK
• 4. Polyalphabetic Cipher:
• Polyalphabetic cipher is far more secure than a monoalphabetic cipher. As
monoalphabetic cipher maps a plain text symbol or alphabet to a ciphertext
symbol and uses the same ciphertext symbol wherever that plain text occurs in
the message.
• But polyalphabetic cipher, each time replaces the plain text with the different
ciphertext.
Transposition Techniques:
• In Transposition techniques, we will just rearrange the order of bits to provide the
security.
• In the transposition technique, the characters' identities are kept the same, but their
positions are altered to produce the ciphertext.
• A transposition cipher in cryptography is a type of encryption that scrambles the
locations of characters without altering the characters themselves.
• Transposition Techniques
• 1. Rail Fence Transposition cipher
• 2. Columnar or Row Transposition cipher
1. Rail Fence Cipher
• Now, to obtain the complete cipher text combine both the halves of cipher text and the complete
cipher text will be:
• Cipher Text: M E M T M R O E T E O O R W
2. Columnar or Row Transposition Technique:
• The columnar transposition cipher is more complex as compared to the rail fence. The steps to
obtain cipher text using this technique are as follow:
• Step 1: The plain text is written in the rectangular matrix of the initially defined size in a row by
row pattern.
• Step 2: To obtain the cipher text read the text written in a rectangular matrix column by column.
But you have to permute the order of column before reading it column by column. The obtained
message is the cipher text message.
• For example:
• Plain Text: WELCOME TO MY SESSION
• Key: 32451
3 2 4 5 1
W E L C O
M E T O M
Y S E S S
I O N X Y
Dummy Dummy
• Here we have to write cipher text (KEY) as lower column to higher column, Ascending order.
• Technical Defination:
• Cryptanalysis is used to break cryptographic security systems, and gain access
to the content of the encrypted messages , even if cryptographic key is unknown.
• 5. Brute-force attack: This attack involves trying every possible key until the correct
one is found.
• While this attack is simple to implement, it can be time-consuming and
computationally expensive, especially for longer keys.
• A man-in-the-middle (MITM) attack is a cyberattack in which a hacker
steals sensitive information by eavesdropping on communications
between two online targets such as a user and a web application.
Stream Cipher And Block Cipher:
• Stream Cipher:
• Stream cipher is used to convert plain text to cipher text.
• In this we take bit or 1 byte as a Plain text and then convert it into cipher text.
• A stream cipher encrypts text by applying a key and algorithm to each bit of a data stream one by
one.
• It is Symmetric key cipher Means here we use only one key for Encryption or Decryption Process.
• Stream ciphers are mainly used to encrypt one byte (8 bits) at a time.
• Generally , Key is in the form of bits.
1) Encryption
• For Encryption,
• Plain Text and Key produces Cipher Text (Same key will be used for decryption.).
• The Plaintext will undergo XOR operation with keystream bit-by-bit and produces the Cipher Text.
• Cipher Text and Key gives the original Plain Text (Same key will be used for
encryption.).
• The Ciphertext will undergo XOR operation with key bit-by-bit and produces the actual
Plain Text.
• Example:
• Keystream : 01010101
• Plain Text : 10110110
Block Cipher:
• Block cipher is an encryption method which divides the plain text into blocks of
fixed size.
• A block cipher creates a ciphertext the same size by operating on fixed-size input
blocks made up of b bits.
• Key will be applied in each blocks.
• Each block has an equal number of bits.
• Data Encryption Standard (DES) is the best example of Block Cipher.
Advantages of Stream Ciphers:
• Advantages of Stream Ciphers:
• Stream ciphers have many advantages, such as:
• Speed: Generally, this type of encryption is quicker than others, such as block ciphers.
• Low complexity: Stream ciphers are simple to implement into contemporary software, and
developers don’t require sophisticated hardware to do so.
• Sequential in nature: Certain companies handle communications written in a continuous manner.
Stream ciphers enable them to transmit data when it’s ready instead of waiting for everything to be
finished because of their bit-by-bit processing.
• Accessibility: Using symmetrical encryption methods like stream ciphers saves businesses from
having to deal with public and private keys. Additionally, computers are able to select the
appropriate decryption key to utilize thanks to mathematical concepts behind current stream
ciphers.
Disadvantages of Stream cipher:
• Disadvantages of Stream Ciphers
• If an error occurs during transmission, it can affect subsequent bits, potentially
corrupting the entire message because stream ciphers rely on previously stored cipher
bits for decryption
• Maintaining and properly distributing keys to stream ciphers can be difficult,
especially in large systems or networks.
• Some stream ciphers may be predictable or vulnerable to attack if their key stream is
not properly designed, potentially compromising the security of the encrypted data.
Data Encryption Standard:
• The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National
Institute of Standards and Technology (NIST).
• DES is an implementation of a Feistel Cipher.
• DES is a block cipher and encrypts data in blocks of size of 64 bits each, which means 64 bits of plain
text go as the input to DES, which produces 64 bits of ciphertext.
• The same algorithm and key are used for encryption and decryption, with minor differences. The key
length is 56 bits.
• DES has an effective key length of 56 bits, since 8 of the 64 bits of the key are not used by the
encryption algorithm (function as check bits only).
• DES is based on the two fundamental attributes of cryptography:
• substitution (also called confusion) and transposition (also called diffusion).
• DES consists of 16 steps, each of which is called a round.
• Each round performs the steps of substitution and transposition.
For Example:
• We have mentioned that DES uses a 56-bit key.
• Actually, The initial key consists of 64 bits.
• However, before the DES process even starts, every 8th bit of the key is discarded to produce a
56-bit key.
• That is bit positions 8, 16, 24, 32, 40, 48, 56, and 64 are discarded.
• Overview of DES:
• In the first step, the 64-bit plain text block is handed over to an initial Permutation (IP) function.
• The initial permutation is performed on plain text.
• Next, the initial permutation (IP) produces two halves of the permuted block; saying Left Plain
Text (LPT) and Right Plain Text (RPT).
• Now each LPT and RPT go through 16 rounds of the encryption process.
• In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed on the combined
block
• The result of this process produces 64-bit ciphertext.
Diffie Hellman Key Exchange Algorithm:
4. Other applications −
• The Diffie-Hellman key exchange is also used in many other applications where secure
communication is required, such as secure email, secure web browsing, and secure voice over IP
(VoIP).
• It is a flexible and widely supported technique for establishing secure communication channels.
Thank You !