0% found this document useful (0 votes)
11 views

ICS Unit 2

This document provides an introduction to cryptography, explaining key concepts such as plaintext, ciphertext, encryption, and decryption, as well as various encryption techniques including substitution and transposition ciphers. It details specific methods like the Caesar Cipher, Playfair Cipher, Vigenere Cipher, and the Data Encryption Standard (DES), highlighting their processes and applications. Additionally, it introduces the Advanced Encryption Standard (AES) as a more secure alternative to DES.

Uploaded by

dedxd2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

ICS Unit 2

This document provides an introduction to cryptography, explaining key concepts such as plaintext, ciphertext, encryption, and decryption, as well as various encryption techniques including substitution and transposition ciphers. It details specific methods like the Caesar Cipher, Playfair Cipher, Vigenere Cipher, and the Data Encryption Standard (DES), highlighting their processes and applications. Additionally, it introduces the Advanced Encryption Standard (AES) as a more secure alternative to DES.

Uploaded by

dedxd2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Unit 2

INTRODUCTION TO CRYPTOGRAPHY:

 An original message is known as the plaintext, while the coded message is called the ciphertext.
 The process of converting from plaintext to ciphertext is known as enciphering or encryption; restoring theplaintext from
the ciphertext is deciphering or decryption.
 The many schemes used for encryption constitute the area of study known as cryptography. Such a scheme is known as a
cryptographic system or a cipher.
 Techniques used for deciphering a message without any knowledge of the enciphering details fall into the area of
cryptanalysis.
 Cryptanalysis is what the layperson calls “breaking the code.”The areas of cryptography and cryptanalysistogether are
called cryptology.

A symmetric encryption scheme has five ingredients:

Plaintext: This is the original intelligible message or data that is fed into the algorithm as input.

Encryption algorithm: The encryption algorithm performs various substitutions and transformations on the plaintext.

Secret key: The secret key is also input to the encryption algorithm.The key is a value independent of the plaintextand of the
algorithm. The algorithm will produce a different output depending on the specific key being used at the time.The exact substitutions
and transformations performed by the algorithm depend on the key.

Ciphertext: This is the scrambled message produced as output. It depends on the plaintext and the secret key.

Decryption algorithm: This is essentially the encryption algorithm run in reverse. It takes the ciphertext and the secret key and
produces the original plaintext.

Substitution Technique in Cryptography


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

Substitution Technique:
Caesar Cipher
Monoalphabetic Cipher
Playfair Cipher
Polyalphabetic Cipher
Vignere Cipher
Caesar Cipher
This the simplest substitution cipher by Julius Caesar. 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:
Plain Text: meet me tomorrow
Cipher Text: phhw ph wrpruurz
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’.

Monoalphabetic Cipher
Monoalphabetic cipher is a substitution cipher, where the cipher alphabet for each plain text alphabet is fixed,
for the entire encryption.

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
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:

Plain Text: meet me tomorrow

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.

Plain Text: meet me tomorrow

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.

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.

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

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,

E = (P + K ) mod
i 26
i i

Formula of decryption is,

Di = (Ei - Ki) mod 26

Example: The plaintext is "JAVATPOINT", and

the key is "BEST". Encryption: Ei = (Pi + Ki) mod

26

Plaintext J A V A T P O I N

Plaintext value (P) 09 00 21 00 19 15 14 08 13

Key B E S T B E S T B

Key value (K) 01 04 18 19 01 04 18 19 01

Ciphertext value (E) 10 04 13 19 20 19 06 01 14

Ciphertext K E N T U T G B O
Transposition Technique in Cryptography
Transposition technique is an encryption method which is achieved by
performing permutation over the plain text. Mapping plain text into cipher text
using transposition technique is called transposition cipher.

1. Rail Fence Transposition


2. Columnar Transposition

Rail Fence Cipher


The rail fence cipher is the simplest transposition cipher. The steps to obtain
cipher text using this technique are as follow:

Step 1: The plain text is written as a sequence of diagonals.

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:

