Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CNS Unit-1.2 Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

P.Srinivasulu, CSE, PBRVITS.

Cryptography and Network Security

Cryptography Basics
Introduction: -
Cryptography is the art of achieving security by encoding messages to make them non-readable.
The Conceptual view of Cryptography is shown below:

Cryptanalysis is the technique of decoding messages from a non-readable format back to a


readable format without knowing how they were initially converted from readable format to
nonreadable format.
it is like breaking a code, the Conceptual view of Cryptanalysis is shown below:

Cryptology is a combination of cryptography and cryptanalysis. The Conceptual view of


Cryptology is shown below:

Plain Text and Cipher Text


Introduction: -
Any communication in the language that we speak the form of plain text or clear text.
That is, a message in plain text can be understood by anybody knowing the language as long as the
message is not codified in any manner.
Ex: “Hai, Every One”

we also use plain text during electronic conversations. For instance, when we send an email to
someone, we compose the email message using English.

Elements of a cryptographic operation:-


How we can use Plain Text and Cipher Text can be used in real time communication can be
represented by the following diagram

1
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

.
Clear text, or plain text, signifies a message that can be understood by the sender, the
recipient, and also by anyone else who gets access to that message.
Cipher text is unreadable text message obtained after transforming plain text by applying
Encryption process.
Classical Encryption Techniques: There are two primary ways in which a plain-text
message can be codified to obtain the corresponding cipher text: substitution Cipher Techniques
and transposition Cipher Techniques.
Note that when the two approaches are used together, we call the technique product cipher.

Example:-
Resulting cipher text by using the alphabet-replacing scheme is shown below:

Thus, using the scheme of replacing each alphabet with the one that is three places down the line, a
message “I love you” shall become “L ORYH BRX” as shown below:

2
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Substitution Cipher Techniques


Introduction: -
In the substitution-cipher technique, the characters of a plain-text message are replaced by other
characters, numbers or symbols.
There are many Examples for Substitution Cipher Techniques, some of them are shown below:
1) Caesar Cipher
2) Mono-alphabetic Cipher
3) Homophonic Substitution Cipher
4) Polygram Substitution Cipher
5) Polyalphabetic Substitution Cipher
6) Playfair Cipher
7) Hill Cipher
1) Caesar Cipher: -
It was the first example of substitution Cipher which each alphabet in a message is replaced by an
alphabet three places down the line.
It was as first proposed by Julius Caesar, and is termed Caesar cipher
Algorithm:
Step1:
Assign a numerical equivalent number to each letter as shown below:

Step2:
In Encryption process, for each plaintext letter p, substitute the ciphertext letter c with the
following calculation:
c = E(3,p) = (p+3) mod 26
A shift may be of any amount, so that the general Caesar algorithm is
c = E(k,p) = (p + k) mod 26
where k takes on a value in the range 1 to 25.
The decryption process is simply
p = D(k,c) = (c- k) mod 26
Example: -
Question: Convert the plain text ‘i Love You” to Cipher Text using Caesar Cipher method

Solution:

Therefore, message “I love you” shall become “L ORYH BRX” after encryption.
3
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

The major weakness of the Caesar cipher is its predictability. Once we decide to replace an alphabet
in a plain-text message with an alphabet that is k positions up or down the order, we replace all
other alphabets in the plain-text message with the same technique. Thus, the cryptanalyst has to try
out a maximum of 25 possible attacks, and he/she is assured of success.

2) Mono-alphabetic Cipher: -
In this method, we use random substitution for all the alphabets in a given plain-text message, we
decide to.
This means that in a given plain-text message, each A can be replaced by any other alphabet (B
through Z), each B can also be replaced by any other random alphabet (A or C through Z), and so
on.
Here, there is no relation between the replacement of B and replacement of A. That is, if we have
decided to replace each A with D, we need not necessarily replace each B with E—we can replace
each B with any other character!
Mono-alphabetic ciphers pose a difficult problem for a cryptanalyst because it can be very difficult
to crack.
Example:

3) Homophonic Substitution Cipher: -


The homophonic substitution cipher is very similar to mono-alphabetic cipher. Like a plain
substitution cipher technique, we replace one alphabet with another randomly.
However, In the case of homophonic substitution cipher, one plain-text alphabet can map to
more than one cipher-text alphabet.
For instance, A can be replaced by D, H, P, R;
B can be replaced by E, I, Q, S, etc.
Homophonic substitution cipher also involves substitution of one plain-text character with a
cipher-text character at a time, however the cipher-text character can be any one of the chosen
set.
Example:-
Question: Convert the plain text “abba” int cipher text using homophonic substitution method?
Solution: DEIH
4
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

