Does salt save salt and encrypted file?

I am writing an Android application that is designed to encrypt and decrypt files using AES 256. I use AES-CBC and PBKDF2 mode to get the AES key from a user password. In addition, I create a secure pseudo-random salt for each file encryption key. I store IV and salt with an encrypted file, so I can re-read them and restore the key later to decrypt the file.

My question is: does salt store salt, as well as encrypted file break protection and any value of the salt itself? Could an attacker know the salt and IV make an offline attack against the encrypted file in order to find out the encryption key?

+7
source share
2 answers

The main purpose of the salt should not be secret, but to make sure that the attacker cannot use shortcuts when trying to brute force a password, for example, using rainbow tables (that is, one existing table or a new one to be used for several encrypted files) or forcibly overlay several collected files at once ( which should have different salts).

As long as your password has sufficient entropy, and the number of iterations in your key derivation function is high enough, saving salt with encrypted text is not a problem. Only salt will not allow anyone to decrypt the file.

In addition, if you want to keep the salt secret (then it is usually called โ€œpepperโ€ rather than salt), you will have to think about some mechanism to get the right salt to someone who legally decrypts it.

+10
source

Salt is used for one-way functions, such as password hashing.

Random IV is used for two-way functions, such as data encryption, which can subsequently be decrypted.

Both of them are random bytes and are used to prevent the same information from generating the same result after applying this function. Therefore, if two people choose the same password to store their data and store the same information, the encrypted bytes will be different.

You can save them along with the encrypted file.

Also use more than 1 iteration with PBKDF2, otherwise it will be useless. According to Wikipedia, iOS 3 uses 2,000 iterations, and iOS 4 uses 10,000.

+2
source

All Articles