Plain Text: meet me Tomorrow

Now, we will write this plain text sequence wise in a diagonal form as you can
see below:

Looking at the image, you would get it why it got named rail fence because it
appears like the rail fence.

Once you have written the message as a sequence of diagonals, to obtain the
cipher text out of it you have to read it as a sequence of rows. So, reading the
first row the first half of cipher text will be:

memtmro

reading the second row of the rail fence, we will get the second half of the
cipher text:

eteoorw

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
Rail fence cipher is easy to implement and even easy for a cryptanalyst to
break this technique. So, there was a need for a more complex technique.

Columnar 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.

To understand the columnar transposition let us take an example:

Plain text: meet Tomorrow

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:

Cipher Text: MTREOREMOTOW.

Similar to the rail fence cipher, the columnar cipher can be easily broken.

Columnar Transposition Technique with Multiple


Rounds
It is similar to the basic columnar technique but is introduced with an
improvement. The basic columnar technique is performed over the plain text
but more than once. The steps for columnar technique with multiple rounds
are as follow:

Step 1: The plain text is written in the rectangle of predetermined size row by
row.

Step 2: To obtain the cipher text, read the plain text in the rectangle, column
by column. Before reading the text in rectangle column by column, permute
the order of columns the same as in basic columnar technique.

Step 3: To obtain the final cipher text repeat the steps above multiple time.

Let us discuss one example of a columnar transposition technique for better


understanding. We will consider the same example of a basic columnar
technique which will help in understanding the complexity of the method:

Plain Text: meet Tomorrow

Let us put this plain text in the rectangle of predefined size of 3×4.
Proceeding with the next step, the order of the columns of the matrix is
permuted as you can see in the image below:

Now after the first round the cipher text obtained is as follow:

Cipher Text round 1: MTREOREMOTOW

Now, again we have to put the cipher text of round 1 in the rectangle of size
3×4 row by row and permute the order of columns before reading the cipher
text for round 2. In the second round, the permuted order of the column is 2,
3, 1, 4.

So, the obtained cipher text for round 2 is MOOTRTREOEMW. In this way,
we can perform as many iterations as requires. Increasing the number of
iterations increases the complexity of the techniques.
Data Encryption Standard (DES)

DES stands for Data Encryption Standard. DES is a symmetric-key block cipher created in the
early 1970s by an IBM team and adopted by the National Institute of Standards and Technology
(NIST).

The algorithm takes the plain text in 64-bit blocks and The DES algorithm uses a key of 56-bit
size. converts them into ciphertext using 48-bit keys. Using this key, the DES takes a block of
64-bit plain text as input and generates a block of 64-bit cipher text.

The DES process has several steps involved in it, where each step is called a round. Depending
upon the size of the key being used, the number of rounds varies. For example, a 128-bit key
requires 10 rounds.

DES Algorithm Steps

To put it in simple terms, DES takes 64-bit plain text and turns it into a 64-bit ciphertext. & the
same key is used when it’s time to decrypt the text.

The algorithm process breaks down into the following steps:

1. The process begins with the 64-bit plain text block getting handed over to an initial
permutation (IP) function.

2. The initial permutation (IP) is then performed on the plain text.

3. Next, the initial permutation (IP) creates two halves of the permuted block,

Left Plain Text (LPT) and Right Plain Text (RPT).

4. Each LPT and RPT goes through 16 rounds of the encryption process.

5. Finally, the LPT and RPT are rejoined, and a Final Permutation (FP) is performed on the
newly combined block.

6. The result of this process produces the desired 64-bit ciphertext.


The encryption process step (step 4, above) is further broken down into five stages:

1. Key transformation

2. Expansion permutation

3. S-Box permutation

4. P-Box permutation

5. XOR and swap

For decryption, we use the same algorithm, and we reverse the order of the 16 round keys.

Initial Permutation (IP)