4) Polygram Substitution Cipher:-


In the polygram substitution cipher technique, rather than replacing one plain-text alphabet with
one cipher text alphabet at a time randomly, a block of alphabets is replaced with another block
randomly.
For instance, HELLO could be replaced by YUQQW,
but HELL could be replaced by a totally different cipher text block TEUI, as shown below:

Here, the replacement of plain text happens block by block, rather than character by character.
Polygram substitution cipher technique replaces one block of plain text with another block of
cipher text.

5) Polyalphabetic Substitution Cipher:-


This cipher uses multiple one-character keys. Each of the keys encrypts one plain-text
character. The first key encrypts the first plain-text character; the second key encrypts the second
plain-text character, and so on. After all the keys are used, they are recycled.
Thus, if we have 9 one-letter keys, and plaintext size is more than the Key, then from 10th character
on wards same key is repeated for processing. This number (i.e. 9) is called the period of the
cipher.
Encryption process is shown below:
c = (p + k) mod 26
Decryption process is shown below:
p = (c- k) mod 26
The Vigenére cipher and the Beaufort cipher are examples of polyalphabetic substitution cipher.

Example:

Question:
Convert the plain text “we are discovered save yourself” into cipher text using Polyalphabetic
substitution Cipher, use the key as “deceptive”
Solution:
Consider the key and plaintext given and prepare as follows:

key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself

The conversion process is shown below:


5
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

6
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

7
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

6) Playfair Cipher:-
The Playfair cipher, also called Playfair square, is a cryptographic technique used for manual
encryption of data.
The Playfair cipher was used by the British army in World War I and by the Australians in World
War II. This was possible because the Playfair cipher is quite fast to use and does not demand any
special equipment to be used.
It was used to protect important but not very critical information.
The Playfair encryption scheme uses two main processes, as shown below:

Step 1: Creation and Population of Matrix


The Playfair cipher makes use of a 5 x 5 matrix (table), which is used to store a keyword or phrase
that becomes the key for encryption and decryption. The way this is entered into the 5 x 5 matrix is
based on some simple rules, as shown below:

Example:
Constructing 5 x 5 matrix using the Keyword “Monarchy”

8
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Step 2: Encryption Process


The Encryption process consists of fine steps as shown below:
1. Break down the plain text message into groups of two alphabets. For Example, if the given
message is “attack”, it becomes at ta ck. The Encryption process works on this broken-
down message.
2. If both alphabets are the same (or only one is left), add an X character after the first
alphabet. Encrypt the new pair and continue.
3. If both the alphabets in the pair appear in the same row of our matrix, replace them with
alphabets immediately below them respectively. If the original pair is on the right side of the
row, then wrapping around to the left side of the row happens.
4. If both alphabets in the pair in the same column of our matrix, replace them with alphabets
immediately below them respectively. If the original pair is on the bottom side of the row,
then wrapping around to the top side of the row happens.
5. If the alphabets are not in the same row or column, replace them with the alphabets in the
same row respectively, but at the other pair of corners of the rectangle defined by the
original pair.

Decryption process works in the opposite direction.


We also need to remove the extra X alphabets if added during Encryption process.
Example:
Question:
Convert the plain text “attack” into Cipher Text using Playfair Cipher Technique,
(use the key “Monarchy”)
9
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Solution:

10
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

The Cipher Text generated is: RSSRDE


11
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

7) Hill Cipher:-
The Hill cipher works on multiple letters at the same time. Hence, it is a type of polygraphic
substitution cipher. The Hill cipher has its roots in the matrix theory of mathematics.
The way the Hill cipher works is as shown below:

12
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

13
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Example:

14
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Therefore, the Cipher Text generated is shown below:

15
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Transposition Cipher Techniques


Introduction: -
In the Transposition-Cipher technique, some permutations are applied over the plain text
characters of a plain-text message to generate Cipher Text.
There are many Examples for Transposition-Cipher Techniques, some of them are shown below:
1) Rail-Fence Technique
2) Simple Columnar Transposition Technique
3) Vernam Cipher (One-Time Pad)
4) Book Cipher/Running-Key Cipher

1) Rail-Fence Technique
The rail-fence technique is an example of transposition. It uses a simple algorithm as shown below:

Rail-fence technique involves writing plain text as a sequence of diagonals and then reading it
row by row to produce cipher text.
Let us illustrate the rail-fence technique with a simple example. Suppose that we have a plain-text
message: Come home tomorrow. How would we transform that into a cipher-text message using
the rail-fence technique? This is shown below:

2) Simple Columnar Transposition Technique :-


Steps involved in simple columnar transposition technique are shown below:

