I'm working on a new project that encrypts folders on my personal computer.No sending of files are involved(networking). It is only for protection and security. Is it possible to combine RSA and AES for encrypting/decrypting folders with the use of password? (This is only for research purposes)

  • 3
    The question is why? Adding one encryption system on top of another do not consistently increase the difficulty of breaking it. It is better to simply use a longer key. On the other hand RSA+AES is the cornerstone of TLS.
    – grochmal
    Jan 22 '17 at 0:22
  • Because we are required to make a software that would be somehow differ to the other existing folderlock software. In this case,we will make it to the algorithm not in the features of the software. Jan 22 '17 at 0:26
  • 2
    That's a horrible idea. I'd even say that arguing that "my software is better (more secure) 'cause it uses several algorithms at the same time" is false advertising. What you probably want is a feature which public key cryptography has but block cyphers do not. For example: a user that can use one pendrive to store files into the folder/filesystem and another pendrive to retrieve the files from there. That would make some sense.
    – grochmal
    Jan 22 '17 at 0:35
  • Thanks. But really, to make it a good question you do need something like a feature that will combine the good sides of each. TLS uses both 'cause RSA (or any public key crypto) can be used to check someone's identity (through a CA), whilst RSA (or any block cypher) is quicker. Disk/folder encryption hardly has any need for identification (the OS does that already). You're free to use the idea of two pendrives i cite above. But you do need to edit and update your question to include more info (the part about software building for a start).
    – grochmal
    Jan 22 '17 at 1:31
  • 1
    @grochmal: I think you meant: "TLS uses both 'cause RSA (or any public key crypto) can be used to check someone's identity (through a CA), whilst AES (or any block cypher) is quicker."
    – Lie Ryan
    Jan 22 '17 at 3:20

Yes, for sure. This is called a hybrid cryptosystem.

The general scheme is: create an RSA public / private key pair and encrypt the private key with the password. For this you can use password based encryption (PBE). Make sure you use a good KBKDF (more commonly known as password hashing) with a high work factor / iteration count.

You can now generate random AES data keys to encrypt the data. Encrypt these AES keys using the public key of the key pair and store them with the data. If you need to decrypt, decrypt the private key with the password, decrypt the data key and finally decrypt the data.

This is a very common scheme though, which has been used by e.g. OpenPGP for decades. It is still considered secure for in-place encryption. If you need something more secure, you should explain which part of above protocol you consider insecure. There is really no known way of enhancing a protocol already considered secure.

If you want to create something special, use post-quantum cryptography instead of RSA. You could also use only modern constructs such as RSA-OAEP or RSA-KEM and AES-GCM (use GCM with care though, for large files / large number of files).

  • Using quantum algorithms involves hardware right? I originally propose it with quantum algorithm but got rejected because the focus is only on software. While on the other hand, thank you for sharing me on how will RSA and AES will work on file password encryption. Jan 22 '17 at 15:33
  • Sorry if that was not clear, I meant algorithms that are safe against analysis using quantum computing. Those can definitely be implemented in software. Adjusted answer with link. Jan 22 '17 at 15:45
  • I am sorry too. But combining RSA and AES is fine for this case? Jan 22 '17 at 15:54
  • Yep, it's not novel at all, but you can certainly create a secure protocol using RSA and AES for this. Jan 22 '17 at 16:00

Yes, symmetric encryption and assymetric encryption are frequently used in conjunction, and often with hashing and other techniques to achieve a given goal. In the case of TLS, expensive, slow, assymetric encryption is used to agree a fast, cheap symmetric key used for exchanging data. Assymetric keys are usually large and machine generated - to make them available for use but protect them in storage (e.g. in PGP or ssh) they are often encrypted using a symmetric algorithm and a key chosen by a human.

Since they solve different problems, it makes no sense to apply both techniques to the same task.

we are required to make a software that would be somehow differ to the other existing folderlock software.


Even if you are remixing well written encryption software you are likely to end up with something which is insecure. Your question shows that you still have a long journey ahead of you.

The ability to resist decryption depends primarily on the algorithm and key size. How this is packged with other components in a tool can potentially open up side channel attacks (using ecb rather than, say cbc, not using an IV, leaving the plaintext key in a file, exposing a method to subvert key exchange...). Complexity is not the opposite of security, but they are frequently opposing forces.

There are lots of tools written by experts which still have these vulnerabilities. If you want to write something which stands out in the marketplace then try to find a USP which does not involve having to do encryption in a different way from everyone else; everyone else does it that way for a reason.


Sure, that's exactly what web browsers do in HTTPS web pages.

They use RSA (asymmetric encryption) to share a secret key (symmetric encryption with AES) for server-client communications.

  • Is it possible to use it in encrypting folders? No servers are involved. Jan 22 '17 at 7:43
  • Yes it is, but one thing, in RSA encryption your file or data cannot be larger than the public key, that's the reason we use RSA only for documents or sharing keys purpose. Jan 23 '17 at 14:29

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