[Math] Decryption of RSA algorithm

algorithmscryptographyelementary-number-theorymodular arithmeticprime numbers

The plain text message $\text(BAHI)$ encrypted with $\text(RSA)$ algorithm using $e=3, d=7$ and $n=33$ and the characters of the message are encoded using the values $00$ to $25$ for letters $A$ to $Z$. Suppose character by character encryption was implemented. Then, the Cipher Text message is

  1. $\text(ABHI)$
  2. $\text(HAQC)$
  3. $\text( IHBA )$
  4. $\text(BHQC)$

My attempt:

Using RSA Decyption

Uses his private key $(n, d)$ to compute $m = c^d \mod n$.

Extracts the plaintext from the message representative $m$.

I assume that : $A-1 ,B-2, C-3 , D-4,E-5,….$ etc (Message Encoded Using $01-26)$. Then,

$B=2→ 2^7 \mod 33 = 29-26=3→C $

$A = 1→1^7 \mod 33 = 1 →A $

$H =8→ 8^7 \mod 33 = 2 →B $

$I= 9→9^7 \mod 33 = 15 → O $

Cipher Text Message : $CABO$.


Also, if I assume that $A-0 ,B-1, C-2 , D-3,E-4,….$ etc ( Message Encoded Using $00-25$ as per question).

Then I will get decrypted message is :$BACC$.

But, no option matched. Official ke is given option $(2)$


Somewhere, it explained as :

For BAHI A-1 ,B-2, C-3 , D-4,E-5,…. etc (Message Encoded Using
01-26)

B=>2=> 27 mod 33 = 8 =>H A => 1=>17 mod 33 = 1 =>A H =>8=> 87 mod 33
= 17 =>Q I=> 9=>97 mod 33 = 3 => C Cipher Text Message : HAQC

A-0 ,B-1, C-2 , D-3,E-4,…. etc ( Message Encoded Using 00-25 as per
question)

B=>1=> 17 mod 33 = 0 =>B A => 0=>07 mod 33 = 1 =>A H =>7=> 77 mod 33
= 13 =>N I=> 8=>87 mod 33 = 17 => R Cipher Text Message : BANR

But, I did not get that his mod operation.

Can you explain it, please?

Best Answer

In RSA when you encrypt the plaintext you actually use $e$ as the encryption key. The key $d$ is used for digital signature (signing padded hashes) since everyone in possession of $e$ can validate those.

If we want to get the ciphertext of $BAHI$ using RSA text book scheme we apply these steps:

$B \rightarrow 2^3 \equiv 8 \pmod{33} \rightarrow H$

$A \rightarrow 1^3 \equiv 1 \pmod{33} \rightarrow A$

$H \rightarrow 8^3 \equiv 17 \pmod{33} \rightarrow Q$

$I \rightarrow 9^3 \equiv 3 \pmod{33} \rightarrow C$

So the ciphertext will be $HAQC$. Hope this helps.

Remember that you always publish $e$ to everyone you want to communicate to and that $d$ remains unknown for them. If you use $d$ as encryption key then everyone will decrypt whatever you encrypted and this is not desirable in an encryption scheme.

Related Question