Professional Documents
Culture Documents
UNIT1
UNIT1
UNIT1
Introduction:
This is the age of universal electronic connectivity, where the activities like
hacking, viruses, electronic fraud are very common. Unless security measures
are taken, a network conversation or a distributed application can be
compromised easily.
Network Security has been affected by two major developments over the last
several decades.
First one is introduction of computers into organizations and the second one
being introduction of distributed systems and the use of networks and
communication facilities for carrying data between users & computers. These
two developments lead to ‘computer security’ and ‘network security’, where the
computer security deals with collection of tools designed to protect data and to
thwart hackers. Network security measures are needed to protect data during
transmission. But keep in mind that, it is the information and our ability to
access that information that we are really trying to protect and not the
computers and networks
SECURITY GOALS
Confidentiality
Availability
ATTACKS
Snooping :
Snooping refers to unauthorized access to or interception of data. For example,
a file transferred through the Internet may contain confidential information. An
unauthorized entity may intercept the transmission and use the contents for her
own benefit. To prevent snooping, the data can be made nonintelligible to the
intercepter by using encipherment techniques.
Traffic Analysis
SECURITY MECHANISMS
One of the most specific security mechanisms in use is cryptographic techniques.
Encryption or encryption-like transformations of information are the most
common means of providing security. Some of the mechanisms are
1 Encipherment
2 Digital Signature
3 Access Control
SECURITY ATTACKS
There are four general categories of attack which are listed below.
Modification
An unauthorized party not only gains access to but tampers with an asset. This
is an attack on integrity. e.g., changing values in data file, altering a program,
modifying the contents of messages being transmitted in a network.
Eavesdropper or forger
Fabrication
Cryptographic Attacks
Passive Attacks
Passive attacks are very difficult to detect because they do not involve any
alteration of data. However, it is feasible to prevent the success of these attacks.
Active attacks
These attacks involve some modification of the data stream or the creation of a
false stream. These attacks can be classified in to four categories:
Basic Concepts
Cryptography The art or science encompassing the principles and methods of
transforming an intelligible message into one that is unintelligible, and then
retransforming that message back to its original form
Key Some critical information used by the cipher, known only to the sender&
receiver
Decipher (decode) the process of converting cipher text back into plaintext
using a cipher and a key
CRYPTOGRAPHY:
Cryptography
All the encryption algorithms are based on two general principles: substitution,
in which each element in the plaintext is mapped into another element, and
transposition, in which elements in the plaintext are rearranged.
If the sender and receiver uses same key then it is said to be symmetric key
(or)
If the sender and receiver use different keys then it is said to be public key
encryption.
Cryptanalysis
Cipher text only – A copy of cipher text alone is known to the cryptanalyst.
Known plaintext – The cryptanalyst has a copy of the cipher text and the
corresponding plaintext.
o Verify the sender's signature to be sure they are who they claim they are
o Email messages
o Web security
Symmetric key Cryptography: With the encryption technique, the sender and the
recipient use the same shared key to encrypt and decrypt messages.
Although symmetric key systems are quicker and easier to use, they have the
drawback of requiring a secure key exchange between the sender and the
receiver. Data Encryption System (DES) is the most widely used symmetric key
encryption method.
Hash Functions: In this algorithm, no key is used. The plain text is used to
produce a hash value that has a fixed length, making it challenging to retrieve
the plain text's information. Hash functions are widely used by operating
systems to encrypt passwords.
Features of Cryptography
o Confidentiality: The only person who can access information is the one it
is intended for, which is the primary feature of cryptography.
o Integrity: Information cannot be altered while it is being stored or sent
from the sender to the intended destination without the recipient spotting
the addition of new information in Cryptography.
o Non-repudiation: The creator/sender of a message cannot deny his
intent to send information at a future point.
o Authentication: The identities of the sender and the recipient have been
confirmed. Furthermore, the information's source and final destination are
confirmed.
o Availability: It also ensures that the required information is available to
authorized users at the appropriate time.
o Key Management: The creation, distribution, storage, and alteration of
cryptographic keys take place in this process.
o Algorithm: Mathematical formulae are used in cryptography to encrypt
and decrypt messages.
o Digital Signatures: A signature that can be applied to messages to
protect the message's authenticity and sender identification.
Encryption uses a cipher to encrypt and transform the plaintext into ciphertext.
On the other hand, decryption transforms the ciphertext into plaintext by
employing the same cipher.
Cryptographic Algorithms
A cipher suite uses three different algorithms: one for encryption, message
authentication, and key exchange. This process, integrated into protocols and
developed using software that runs on operating systems (OS) and networked
computer systems, involves:
o Data encryption and decryption using the production of public and private
keys
o To authenticate messages, use digital signature and verification
o Key exchange
Advantages
Applications of Cryptography
Digital signatures: Digital signatures are used to sign papers and act as the
handwritten signature's digital copy. Cryptography is used to create digital
signatures, and public key cryptography is used to verify them. Digital
signatures are becoming more widely used, and many countries have laws that
make them legally binding.
End-to-End Encryption: Email, instant messages, and video chats are all
examples of two-way communications protected by end-to-end encryption. Even
if a message is encrypted, this guarantees that only the intended recipients can
decode it. End-to-end encryption is frequently employed in messaging apps like
Whats App and Signal, offering users high protection and anonymity.
CLASSICAL ENCRYPTION TECHNIQUES
There are two basic building blocks of all encryption techniques: substitution and
transposition.
SUBSTITUTION TECHNIQUES
A substitution technique is one in which the letters of plaintext are replaced by
other letters or by numbers or symbols. If the plaintext is viewed as a sequence
of bits, then substitution involves replacing plaintext bit patterns with cipher text
bit patterns.
Caesar cipher (or) shift cipher
The earliest known use of a substitution cipher and the simplest was by Julius
Caesar. The
Caesar cipher involves replacing each letter of the alphabet with the letter
standing 3 places
further down the alphabet.
Special case of Substitution cipher is known as Caesar cipher where the
key is taken as 3.
Mathematical representation
For each plaintext letter p, substitute the cipher text letter c such that
C = E(p) = (p+3) mod 26
A shift may be any amount, so that general Caesar algorithm is
C = E (p) = (p+k) mod 26
Where k takes on a value in the range 1 to 25. The decryption algorithm is
simply
P = D(C) = (C-k) mod 26
Algorithm for Substitution Cipher:
Input:
A String of both lower and upper case letters, called PlainText.
An Integer denoting the required key.
Procedure:
Create a list of all the characters.
Create a dictionary to store the substitution for all characters.
For each character, transform the given character as per the rule,
depending on whether we’re encrypting or decrypting the text.
Print the new string generated.
Output
Cipher Text is: M eq wxyhCmrk Hexe IrgvCtxmsr
Recovered plain text : I am studying Data Encryption
Monoalphabetic Cipher
In simple words, if the alphabet ‘p’ in the plain text is replaced by the cipher
alphabet ‘d’. Then in the entire plain text wherever alphabet ‘p’ is used, it will be
replaced by the alphabet ‘d’ to form the ciphertext.
Playfair Cipher
Key: KEYWORD
Now, we have to convert this plain text to ciphertext using the given key. We
will discuss the further process in steps.
Step 1: Create a 5X5 matrix and place the key in that matrix row-wise from left
to right. Then put the remaining alphabet in the blank space.
Note: If a key has duplicate alphabets, then fill those alphabets only once in the
matrix, and I & J should be kept together in the matrix even though they occur
in the given key.
Step 2: Now, you have to break the plain text into a pair of alphabets.
Pair: me et me to mo rx ro wz
Note
Pair of alphabets must not contain the same letter. In case, pair has the same
letter then break it and add ‘x’ to the previous letter. Like in our example letter
‘rr’ occurs in pair so, we have broken that pair and added ‘x’ to the first ‘r’.
In case while making pair, the last pair has only one alphabet left then we add
‘z’ to that alphabet to form a pair as in our above example, we have added ‘z’ to
‘w’ because ‘w’ was left alone at last.
If a pair has ‘xx’ then we break it and add ‘z’ to the first ‘x’, i.e. ‘xz’ and ‘x_’.
Step 3: In this step, we will convert plain text into ciphertext. For that, take the
first pair of plain text and check for cipher alphabets for the corresponding in the
matrix. To find cipher alphabets follow the rules below.
Note
If both the alphabets of the pair occur in the same row replace them with the
alphabet to their immediate right. If an alphabet of the pair occurs at extreme
right then replace it with the first element of that row, i.e. the last element of
the row in the matrix circularly follows the first element of the same row.
If the alphabets in the pair occur in the same column, then replace them with
the alphabet immediate below them. Here also, the last element of the column
circularly follows the first element of the same column.
If the alphabets in the pair are neither in the same column and nor in the
same row, then the alphabet is replaced by the element in its own row and the
corresponding column of the other alphabet of the pair.
Pair: me et me to mo rx ro wz
Cipher Text: kn ku kn kz ks ta kc yo
So, this is how we can convert a plain text to ciphertext using Playfair cipher.
When compared with monoalphabetic cipher Playfair cipher is much more
advanced. But still, it is easy to break.
One-Time Pad
The one-time pad cipher suggests that the key length should be as long as
the plain text to prevent the repetition of key. Along with that, the key should
be used only once to encrypt and decrypt the single message after that the key
should be discarded.
Onetime pad suggests a new key for each new message and of the same length
as a new message. Now, let us see the one-time pad technique to convert plain
text into ciphertext. Assume our plain text and key be:
Key: Cipher
Now again convert the plain text and key into the numeric form. For that
number the alphabets such as A=0, B=1, C=2, …………, Z=25. So, our plain text
and key in numeric form would be:
Plain text: 1 8 13 0 17 24
Key: 2 8 15 7 4 17
Now, you have to add the number of the plain text alphabet, to the number of
its corresponding key alphabet. That means, for this example, we will add:
B+C = 1+2 = 3
I+I = 8+8 = 16
N+P = 13+15 = 28
A+H = 0+7 = 7
R+E = 17+4 = 21
Y+R = 24+17 = 41
The resultant ciphertext numbers we get are (3, 16, 28, 7, 21, 41
If the addition of any plain text number and the key number is >26, then
subtract only that particular number from 26. We have the addition of two pair
of plain text number and a key number, greater than 26, i.e. N+P=28 &
Y+R=41.
N+P = 28 – 26 = 2
Y+R = 41 – 26 = 15
So, the final ciphertext numbers are (3, 16, 2, 7, 21, 15). Now convert this
number to alphabets assuming A to be numbered 0 and B to be 1…..Z to 25.
Ciphertext: dqchvp.
In this way, we can convert plain text to cipher text using a one-time pad.
So, this is all about the substitution cipher techniques. It has a monoalphabetic
cipher and polyalphabetic cipher technique. Substitution technique is also called
classical substitution technique.
The rail fence cipher is the simplest transposition cipher. The steps to obtain
cipher text using this technique are as follow:
Step 2: Then, to obtain the cipher text the text is read as a sequence of rows.
To understand this in a better way, let us take an example:
Now, we will write this plain text sequence wise in a diagonal form as you can
see below:
import java.util.*;
// Encryption
static String encryptMessage(String msg) {
int row, col;
StringBuilder cipher = new StringBuilder();
// Get the cipher text from the matrix column-wise using the
permuted key
for (int i = 0; i < row; i++) {
if (Character.isLetter(matrix[i][columnIndex]) ||
matrix[i][columnIndex] == ' ' || matrix[i][columnIndex] == '_') {
cipher.append(matrix[i][columnIndex]);
}
}
}
return cipher.toString();
}
// Decryption
static String decryptMessage(String cipher) {
/* Calculate the number of columns for the cipher matrix */
int col = key.length();
return msg.toString();
}
setPermutationOrder();
Output:
Encrypted Message: e kefGsGsrekoe_
Decrypted Message: Geeks for Geeks
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.
Now, put the plain text in the rectangle of a predefined size. For our example,
the predefined size of the rectangle would be 3×4. As you can see in the image
below the plain text is placed in the rectangle of 3×4. And we have also
permuted the order of the column
Now, to obtain the cipher text we have to read the plain text column by column
as the sequence of permuted column order. So, the cipher text obtained by the
columnar transposition technique in this example is:
Similar to the rail fence cipher, the columnar cipher can be easily broken. The
cryptanalyst only has to try few permutation and combination over the order of
column to obtain the permuted order of column and the get the original
message. So, a more sophisticated technique was required to strengthen the
encryption.
Book Cipher or Running Key Cipher
The book cipher or the running key cipher works on the basic principle of one-
time pad cipher. In onetime pad cipher the key is taken as long as the plain text
and is discarded after the use. Every time a new key is taken for a new
message.
The improvement to the onetime pad in Book cipher is that the key or the
onetime pad is taken from the book. Let us discuss the steps:
Step 1: Convert the plain text in numeric form consider A=0, B=1, C=3 …,
Z=25.
Step 2: Take an onetime pad or key from any of the books and convert it in the
numeric form also. But the key must be as long as the length of plain text.
Step 3: Now add the numeric form of both plain text and key, each plain text
letter with corresponding key text letter. If the addition of any plain text letter
with corresponding key text letter is >26, then subtract it with 26.
Now we have to convert this plain text and key text in numeric form and add
them to get cipher text as shown in the image below: