# RSA: Know the public key from a pair of plain text and their cipher?

I have two plain texts files cipher with RSA (with the same public and private key) and I have their cipher texts too. Would it be possible know the public key from that information?

My messages have 10 characters and I cannot calculate a huge exponential operation. No padding is used on the messages before encryption.

• What are the ciphertext sizes in bits? What is the source of this question? – kelalaka Apr 29 '20 at 12:50
• Cipher text have a size of 128 bytes. The messages are "First test" and "Second test" – root2d3877 Apr 29 '20 at 13:05
• Suggestion: maybe you converted your plaintexts into integers incorrectly. Did you try little endian or big endian? – user69015 Apr 30 '20 at 12:37

From a couple of plaintext/ciphertext $$(m_1, c_1)$$ and $$(m_2, c_2)$$, then the modulus $$n$$ is a factor of $$\gcd(m_1^e-c_1, m_2^e-c_2).$$ The explanation is that $$c_i = m_i^e - \lambda_i n$$ for some unknown $$\lambda_i$$, so $$n$$ both divides $$m_1^e-c_1$$ and $$m_2^e-c_2$$.
Of course, this solution works if you know $$e$$, but it can be tried with some classically used values ($$e=3$$ for instance).
• The most used value for $e$ is $65537$, so if you can manage exponentiation with it, you may find something. – user69015 Apr 29 '20 at 15:27