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?

  • $\begingroup$ Isn't n supposed to be the product of two primes? It can't be 33. Do you have any extra information? $\endgroup$ – zzz Jan 5 '17 at 2:01
  • 1
    $\begingroup$ $33=3\cdot 11$ it is a semi-prime number (product of two primes). So it can be used perfectly for this example. $\endgroup$ – kub0x Jan 5 '17 at 2:03
  • $\begingroup$ BTW I hate these RSA-examples where they basically reduce RSA to a mono-alphabetic cipher, where they even hive you the key! (just compute all 26 possible ciphertext letters). It defeats the whole purpose of public key crypto. $\endgroup$ – Henno Brandsma Jan 5 '17 at 5:03

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.

  • $\begingroup$ Thanks for nice explanation. $\endgroup$ – 1 0 Jan 5 '17 at 2:05
  • 2
    $\begingroup$ Your last explanation is incorrect. You should publish $e$ to everyone you want to allow to communicate to you. To encrypt a message, you should use the $e$ published by the person to whom you are writing. You never encrypt a message with your own $e$ as you would be the only one able to decrypt it. The keynote is that you don't publish anything (any key) to someone in order to communicate to them; you must await their publication of a key that you can then use. $\endgroup$ – Wildcard Jan 5 '17 at 2:10
  • $\begingroup$ I haven't specify in my explanation that you use your own $e$ to encrypt plaintexts for others. Of course you use others public exponent to encrypt, since they have to be able to decrypt those ciphertext with their own $d$. My last paragraph enfatizes that publishing $e$ to everyone means that others will use your $e$ so you can decrypt with your own $d$. Sorry if it sounds messy but I've expertise on this field. $\endgroup$ – kub0x Jan 5 '17 at 2:15
  • $\begingroup$ @kub0x, I have stated that "Somewhere, it explained as :" on my this post. Is his approach correct? $\endgroup$ – 1 0 Jan 5 '17 at 2:21
  • $\begingroup$ @MithleshUpadhyay: Yes it is correct, the first one using charset from 01 to 26 is the same as my answer, the second one is also correct but the difference in the charset is that he is using numbers from 0-25 so he gets $BANR$. $\endgroup$ – kub0x Jan 5 '17 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.