for example: if we have public key : (5,221) and private key : (77,221) and we want to encrypt 1:

c(m) = (m)^p mod n 
c(m)=(1)^77 mod 21 =1

so how to deal with that? is there some work around ?

  • $\begingroup$ How to deal with what? The encryption of 1 is 1, so what? $\endgroup$
    – fkraiem
    Commented Aug 21, 2017 at 1:29

1 Answer 1


The algorithm you quote is usually called textbook RSA and is not used in practice for numerous security reasons (the problem you pointed out, is just one of them).

In practice, you have to pad (or armor) your message. This should be done using the RSA-OAEP (also called PKCS#1 v2.0) scheme. It transforms your message (1) into a pseudorandom block (not 1) which is then processed by the RSA encryption.

  • $\begingroup$ could you include example with your answer please ? $\endgroup$
    – Mr.lock
    Commented Aug 20, 2017 at 16:58
  • 6
    $\begingroup$ @Mr.lock OAEP uses cryptographic hashes and requires realistic key sizes, so there is little point in posting an example. $\endgroup$ Commented Aug 20, 2017 at 18:35
  • 1
    $\begingroup$ You can take a look at some test vectors, that the message is a single byte with value 1 won't make much of a difference within the calculations that need to be performed $\endgroup$
    – Maarten Bodewes
    Commented Aug 20, 2017 at 21:04
  • $\begingroup$ You could post a practical example of RSA-KEM! That's much simpler than the rigmarole of RSAES-OAEP. $\endgroup$ Commented Aug 21, 2017 at 1:56
  • 1
    $\begingroup$ It’s not random if it’s deterministic and reversible $\endgroup$
    – Cole Tobin
    Commented Aug 21, 2017 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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