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?

UPDATE

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
    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) – gusto2 Nov 23 '17 at 8:26
  • 1
    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. – Maarten Bodewes Nov 23 '17 at 11:47
  • 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. – Fuga Nov 23 '17 at 17:25
  • 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 – 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 :-)

  • I created a repo at GitHub with both the problem and the solution. Thank you! – Fuga Nov 25 '17 at 21:17
up vote 0 down vote accepted

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

 
discard

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.