# Is encrypting data with AES-CTR-128 and keys with RSA-2048 secure?

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.

New contributor
veter0 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• – kelalaka Jan 14 at 10:31
• it's not an answer :( – veter0 Jan 14 at 10:40
• The link points to a question that kelalaka has answered, the question is basically the same as yours. – SamG101 Jan 14 at 10:44
• 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. – Maarten Bodewes Jan 14 at 10:49
• @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? – Maarten Bodewes Jan 14 at 10:51