Unit 2
Unit 2
Cryptography and
Cryptographic Algorithms
Cryptography
Science and Art of transforming message to make them secure and
immune to attack
Cryptography is the technique of converting ordinary plain text into
unintelligible text and vice-versa.
It is the practice and study of techniques for secure communication in the
presence of third parties.
It is also referred by the terms Cryptology and Cryptanalysis.
It is a method of storing and transmitting data in a particular form so that
only those for whom it is intended can read and process it.
Cryptography is most often associated with scrambling plaintext into
cipher text (a process called encryption), then back again (known as
decryption).
Cryptography
Encryption
The Data Encryption Standard(DES) works by using the same key to encrypt
and decrypt a message, so both the sender and the receiver must know and
use the same private key.
DES is an outdated symmetric-key method of data encryption.
Originally designed by researchers at IBM in the early 1970s, DES was
adopted by the U.S. government as an official Federal Information
Processing Standard (FIPS) in 1977 for the encryption of commercial and
sensitive yet unclassified government computer data.
It was the first encryption algorithm approved by the U.S. government for
public disclosure.
DES has been upgraded by the more secure Advanced Encryption
Standard (AES) algorithm.
Data Encryption Standard (DES)
Now the output of IP is divided into two equal halves i.e. Left 32 bits as
LPT and right 32 bits as RPT.
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
1. Key transformation
Key Bit shifted per round
Compression Permutation
2. Expansion Permutation of Plain Text (P.T.) and X-OR
3. S-box Substitution
4. P-box Permutation
5. X-OR and Swap
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
1. Key transformation (key bit shifting)
We have noted initial 64-bit key is transformed into a 56-bit key by
discarding every 8th bit of the initial key. Thus, for each a 56-bit key is
available. From this 56-bit key, a different 48-bit Sub Key is generated
during each round using a process called key transformation.
For this, the 56-bit key is divided into two halves, each of 28 bits.
These halves are circularly shifted left by one or two positions,
depending on the round.
For example: if the round numbers 1, 2, 9, or 16 the shift is done by only
one position for other rounds, the circular shift is done by two positions.
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
1. Key transformation (Compression Permutation)
After an appropriate shift, 48 of the 56 bits are selected.
For instance, after the shift, bit number 14 moves to the first position, bit
number 17 moves to the second position, and so on. If we observe the
table carefully, we will realize that it contains only 48-bit positions. Bit
number 18 is discarded (we will not find it in the table), like 7 others (9,
22, 25, 35,38, 43 and 54), to reduce a 56-bit key to a 48-bit key as shown
in table below:
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
1. Key transformation (Compression Permutation)
Since the key transformation process involves permutation as well as a
selection of a 48-bit subset of the original 56-bit key it is called
Compression Permutation.
Because of this compression permutation technique, a different subset
of key bits is used in each round. That makes DES not easy to crack.
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
2. Expansion Permutation of Plain Text (P.T.) and X-OR
Recall: we had two 32-bit plain text areas called Left Plain Text(LPT)
and Right Plain Text(RPT) and 48 bit key.
During the expansion permutation, the RPT is expanded from 32 bits to 48
bits (since key block is 48 bit). Bits are permuted as well hence called
expansion permutation.
This happens as the 32-bit RPT is divided into 8 blocks, with each block
consisting of 4 bits.
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
2. Expansion Permutation of Plain Text (P.T.) and X-OR
Each 4-bit block is expanded to 6-bit and produces 48-bit output as below:
Finally 48-bit RPT is XORed with 48-bit Key and finally output is given to
the next box(S-box).
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
3. S-box Substitution
Converts 48-bit RPT XORed with 48-bit key to 32-bit output
There are 8 Substitution boxes or S-boxes, where each block has 6 bit
input and 4 bit output. The 48-bit are divided into eight 6-bit sub-block.
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
3. S-box Substitution
Each S-box is a table of 4 rows and 16 columns. Each entry in the box is a
4-bit number. The 6 input bits of the S-box specify under which row and
column number to look for the output.
Example: Let us consider the input to a S-box is 011011
Here the first and last bit of the 6 input bit forms the row and the remaining
four bits constitute the row. 011011
01
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
3. S-box Substitution
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
4. P-Box Permutation
Output of the S-Box (32-bit) is given to P-Box.
32-bit is permuted with 16*2 permutation table.
For Example:
• 16th bit of S-box takes first position as per above permutation table.
Produces 32 bit result
Data Encryption Standard (DES)-Steps
16 Rounds of Encryption (Steps)
5. X-OR and SWAP
Now the 32-bit LPT is XORed with 32 bit output of the P-Box.
The original 32-bit RPT is taken as it is and finally added/concatenated it
as 32-bit LPT as shown in figure below:
Data Encryption Standard (DES)-Steps
There is still a need for key distribution. But in this case, we intend to
distribute the public key to anyone.
One part (the public key) is available to be given away and the other
part (the private key) is intended to be kept secret.
To encrypt something for another person, we need to get a hold of
their public key and use it as the encryption key.
Then, despite the fact that the public key can be seen by anyone, the
only person that can decrypt our message is the person with the private
key.
Asymmetric Key Cryptography
RSA Algorithm
The public key is represented by the integers n and e; and, the private
key, by the integer d(although n is also used during the decryption). m
represents the message.
A user of RSA creates and then publishes a public key based on two
large prime numbers, along with an auxiliary value. The prime
numbers must be kept secret.
The RSA algorithm involves four steps:
a. key generation
b. key distribution
c. Encryption
d. decryption.
RSA Algorithm-Key Generation
The keys for RSA algorithm are generated in the following way:
1. Choose two different large random prime numbers p and q
2. Calculate n=p*q, n is called modulus
3. Calculate the totient function: Φ(n)=(p-1)(q-1)
4. Now choose an integer ‘e’ such 1<e<Φ(n) where e and Φ(n) do not
share factors other than 1
i.e. gcd(Φ(n), e) =1 , 1<e<Φ(n)
(e,n) is released as the public key
5. Now for generating private key, we calculate d as,
d*e mod Φ(n) = 1
(d,n) is used as the private key
RSA Algorithm-Key Distribution