I have the exponent $e=2^{16}+1$ and modulus $n$ (154 digit number) of an RSA public key along with the ciphertext (64 bytes) encrypted using the same key with RSA/ECB and no padding.

I am required to decrypt the ciphertext and have two options:-

  1. Find the prime factors of $n$, $p$ and $q$, to determine the private key which can then be used for decryption, or

  2. Use a dictionary attack (~135k words)

The first option does not seem feasible to me considering how big the modulus is and so I think the second option is more likely.

My question then is, where would I begin with a dictionary attack on the above cipher text? My initial idea is to iterate through every word in the dictionary, encrypt it using the public key above and check to see if the cipher text contains the result, but words in the dictionary have lengths up to 30 so this would definitely take a while.

up vote 4 down vote accepted

If the public modulus was generated properly, option 2 (brute force dictionary search of candidate plaintext) will be faster. Option 1 (factoring a ≈512-bit RSA integer) is feasible, but can be quite compute-intensive even with the best known algorithm (GNFS). On the other hand, if random padding was used (as it should, and would be in any good practice), option 2 would not be feasible.

First things are to determine how exactly a dictionary word would be encrypted, including formatting of the ciphertext.

I think Python 3 might be acceptably fast just checking if pow(m,e,n)==c where m varies over the plaintexts appropriately converted to integer as in the encrption, and c is the ciphertext appropriately converted back to integer. For (perhaps only slightly) better speed, write a compiled program using GMP.

  • 1
    Thanks a trillion, using pow() and converting the ciphertext back to an integer was just what I needed. I managed to successfully decrypt the word :) – 2nce Dec 3 at 13:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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