The plain text is divided into smaller chunks of 64-bit size. The IP is performed before the first
round. This phase describes the implementation of the transposition process. For example, the
58th bit replaces the first bit, the 50th bit replaces the second bit, and so on. The resultant 64-bit
text is split into two equal halves of 32-bit each called Left Plain Text (LPT) and Right Plain
Text (RPT).
Applications of DES Algorithm

In this section, we are going to learn about some of the applications of the DES Algorithm.

1. It is used in random number generation

2. It is deployed when not-so-strong encryption is needed

3. It is used to develop a new form of DES, called Triple DES (using a 168-bit key formed using
three keys)
AES(Advanced Encryption Standard):
Advanced Encryption Standard (AES) is a specification for the encryption of
electronic data established by the U.S. National Institute of Standards and
Technology (NIST) in 2001. AES is widely used today as it is much stronger than
DES and triple DES despite being harder to implement. AES is a highly
trusted encryption algorithm used to secure data by converting it into an
unreadable format with the proper key.

AES encryption uses various key lengths (128, 192, or 256 bits) to provide strong
protection against unauthorized access. This data security measure is efficient and
widely implemented in securing internet communication, protecting sensitive
data, and encrypting files. AES, a cornerstone of modern cryptography, is
recognized globally for its ability to keep information safe from cyber threats.

 AES is a Block Cipher.


 The key size can be 128/192/256 bits.
 Encrypts data in blocks of 128 bits each.

That means it takes 128 bits as input and outputs 128 bits of encrypted cipher text.

The number of rounds depends on the key length as follows :


 128-bit key – 10 rounds
 192-bit key – 12 rounds
 256-bit key – 14 rounds

Creation of Round Keys


A Key Schedule algorithm calculates all the round keys from the key. So the initial
key is used to create many different round keys which will be used in the
corresponding round of the encryption.
Each round comprises of 4 steps:

o Sub Bytes
o Shift Rows
o Mix Columns
o Add Round Key

 Sub-Bytes: In this step, it converts each byte of the state array into
hexadecimal, divided into two equal parts. These parts are the rows and columns,
mapped with a substitution box (S-Box) to generate new values for the final state
array.

 Shift Rows: It swaps the row elements among each other. It skips the first row.
It shifts the elements in the second row, one position to the left. It also shifts the
elements from the third row two consecutive positions to the left, and it shifts the last
row three positions to the left.
 Mix Columns: It multiplies a constant matrix with each column in the state
array to get a new column for the subsequent state array. Once all the columns are
multiplied with the same constant matrix, you get your state array for the next step.
This particular step is not to be done in the last round.

 Add Round Key: The respective key for the round is XOR’d with the state
array is obtained in the previous step. If this is the last round, the resultant state array
becomes the ciphertext for the specific block; else, it passes as the new state array
input for the next round.

Advantages of AES
The AES algorithm provides several advantages over older algorithms such
as the Data Encryption Standard (DES):

 Security. AES offers stronger security since it incorporates multiple


rounds of encryption, making it harder to break, and harder for threat
actors to intercept or steal the encrypted information using brute-force
attacks.

 Cost. AES is an open source and ubiquitously available solution, making


it cost-effective to adopt and implement.

 Implementation. AES is a flexible and simple algorithm, making it


suitable for both hardware and software implementation.
RSA (Rivest, Shamir, and Adelman )
RSA is the most common public-key algorithm, named after its inventors Rivest,
Shamir, and Adelman (RSA).

RSA encryption algorithm is a type of public-key encryption algorithm.

Public key encryption algorithm:


Public Key encryption algorithm is also called the Asymmetric algorithm. Asymmetric
algorithms are those algorithms in which sender and receiver use different keys for
encryption and decryption. Each sender is assigned a pair of keys:

The Public key is used for encryption, and the Private Key is used for decryption.
Decryption cannot be done using a public key. The public key is well known, but the private
key is secret and it is known only to the user who owns the key.

RSA encryption algorithm:


RSA algorithm uses the following procedure to generate public and private keys:

o Select two large prime numbers, p and q.


