You are on page 1of 3

STEPS IN USING THE RSA (Rivest-Shamir-Adleman) Asymmetric Encryption

1. Key Generation:

 Choose two prime numbers, p and q. For this example, let's use p = 61 and q = 53.

 Calculate the modulus, n, as the product of p and q: n = p * q = 61 * 53 = 3233.

 Calculate the Euler's Totient Function, φ(n), which is the number of positive integers less
than n that are coprime to n. φ(n) = (p - 1) * (q - 1) = 60 * 52 = 3120.

 Choose an encryption exponent, e. Typically, e is a small prime number, and it should be


coprime with φ(n). For this example, let's choose e = 17 because it is a common choice.

 Calculate the decryption exponent, d, which is the modular multiplicative inverse of e


modulo φ(n). In this case, d = 2753 because (17 * 2753) % 3120 = 1.

2. Public Key and Private Key:

 The public key consists of (n, e), which you can freely share with anyone who wants to
send you encrypted messages.

 The private key consists of (n, d), which you must keep secret to decrypt messages.

3. Encryption:

 To encrypt a message M, convert it to an integer. For example, let's encrypt the letter
'H', which has an ASCII value of 72.

 Use the recipient's public key (n, e) to encrypt the message. The encrypted message, C,
is calculated as: C = M^e mod n. In this case, C = 72^17 mod 3233 ≈ 1096.

4. Decryption:

 To decrypt the message, the recipient uses their private key (n, d).

 Use the private key to decrypt the message: M = C^d mod n. In this case, M =
1096^2753 mod 3233 ≈ 72.

 Convert the integer back to the original message, which is 'H' (ASCII value 72).

So, in this example, the message 'H' is encrypted with the recipient's public key and decrypted with their
private key to reveal the original message.
Scenario-Based Question:

Imagine you want to securely send a sensitive document to your colleague. Explain the step-by-step
process of how you would use RSA encryption to protect the document and ensure that only your
colleague can decrypt it.

EXAMPLE 1

1. Key Generation:

 You generate an RSA key pair consisting of a public key and a private key.

 Let's say you select the following parameters:

 Public key (n, e): (187, 17)

 Private key (n, d): (187, 53)

 You keep your private key (n, d) secret and share your public key (n, e) with your
colleague.

2. Encryption:

 You have a sensitive document that you want to send to your colleague. For simplicity,
let's represent the document as a single number, D = 123.

 Using your colleague's provided public key (n, e), you apply the RSA encryption
algorithm to encrypt the document:

 Ciphertext (C) = D^e mod n

 C = 123^17 mod 187 ≈ 176.

3. Sending the Ciphertext:

 You securely send the ciphertext (C = 176) to your colleague through a secure channel.

4. Decryption:

 Your colleague, upon receiving the ciphertext (C = 176), uses their private key (n, d) to
decrypt the document.

 They apply the RSA decryption algorithm:

 Decrypted Document (D) = C^d mod n

 D = 176^53 mod 187 ≈ 123.

As a result, your colleague successfully decrypts the cipher text to obtain the original sensitive
document, which in this case is represented by the number 123.
EXAMPLE 2

1. Key Generation:

 You generate an RSA key pair with the following parameters:

 Public key (n, e): (323, 17)

 Private key (n, d): (323, 2753)

 Keep your private key (n, d) secret and share your public key (n, e) with your colleague.

2. Encryption:

 You have a sensitive document, and you convert it into a numerical representation. For
simplicity, let's represent the document as a single number, D = 200.

 Using your colleague's provided public key (n, e), apply the RSA encryption algorithm:

 Ciphertext (C) = D^e mod n

 C = 200^17 mod 323 ≈ 38.

3. Sending the Ciphertext:

 You securely send the ciphertext (C = 38) to your colleague through a secure channel.

4. Decryption:

 Your colleague, upon receiving the ciphertext (C = 38), uses their private key (n, d) to
decrypt the document.

 They apply the RSA decryption algorithm:

 Decrypted Document (D) = C^d mod n

 D = 38^2753 mod 323 ≈ 200.

Your colleague successfully decrypts the ciphertext to obtain the original sensitive document, which in
this case is represented by the number 200. This process ensures that only your colleague, with the
corresponding private key, can decrypt and access the sensitive document, maintaining its
confidentiality during transmission.

You might also like