Mini RSA
Problem
What happens if you have a small exponent? There is a twist though, we padded the plaintext so that (M ** e) is just barely larger than N. Let's decrypt this: ciphertext
Solution
I spent a while (2 hours) searching for resources to solve this. However, this Cryptography StackExchange comment is where I found the solution. Other helpful resources include: RSA Padding Schemes - Wikipedia, Cryptography StackExchange 1, Cryptography StackExchange 2, and Cryptography StackExchange 3
Without padding, encryption of
m
ism^e mod n
: the messagem
is interpreted as an integer, then raised to exponente
, and the result is reduced modulon
. Ife = 3
andm
is short, thenm^3
could be an integer which is smaller thann
, in which case the modulo operation is a no-operation. In that case, you can just compute the cube root of the value you have. However, we cannot simply computec^(1/3)
(wherec
is the ciphertext) because there is a slight amount of padding to the message to makem^e
larger thann
, which makes the modulo operation take effect.With a short
m
slightly wider thann^(1/e)
, which is what we have, we are givenc = m^e mod n
and can find by enumerationk
such thatk * n + c
is ane
th power: thenm = (k * n + c)^(1/e)
.We can use python and write a solution script to search though thousnads of values for
k
until we find one that contains the start of the flag. When we find the padding amount, we can increase the precision and rerun the calculation to get the entire flag. Keeping the precision high enough just to see the beginning of the flag speeds up the enumeration ofk
.
Flag
picoCTF{e_sh0u1d_b3_lArg3r_a166c1e3}
Last updated