Example:
Consider the plaintext message ‘Come home tomorrow’. Let us understand how it can be
transformed into cipher text using this technique. This is illustrated below:
16
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

3) Vernam Cipher (One-Time Pad):-


Steps involved in Vernam Cipher technique are shown below:

Example:
Convert plain-text message HOW ARE YOU using a one-time pad NCBTZQARX

17
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Here, cipher-text message generated is UQXTRUYFR.


Vernam Cipher uses a one-time pad, which is discarded after a single use, and therefore, it is
suitable only for short messages.

4) Book Cipher/Running-Key Cipher


The idea used in book cipher, also incorrectly called running-key cipher, is quite simple, and is
similar in principle to the Vernam cipher.

For producing cipher text, some portion of text from a book is used, which serves the purpose of a
one-time pad. Thus, the characters from a book are used as onetime pad, and they are added to the
input plain-text message similar to the way a one-time pad works.

18
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Encryption and Decryption


Introduction: -
In technical terms, Encryption is the process of encoding plaintext messages into cipher text
messages.

Decryption is the process of transforming cipher-text messages back to plain text messages

Encryption transforms a plain-text message into cipher text, whereas decryption transforms a
cipher text message back into plain text. Decryption is exactly the opposite of encryption.

Encryption and decryption in the real world :-


In computer-to-computer communications, the computer at the sender’s end usually transforms a
plaintext message into ciphertext by performing encryption.

The encrypted cipher-text message is then sent to the receiver over a network (such as the
Internet, although it can be any other network).

The receiver’s computer then takes the encrypted message, and performs the reverse of
encryption, i.e. it performs the decryption process to obtain the original plain-text message. This is
shown below:

To encrypt a plain-text message, the sender (the sender’s computer) performs encryption by
applying the encryption algorithm.
To decrypt a received encrypted message, the recipient performs decryption by applying the
decryption algorithm.

Every encryption and decryption process has two aspects:


the algorithm and the key used for encryption and decryption.
19
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Symmetric and Asymmetric Key Cryptography


Introduction: -
Broadly, there are two cryptographic mechanisms/techniques, depending on what keys
are used.
-Symmetric Key Cryptography
-Asymmetric Key Cryptography
If the same key is used for encryption and decryption, then the mechanism is called as Symmetric
Key Cryptography.
If two different keys are used in a cryptographic mechanism, wherein one key is used for
encryption, and another, different key is used for decryption; then the mechanism is called as
Asymmetric Key Cryptography.

Symmetric Key Cryptography:-


Symmetric encryption involves the use of a Single Secret Key for both the encryption and
decryption of the Message.
Only symmetric encryption has the speed and computational efficiency to handle encryption of large
volumes of data.
It’s block diagram is shown below:

Example Techniques of Symmetric Key Encryption include the following:


DES – Data Encryption Standard
AES – Advanced Encryption Standard
etc.

20
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Asymmetric Key Cryptography:-


Asymmetric encryption involves the use of two keys, one for the Encryption and other for
Decryption of the message.

In this scenario, the key used for Encryption is called Public Key, and the Key used for Decryption
is called as Private Key or Secrete Key.

It’s block diagram is shown below:

That means, Asymmetric encryption uses a pair of Keys (k1 and k2) one for Encryption and the
other for Decryption.

Example Techniques of Asymmetric Key Encryption include the following:


RSA,
Elliptic Curve Cryptography Encryption
etc.

21
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Key Range and Key Size


Introduction: -
We are using Encryption to maintain Confidentiality during message transmission.
However, the Encrypted Message can also be attacked.
The encryption/decryption algorithm is usually not a secret, some body can guess it or knows about
it. Also, one can access an encrypted message by various means such as by listening to the flow of
information over a network.
Thus, only the actual key value remains a challenge for the attacker. If the key is found, the
attacker can resolve the mystery by working backwards to the original plain-text message, as shown
below: (e.g. the value of the key is a number between 0 and 100 billion)

This is called as brute-force attack, which works on the principle of trying every possible key in the
key range, until you get the right key.
To find the key, he attacker can write a computer program that tries many such keys in one
second. In the best case, the attacker finds the right key in few attempts, or in the worst case, it is
the 100 billionth attempt.
22
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

As shown in diagram, when the attacker notices that the decryption has yielded unintelligent plain
text, he continues the process with the next key in the sequence. Finally, he is able to find the plain
text “To: Payroll”

How does the attacker determine if the plain text, and therefore the key, are the right ones?
This can be determined depending on the value of the plain text. If the plain text seems reasonable
(i.e. very close to actual English words/sentences/numbers that make sense), it is highly probable
that the plain text is indeed what corresponds to the cipher text.