o Multiply these numbers to find n = p x q, where n is called the modulus for
encryption and decryption.
o Choose a number e less than n, such that n is relatively prime to (p - 1) x (q -
1). It means that e and (p - 1) x (q - 1) have no common factor except 1. Choose
"e" such that 1<e < φ (n), e is prime to φ (n),
gcd (e,d(n)) =1
o If n = p x q, then the public key is <e, n>. A plaintext message m is encrypted
using public key <e, n>. To find ciphertext from the plain text following formula
is used to get ciphertext C.
C = me mod n
Here, m must be less than n. A larger message (>n) is treated as a concatenation
of messages, each of which is encrypted separately.
o To determine the private key, we use the following formula to calculate the d
such that:
De mod {(p - 1) x (q - 1)} = 1
Or
De mod φ (n) = 1
o The private key is <d, n>. A ciphertext message c is decrypted using private key
<d, n>. To calculate plain text m from the ciphertext c following formula is used
to get plain text m.
m = cd mod n

o Example 1:
o This example shows how we can encrypt plaintext 9 using the RSA public-key
encryption algorithm. This example uses prime numbers 7 and 11 to generate
the public and private keys.
o Explanation:
o Step 1: Select two large prime numbers, p, and q.
o p=7
o q = 11
o Step 2: Multiply these numbers to find n = p x q, where n is called the modulus
for encryption and decryption.
o First, we calculate
o n=pxq
o n = 7 x 11
o n = 77
o Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x
(q -1). It means that e and (p - 1) x (q - 1) have no common factor except 1.
Choose "e" such that 1<e < φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
o Second, we calculate
o ADVERTISEMENT
o φ (n) = (p - 1) x (q-1)
o φ (n) = (7 - 1) x (11 - 1)
o φ (n) = 6 x 10
o ADVERTISEMENT
o φ (n) = 60
o Let us now choose relative prime e of 60 as 7.
o ADVERTISEMENT
o Thus the public key is <e, n> = (7, 77)
o Step 4: A plaintext message m is encrypted using public key <e, n>. To find
ciphertext from the plain text following formula is used to get ciphertext C.
o To find ciphertext from the plain text following formula is used to get ciphertext
C.
o C = me mod n
o C = 97 mod 77
o C = 37
o Step 5: The private key is <d, n>. To determine the private key, we use the
following formula d such that:
o De mod {(p - 1) x (q - 1)} = 1
o 7d mod 60 = 1, which gives d = 43
o The private key is <d, n> = (43, 77)
o Step 6: A ciphertext message c is decrypted using private key <d, n>. To
calculate plain text m from the ciphertext c following formula is used to get plain
text m.
o m = cd mod n
o m = 3743 mod 77
o m=9
o In this example, Plain text = 9 and the ciphertext = 37

o Example 2:
In an RSA cryptosystem, a particular A uses two prime numbers, 13 and 17, to
generate the public and private keys. If the public of A is 35. Then the private key of
A is ……………?.

o Explanation:
o Step 1: in the first step, select two large prime numbers, p and q.
o p = 13
o q = 17
o Step 2: Multiply these numbers to find n = p x q, where n is called the modulus
for encryption and decryption.
o First, we calculate
o n=pxq
o n = 13 x 17
o n = 221
o Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x
(q -1). It means that e and (p - 1) x (q - 1) have no common factor except 1.
Choose "e" such that 1<e < φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
o Second, we calculate
o φ (n) = (p - 1) x (q-1)
o φ (n) = (13 - 1) x (17 - 1)
o φ (n) = 12 x 16
o φ (n) = 192
o g.c.d (35, 192) = 1
o Step 3: To determine the private key, we use the following formula to calculate
the d such that:
o ADVERTISEMENT
o Calculate d = de mod φ (n) = 1
o d = d x 35 mod 192 = 1
o d = (1 + k.φ (n))/e [let k =0, 1, 2, 3………………]
o Put k = 0
o d = (1 + 0 x 192)/35
o d = 1/35
o Put k = 1
o d = (1 + 1 x 192)/35
o d = 193/35
o Put k = 2
o d = (1 + 2 x 192)/35
o d = 385/35
o d = 11
o The private key is <d, n> = (11, 221)
o Hence, private key i.e. d = 11

