Here's a question. I have a file that have to be encrypted with strong cipher (I've choosen AES-CTR-128). I'm using MVC 2019 to compile C++ program. Firstly, I create RSA-2048 key pair (public and private), then I read all data from file to buffer (filesize ±300kb), encrypt with AES-CTR-128 buffer with data from file, encrypt key and nonce used for AES-CTR-128 (I'm using WinAPI function CryptGenKey() to create random key and nonce) with public key of RSA-2048 generated previously, write encrypted key and nonce to the end of file.

Is there any possibility to get original data if attacker don't know key+nonce and RSA-2048 private key?

I know that original text can be changed even if it was encrypted, but it doesn't matter. Also, I know that I can skip encryption of nonce, but... better it will be safe.

  • $\begingroup$ possible duplicate of Is encrypting a file with AES-CTR and then encrypting the AES key with RSA-4096 secure? $\endgroup$
    – kelalaka
    Jan 14, 2020 at 10:31
  • $\begingroup$ it's not an answer :( $\endgroup$
    – veter0
    Jan 14, 2020 at 10:40
  • $\begingroup$ The link points to a question that kelalaka has answered, the question is basically the same as yours. $\endgroup$
    – SamG101
    Jan 14, 2020 at 10:44
  • $\begingroup$ Two things: your RSA key size is about as small as I would still feel comfortable with, using RSA-4096 should be preferred. Furthermore, I would try and validate if your decryption exposes an RSA padding oracle attack such as the Bleichenbacher attack. You didn't specify the RSA padding mechanism, but I would recommend OAEP over PKCS#1 padding for most ops. $\endgroup$
    – Maarten Bodewes
    Jan 14, 2020 at 10:49
  • 1
    $\begingroup$ @veter0 Please indicate why you think that the question that kelalaka pointed out doesn't represent an identical question and answer for you. Even the attack I've pointed out is in there. What parts are you still unsure of? $\endgroup$
    – Maarten Bodewes
    Jan 14, 2020 at 10:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.