Chapter 4-1
Chapter 4-1
ENCRYPTION ALGORITHM
DES Encryption:-
Step 1:
In the first step the 64-bit plain text undergoes initial permutation which rearranges the bits to produce
two 32-bit permuted block which is called left plain text (LPT 32-bit) and right plain text
(RPT 32-bit).
Step 2: Now, 16 rounds of DES encryption will be performed on this LPT and RPT with a 56-bit key.
Step 3: After the 16th round the 32-bit LPT and 32-bit RPT are integrated which forms a 64-bit block
again and then the final permutation is applied to this 64-bit block, to obtain the 64-bit cipher
text.
2. Expansion Permutation: -In the first step of encryption, during the initial permutation of DES, the
64-bit plain text is permuted and we have 32-bit LPT and 32-bit RPT. Now, the expansion permutation is
performed on the 32-bit RPT which transforms it from 32-bit to 48- bit.
This happens as the 32-bit RPT is divided into 8 blocks, with each block consisting of 4 bits.
Then, each 4-bit block of the previous step is then expanded to a corresponding 6-bit block, i.e., per 4-bit
block, 2 more bits are added.
Now the 48-bit key is XOR with 48-bit RPT and the resulting output is given to the next step.
The 32-bit LPT is untouched during the process.
3. S-box Substitution:- It accepts the 48-bits input from the XOR operation involving the compressed
key and expanded RPT and produces 32- bit output using the substitution techniques. Each of the 8 S-
boxes has a 6-bit input and a 4-bit output. The output of each S-box then combined to form a 32- bit
block, which is given to the last stage of a round.
4. P-box Permutation:- The 32-bit output obtained from s-box substitution is provided as an input to P-
box. Here, the 32-bit input is simply permuted and send to the next step.
DES Decryption:-
The same Data Encryption Standard algorithm used for encrypting the plain text is also used to
decrypting the cipher text.
But the algorithm is reversed, such as the initial and final permutation events are reversed. Even the
sequence of the sub keys applied in 16 rounds of DES is also reversed.
RSA is an asymmetric or public-key cryptography algorithm which means it works on two different
keys: Public Key and Private Key.
The Public Key is used for encryption and is known to everyone, while the Private Key is used for
decryption and must be kept secret by the receiver.
RSA Algorithm
It consists of three main stages:
Key Generation: Creating Public and Private Keys
Encryption: Sender encrypts the data using Public Key to get cipher text.
Decryption: Decrypting the cipher text using Private Key to get the original data.
1. Key Generation
Choose two large prime numbers, say p and q. These prime numbers should be kept secret.
Calculate the product of primes, n = p * q.
This product is part of the public as well as the private key.
Finally, the Public Key = (n, e) and the Private Key = (n, d).
Example :-
To encrypt a message M, it is first converted to numerical representation using ASCII and other
encoding schemes.
Now, use the public key (n, e) to encrypt the message and get the cipher text using the formula:
C = M e mod n, where C is the Cipher text and e and n are parts of public key.
3. Decryption
To decrypt the cipher text C, use the private key (n, d) and get the original data using the formula:
M = C d mod n, where M is the message and d and n are parts of private key.
The Diffie-Hellman key exchange (also known as exponential key exchange) is a method for securely
exchanging cryptographic keys over an insecure channel.
It is a fundamental building block of many secure communication protocols, including SSL/TLS and SSH.
The Diffie-Hellman key exchange works by allowing two parties (Alice and Bob) to agree on a shared
secret key over an insecure channel, without any other party being able to intercept the key or learn
anything about it.
The key exchange involves the following steps :-
Alice and Bob agree on two large prime numbers, p and g, and a public key exchange algorithm.
Alice chooses a secret integer, a, and computes A = g^a mod p. She sends A to Bob.
Bob chooses a secret integer, b, and computes B = g^b mod p. He sends B to Alice.
Alice computes secret key s = B^a mod p. Bob computes secret key s = A^b mod p.
Alice and Bob now both have shared secret keys, which they can use to establish a secure
communication channel.
Alice Bob
p,g p,g
Secret Integer : - a Secret Integer : - b
A = g^a mod p B = g^b mod p
5. The hash value is appended to the message at the source at a time when the message is assumed or
known to be correct.
6. The receiver authenticates that message by re-computing the hash value. Hash value is not considered
to be secret so something is required to protect the hash value.
7. The message plus concatenated Hash code is encrypted using symmetric encryption. Sender and
receiver share the same secret key. The message must have come from authorized sender and has not
been altered is checked by recomputing and comparing hash code by receiver.
Digital Signature
Explain digital signature in Cryptography.
4. The receiver calculates the message digest from the plain text or message he received.
5. Receiver decrypts the encrypted message digest using the sender’s public key. If both the MDs are
not same then the plaintext or message is modified after signing.