So here's my problem: I have 3 files. One is ciphertext.enc, which is a text encrypted using AES 256. The second one is key.cipher, which is ciphertext.enc's key. This key.cipher was encrypted using a public RSA key. The third file is pub.key, the public RSA key used to encrypt key.cipher. Is also known that openssl was used to perform these encryptions. No more information is given.

The objective is to obtain the original text contained in ciphertext.enc, but i'm a little lost on how to procceed. I understand the basics behind AES and RSA, but i'm not familiar with them in practice, specially openssl. How should i procceed with this problem?


The pub.key may actually be the RSA private. This is part of an exercise which i couldn't find an answer.

Also, just to clearify the problem: I have a message encrypted with AES. I also have the AES key, but the key was encrypted using the RSA key pub.key (which acording to the exercise is a public key). The objective is to find out what is the message - probably breaking key.cypher in order to decrypt ciphertext.enc.

  • 2
    $\begingroup$ Is that a school/course excercise? As the problem is - lets assume pub.key is an RSA public key nad key.cipher is the encrypted AES key. To decrypt the key.cipher you need a private key (not the public one). So - either the pub.key is the private key (just naming is wrong) or (when properly done) you cannot do much about it. For some excercises (homeworks) there are apparent weaknesses/mistakes, but that is not obvious in your question. Or - maybe the key is already decrypted (available), however without proper encryption mode you may just guess (try all available) $\endgroup$ – gusto2 Nov 23 '17 at 8:26
  • 1
    $\begingroup$ I'm voting this as "unclear what you are asking" for the reasons gusto2 gave. Basically you are asking to reverse AES or RSA without the secret or private key. Well, that's not possible unless there were mistakes during key generation or encryption. $\endgroup$ – Maarten Bodewes Nov 23 '17 at 11:47
  • $\begingroup$ Yes, it is an exercise, but i found no answers to it. It was said that key.cipher was encrypted with a public RSA key and this key is contained in pub.key. I'll update OP saying it may be the private key, but this isn't what the problem say. Also will try to be more specific about what i need. $\endgroup$ – Fuga Nov 23 '17 at 17:25
  • $\begingroup$ How big is N in the public key? - A real life N would be 1000+ bits, but if your N is more in the range of 100 bits, then factoring N to break the RSA key becomes much more feasible $\endgroup$ – Eugene Styer Nov 23 '17 at 17:38

There are weak RSA keys which can be factorized.

You could test if this public key belongs to a weak private key and thus calculate the private key. I didn't dive into it yet, but you can take a look here.

ps. Can you link the exercice? I also would like to look into it :-)

  • $\begingroup$ I created a repo at GitHub with both the problem and the solution. Thank you! $\endgroup$ – Fuga Nov 25 '17 at 21:17

Found a solution using this method to get the private RSA key. Then i used the key to decrypt the AES key and finally the message. For those interested, both the solution and the problem can be found here (i'll translate it to english later).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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