Score:0

RSA not encrypting properly when e=d?

jp flag

I'm trying to implement the RSA algorithm with some random (valid as far as I know) generated values but for this combination, encryption/decryption doesn't work.

message = 324
p = 3
q = 29
n = 87
e = 15
d = 15

Which give both and encrypted and decrypted answer of 63

I'm guessing I made and error while generating the values but I don't exactly know where.

I know e and d shouldn't be equal for security reasons, but from my understanding encryption should still work.

Daniel S avatar
ru flag
It does work in the sense that 324 mod 78 is 63. RSA cannot cope with messages large than the modulus and at best the remainder of the message with respect to the modulus is returned.
kelalaka avatar
in flag
I've failed to find a dupe ( hope one can find one or someone wants to write an answer). Remember $c = m^e \bmod N$ so RSA is performed under modulus...
Score:4
cm flag

I believe the problem is linked to the size of the message rather than the choices of $e$ and $d$.

When deciphering a message, we don't get the result of the message m but rather m mod N. With $N$ being 87.

If the size of the message is smaller than N then we know that $m = m \bmod N$, however this does not happen otherwise.

Observing this example in particular we have that $63 = 324 \bmod 87$, and so the deciphering process acted accordingly with the expected.

As for why the encrypted value is also 63 I believe it was sheer misfortune. The keys and N are quite small, so the chance for suspicious combinations is higher than with real parameterizations.

I may be missing some forbidden pattern in the choice of message, given that the calculations only apply to $m < N$, but if the program works for messages lower than 87, then there should be no problem in having $d = e$.

Don Freecs avatar
sz flag
what about an attacker who uses always d=e as a first test attack ? is it indeed a problem ?
jp flag
@DonFreecs why d=e though? same chance of success as if you try d=1 or d=3 or d=12345 or d="hello I am an insecure key"
Don Freecs avatar
sz flag
@user253751 indeed so it is a problem to use it ^^
Pedro Campones avatar
cm flag
For most values of p and q, it's not possible for d=e. In order for RSA to work it's necessary that *de = 1 mod (p - 1)(q - 1)*. The higher the value of N, the lower the likellyhood of this happening.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.