How can we prevent an attacker from succeeding in such attempts?


The solution to our problem lies in increasing the key range to a size, which requires the
attacker to work for more than year in order to crack the key.

Key Range and Key Size:-


In computer terms, the concept of key range leads us to the principle of key size. we measure the
strength of a cryptographic key is with key size.

We measure key size in bits, and represent it using the binary number system. Thus, our key
might be of 40 bits, 56 bits, 128 bits, and so on.

In order to protect ourselves against a brute-force attack, the key size should be such that the
attacker cannot crack it within a specified amount of time.

Example: If the key size can be just 2 bits.


Then the possible key values are 00, 01, 10, 11.
The Key Range is from 00 to 11

Clearly, we can assume with reasonable confidence that a 128-bit key is quite safe.

23
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Possible Types of Attacks.


Introduction: -
when the sender of a message encrypts a plain-text message into its corresponding cipher text, there
are five possibilities for an attack on this message, as shown below:

1)Cipher-Text Only Attack:-


In this type of attack, the attacker does not have any clue about the plain text. She has some
or all of the cipher texts.
The attacker analyzes the cipher text at leisure to try and figure out the original plain text. Based on
the frequency of letters (e.g. the alphabets e, i, a are very common in English, etc.) the attacker
makes an attempt to guess the plain text, this is shown below:

We have mentioned that for this attack to succeed, the attacker should have access to sufficient
amount of cipher text.

24
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

The reason behind this is simple.


For instance, if the attacker has cipher text available as ABC and knows that the encryption
algorithm used was Monoalphabetic cipher, he should try various possibilities to get the correct
plain text. Because, there are so many three-letter words in English that could correspond to this
cipher text. Does this cipher text map to CAT, RAT, MAT, SHE, ARE, …?

2)Known Plain-Text Attack:-


In this case, the attacker knows about some pairs of plain text and corresponding cipher text
for those pairs.
Using this information, the attacker tries to crack upcoming messages by finding Encryption patten.
How can the attacker obtain the plain text, in the first place? This can happen because plain-text
information may become outdated over time, and hence, become public knowledge. Alternatively,
it could be leaked inadvertently.

3)Chosen Plain-Text Attack:-


Here, the attacker selects a plain-text block, and tries to look for the encryption of the same to
generate cipher text that will be compared with actual cipher text.
Based on this, the attacker intentionally picks patterns of cipher text that result in obtaining more
information about the key.
How is this possible? For example, a telegraph company may offer a paid service where they
encrypt people’s messages and send them to the desired recipient. The telegraph company on the
other side would decrypt the message and give the original message to the recipient.
Therefore, the attacker chooses some such plain text and pays the telegraph company to encrypt it.
The result of this is that the attacker now has access to some plain text that he had chosen, and its
corresponding cipher text.

4)Chosen Cipher-Text Attack:-


In this attack, the attacker knows the encryption algorithm, the corresponding plain-text
block, with some chosen Cipher-Text, he will try to find Key.
The attacker’s job is to discover the key used for encryption. However, this type of attack is not
very commonly used.

5)Chosen-Text Attack:-
The chosen-text attack is essentially a combination of chosen plain-text attack and chosen cipher-
text attack. This is shown below:

25
P.Srinivasulu, CSE, PBRVITS. Cryptography and Network Security

Steganography
Introduction: -
Steganography is a technique that facilitates hiding of a message that is to be kept secret inside
other message or image. This results in the concealment of the secret message itself!
Steganography is the practice of concealing a message within another message or a physical
object.
In computing/electronic contexts, a computer file, message, image, or video is concealed within
another file, message, image, or video.
The advantage of steganography over cryptography alone is that the intended secret message does
not attract attention to itself as an object for inspection.

Example1:
the hidden message may be in invisible ink between the visible lines of a private letter

Example2:
Suppose that we have a secret message to send. We can take another image file and we can
replace the last two rightmost bits of each byte of that image with (the next) two bits of our secret
message.
The resulting image would not look too different, and yet carry a secret message inside! The
receiver would perform the opposite trick: it would read the last two bits of each byte of the image
file, and reconstruct the secret message.

This concept is illustrated below:

Steganography software
Steganography software is used to perform a variety of functions in order to hide data, including
encoding the data in order to prepare it to be hidden inside another file, keeping track of which bits
of the cover text file contain hidden data, encrypting the data to be hidden and extracting hidden
data by its intended recipient.

Example:
 OpenStego is an open-source steganography program;

 Xiao Steganography, used to hide secret files in BMP images or WAV files

*********************************************

26

You might also like