Message Authentication
Verifying the identity of user. Message authentication assures that data recived are
exactly as sent message .

Message authentication allows one party—the sender—to send a message to


another party—the receiver—in such a way that if the message is modified en
route, then the receiver will almost certainly detect this. Message authentication is
also called data-origin authentication.

Message authentication provides two services. It provides a way to ensure


message integrity and a way to verify who sent the message. There are two
methods for producing the message authentication code:

1)Message Encryption:
The Process of conversion of plain text into cipher text, cipher text acts as
authenticator.

2) Message Authentication Code(MAC) –


It is also called as MAC. A message authentication code (MAC) is a cryptographic
checksum on data that uses a session key to detect both accidental and intentional
modifications of the data.

We will have some authentication & apply them on plain text along with the key
which produces the fixed length code called MAC. This code is attached to the
message or request sent by the user. Message authentication codes (MACs)
attached to the message must be recognized by the receiving system in order to
grant the user access. MACs are commonly used in electronic funds transfers
(EFTs) to maintain information integrity.

The message authentication code technique involves the use of a secret key. This
technique assumes that two communicating parties, say A and B, share a common
secret key KAB. When A has a message to send to B, it calculates the message
authentication code as a function of the message and the key: MACM = F (KAB,M).

The message plus code are transmitted to the intended recipient. The recipient
performs the same calculation on the received message, using the same secret key,
to generate a new message authentication code. The received code is compared to
the calculated code. If we assume that only the receiver and the sender know the
identity of the key, and if the received code matches the calculate code, then
 The receiver is assured that the message has not been altered.
 Because no one else knows the secret key, no one else could prepare a
message with a proper code.
 If the message includes a sequence number, then the receiver can be assured
of the proper sequence, because an attacker cannot successfully alter the
sequence number.
C(M,K)= Fixed length code(MAC)

Hash Functions
Hashing is the process of generating a value from a text or a list of numbers
using a mathematical function known as a hash function.

Hashing is the process of converting data — text, numbers, files, or anything,


really — into a fixed-length string of letters and numbers. Data is converted into
these fixed-length strings, or hash values, by using a special algorithm called a
hash function.

A cryptographic hash function is a transformation that creates an input (or


message) and restore a fixed-size string, which is known as the hash value. A hash
value h is produced by a function H of the form −
h = H(M)
where M is the variable length message and H (M) is the fixed length hash value.
Hash functions are generally used mathematical functions in cryptography for
executing security. A hash function transform an input value of any arbitrary size
to a fixed-size value. Therefore, the input can be of any length but the output
produced is always of a fixed length. The output generated is known as hash
values or hashes.

The general use of hashing is password checking. When the user enters the
password, the hash of the password is produced and compared with the hash in the
database. If both the hashes are the equal thus the user is enabled to login else the
user required to enter the password again.

Types of Hash functions


