I'm trying to apply the RSA cryptosystem to encrypt a byte M=72, using predefined modulus n, public key exponent e and private key d.
(n, e, d, p, q) = (4802, 5, 59, 43, 8)
In order to accomplish that, I used the following code on Python console:
C=(M**e)%n
M=(C**d)%n
print M
- the first instruction encrypts the byte as C: using the RSA encryption mathematical expression (
**stands for exponentional, and%for modulus in Python programming language) - the second decrypts C to get M back: using the RSA decryption mathematical expression.
However, the output shows:
2816
which means that M was incorrectly computed as '2816', although I'm pretty sure that all the values of n, e, d, p and q respect the RSA public key algorithm specification.
Does anyone have any idea?
n. – user6039980 Oct 21 '18 at 17:16p*qis different fromn, andqis not prime number. – user6039980 Oct 21 '18 at 17:18nis some million (.. dozens words "million" suppressed) million times too small to provide security. B)M=(C**d)%nwon't work even if you increasenby a million million. See modular exponentiation or/and use the three-argument form of pow. C) With the question's textbook RSA, a message guess can be checked; think of e.g. a name on the class roll. See encryption padding. – fgrieu Oct 21 '18 at 19:42C**dperforms the exponentiation and%napplies the modulus. Why it won't work if n is increased by million? A+C) I'm not understanding what you're talking about. sorry. – user6039980 Oct 21 '18 at 20:59C**dexactly fornlarge enough for security, which implies nearly as largeCandd. Modular reduction must be applied as the exponentiation is performed. Three-argumentspowdoes, but(C**d)%ndoes not. On A):nneeds to be MUCH larger, otherwise it can be factored and an adversary can then decipher just as easily as the legitimate recipient. On C): with the question's textbook RSA, if you know that the name of a student is enciphered, you can encrypt each name on the class roll and see which matches the ciphertext. – fgrieu Oct 21 '18 at 21:56