There are many hash functions that use numeric or alphanumeric keys. This
article focuses on discussing different hash functions:
1. Division Method.
2. Mid Square Method.
3. Folding Method.
4. Multiplication Method.
Let’s begin discussing these methods in detail.
1. Division Method:
This is the most simple and easiest method to generate a hash value. The hash
function divides the value k by M and then uses the remainder obtained.
Formula:
h(K) = k mod M
Here,
k is the key value, and
M is the size of the hash table.
It is best suited that M is a prime number as that can make sure the keys are more
uniformly distributed. The hash function is dependent upon the remainder of a
division.
Example:
k = 12345
M = 95
h(12345) = 12345 mod 95
= 90
k = 1276
M = 11
h(1276) = 1276 mod 11
=0
Pros:
1. This method is quite good for any value of M.
2. The division method is very fast since it requires only a single division
operation.
Cons:
1. This method leads to poor performance since consecutive keys map to
consecutive hash values in the hash table.
2. Sometimes extra care should be taken to choose the value of M.
2. Mid Square Method:
The mid-square method is a very good hashing method. It involves two steps to
compute the hash value-
1. Square the value of the key k i.e. k2
2. Extract the middle r digits as the hash value.
Formula:
h(K) = h(k x k)
Here,
k is the key value.
The value of r can be decided based on the size of the table.
Example:
Suppose the hash table has 100 memory locations. So r = 2 because two digits
are required to map the key to the memory location.
k = 60
k x k = 60 x 60
= 3600
h(60) = 60
The hash value obtained is 60
Pros:
1. The performance of this method is good as most or all digits of the key value
contribute to the result. This is because all digits in the key contribute to
generating the middle digits of the squared result.
2. The result is not dominated by the distribution of the top digit or bottom digit
of the original key value.
Cons:
1. The size of the key is one of the limitations of this method, as the key is of big
size then its square will double the number of digits.
2. Another disadvantage is that there will be collisions but we can try to reduce
collisions.
3. Digit Folding Method:
This method involves two steps:
1. Divide the key-value k into a number of parts i.e. k1, k2, k3,….,kn, where
each part has the same number of digits except for the last part that can have
lesser digits than the other parts.
2. Add the individual parts. The hash value is obtained by ignoring the last carry
if any.
Formula:
k = k1, k2, k3, k4, ….., kn
s = k1+ k2 + k3 + k4 +….+ kn
h(K)= s
Here,
s is obtained by adding the parts of the key k
Example:
k = 12345
k1 = 12, k2 = 34, k3 = 5
s = k1 + k2 + k3
= 12 + 34 + 5
= 51
h(K) = 51
Note:
The number of digits in each part varies depending upon the size of the hash
table. Suppose for example the size of the hash table is 100, then each part must
have two digits except for the last part which can have a lesser number of digits.
4. Multiplication Method
This method involves the following steps:
1. Choose a constant value A such that 0 < A < 1.
2. Multiply the key value with A.
3. Extract the fractional part of kA.
4. Multiply the result of the above step by the size of the hash table i.e. M.
5. The resulting hash value is obtained by taking the floor of the result obtained
in step 4.
Formula:
h(K) = floor (M (kA mod 1))
Here,
M is the size of the hash table.
k is the key value.
A is a constant value.
Example:
k = 12345
A = 0.357840
M = 100
h(12345) = floor[ 100 (12345*0.357840 mod 1)]
= floor[ 100 (4417.5348 mod 1) ]
= floor[ 100 (0.5348) ]
= floor[ 53.48 ]
= 53
MD5 (Message Digest 5): MD5 is a widely-used cryptographic hash function
that produces a 128-bit hash value. It is fast and efficient but is no longer
recommended for security purposes due to known vulnerabilities. The basic idea
behind MD5 is to take an input message of any length, and produce a fixed-
length output, known as the hash value or message digest. This hash value is
unique to the input message, and is generated using a mathematical algorithm
that involves a series of logical operations, such as bitwise operations, modular
arithmetic, and logical functions.

MD5 is widely used in a variety of applications, including digital signatures,


password storage, and data integrity checks.

Digital signature
A digital signature is a mathematical technique which validates the authenticity and integrity of a
message, software or digital documents. It allows us to verify the author name, date and time of
signatures, and authenticate the message contents.

Application of Digital Signature


The important reason to implement digital signature to communication is:

o Authentication
o Non-repudiation
o Integrity
Authentication
Authentication is a process which verifies the identity of a user who wants to access the system.
In the digital signature, authentication helps to authenticate the sources of messages.

Non-repudiation
Non-repudiation means assurance of something that cannot be denied. It ensures that someone to
a contract or communication cannot later deny the authenticity of their signature on a document
or in a file or the sending of a message that they originated.

Integrity
Integrity ensures that the message is real, accurate and safeguards from unauthorized user
modification during the transmission.

Algorithms in Digital Signature


A digital signature consists of three algorithms:

1. Key generation algorithm

The key generation algorithm selects private key randomly from a set of possible private keys.
This algorithm provides the private key and its corresponding public key.

2. Signing algorithm

A signing algorithm produces a signature for the document.

3. Signature verifying algorithm

A signature verifying algorithm either accepts or rejects the document's authenticity.

How digital signatures work


Digital signatures are created and verified by using public key cryptography, also known as
asymmetric cryptography. By the use of a public key algorithm, such as RSA, one can generate
two keys that are mathematically linked- one is a private key, and another is a public key.

The user who is creating the digital signature uses their own private key to encrypt the signature-
related document. There is only one way to decrypt that document is with the use of signer's
public key.

This technology requires all the parties to trust that the individual who creates the signature has
been able to keep their private key secret. If someone has access the signer's private key, there is
a possibility that they could create fraudulent signatures in the name of the private key holder.

The steps which are followed in creating a digital signature are:

1. Select a file to be digitally signed.


2. The hash value of the message or file content is calculated. This message or file content is
encrypted by using a private key of a sender to form the digital signature.
3. Now, the original message or file content along with the digital signature is transmitted.
4. The receiver decrypts the digital signature by using a public key of a sender.
5. The receiver now has the message or file content and can compute it.
6. Comparing these computed message or file content with the original computed message. The
comparison needs to be the same for ensuring integrity.

Monoalphabetic Cipher Polyalphabetic Cipher

Polyalphabetic cipher is any cipher based


A monoalphabetic cipher is one where each
on substitution, using multiple
symbol in plain text is mapped to a fixed
substitution alphabets.
symbol in cipher text.

The relationship between a character in


The relationship between a character in the
the plain text and the characters in the
plain text and the characters in the cipher text
cipher text is one-to-many.
is one-to-one.

Each alphabetic character of plain text


Each alphabetic character of plain text is
can be mapped onto ‘m’ alphabetic
mapped onto a unique alphabetic character of
characters of a cipher text.
a cipher text.

A stream cipher is a polyalphabetic


A stream cipher is a monoalphabetic cipher
cipher if the value of key does depend
if the value of key does not depend on the
on the position of the plain text
position of the plain text character in the
character in the plain text stream.
plain text stream.

It includes autokey, Playfair,


It includes additive, multiplicative, affine
Vigenere, Hill, one-time pad, rotor,
and monoalphabetic substitution
and Enigma cipher.
cipher.

It is a simple substitution cipher. It is multiple substitutions cipher.

Polyalphabetic Cipher is described as


Monoalphabetic Cipher is described as a
substitution cipher in which plain text
substitution cipher in which the same fixed
letters in different positions are
mappings from plain text to cipher letters
enciphered using different
across the entire text are used.
cryptoalphabets.
Monoalphabetic ciphers are not that strong
Polyalphabetic ciphers are much stronger.
as compared to polyalphabetic cipher.
Que. Distinguish Between Monoalphabetic & Polyalphabetic

Que. Describe conventional encryption model. What are the requirements


for secure use of conventional encryption?
Conventional encryption

Conventional encryption is a cryptographic system that uses the same key


used by the sender to encrypt the message and by the receiver to decrypt
the message.

It is still much preferred of the two types of encryption systems due to its
simplicity. It is a relatively fast process since it uses a single key for both
encryption and decryption In this encryption model, the sender encrypts
plaintext using the receiver’s secret key, which can be later used by the
receiver to decrypt the ciphertext. Below is a figure that illustrates this
concept.

Symmetric encryption is also referred to as conventional


encryption or single-key encryption.

Suppose A wants to send a message to B, that message is called plaintext.


Now, to avoid hackers reading plaintext, the plaintext is encrypted using an
algorithm and a secret key (at 1). This encrypted plaintext is called
ciphertext. Using the same secret key and 27 encryption algorithm run in
reverse(at 2), B can get plaintext of A, and thus the message is read and
security is maintained.

The idea that uses in this technique is very old and that’s why this model is
called conventional encryption.
Conventional encryption has mainly 5 ingredients :

1. Plain text –
It is the original data that is given to the algorithm as an input.

2. Encryption algorithm –
This encryption algorithm performs various transformations on plain text
to convert it into ciphertext.

3. Secret key –
The secret key is also an input to the algorithm. The encryption algorithm
will produce different outputs based on the keys used at that time.

Ciphertext –

It contains encrypted information because it contains a form of original


plaintext that is unreadable by a human or computer without proper cipher to
decrypt it. It is output from the algorithm.

Que. Explain the model of Symmetric Encryption


Model of Symmetric Encryption

Symmetric Encryption is the most basic and old method of encryption. It uses only
one key for the process of both the encryption and decryption of data. Thus, it is
also known as Single-Key Encryption.

A few basic terms in Cryptography are as follows:

Plain Text: or The Symmetric Cipher Model:

A symmetric cipher model is composed of five essential parts:

28
Encryption (or E 1. Plain Text (x): This is the original data/message that is to be
communicated to the receiver by the sender. It is one of the inputs to the
encryption algorithm.

2. Secret Key (k): It is a value/string/textfile used by the encryption and decryption


algorithm to encode and decode the plain text to cipher text and vice-versa
respectively. It is independent of the encryption algorithm. It governs all the
conversions in plain text. All the substitutions and transformations done depend
on the secret key.
3. Encryption Algorithm (E): It takes the plain text and the secret key as inputs
and
E(x, k)produces
=y Cipher Text as output. It implies several techniques such as
substitutions and transformations on the plain text using the secret key.

Requirements for Encryption:

There are only two requirements that need to be met to perform encryption.
They are,

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 29 and the receiver. It should be leakproof
so that the attacker cannot access the secret key.
Que. What do you mean by N/w security? Explain the model of network security in detail.
OR
Que. Draw and explain internetwork security model

Network Security

Network security is the security designed to protect the integrity of the network from
unauthorized access and threats. The network administrators are responsible for
adopting various defensive measures to guard their networks from possible security
risks.

Computer networks are linked in daily transactions and communication within the
government, private, or corporates that needs security. The most common and
straightforward strategy of protecting network support is allocating it with a unique
name and a corresponding password. The network security consists of:

1. Protection: The user should be able to configure their devices and networks accurately.
2. Detection: The user must detect whether the configuration has changed or get a
notification if there is any problem in the network traffic.
3. Reaction: After detecting the problems, the user must respond to them and must
return to a protected position as quickly as possible.

Model of network security

An effective network security model in computer networks has the following key
aspects:

1. An encryption algorithm encodes plaintext into ciphertext


30
and decodes cypher text back into plain text. The strength of
the
algorithm relies on its ability to withstand cracking attempts by
adversaries.

2. Secure generation, distribution and usage of a secret key


exclusively shared between the communicating parties over the
computer network. A trusted third party facilitates the secret key
exchange in the network security model in CNS.
3. Communication protocols enable the application of the chosen
encryption powered by the secretly shared key to deliver
security services like confidentiality, integrity and
authentication of the sender.

Important Question

1. Explain Man in the Middle Attack in Detail


2. Explain the model of Symmetric Encryption
3. Explain security Attributes/goal in detail
4. What do you mean by N/w security? Explain the model of
network security in detail.
Or

Draw and explain internetwork security model

5. What are different types of attacks? Explain all category &


its subtypes of attacks in detail with diagram.
6. Describe conventional encryption model. What are
the requirements for secure use of conventional
encryption?
7. Encrypt the following string using caesar cipher with key of
3 String: "Hells World".
8. Explain any one Substitution Cipher.
9. Explain Monoalphabetic cipher in detail & generate cipher
text for "GOOD MORNING" using it.
10. Using play for cipher, encrypt the following sting "Playfair
Cipher" using key "Marshall".
31
11. Write a short note on polyalphabetic ciphers with
an example.

32
12. Encrypt the message "Money helps to build
infrastructure" using Hill cipher with the key 9 4 5 7
Show your
calculations and result.
13. Explain Security Services in brief.

33

You might also like