im try develop a encryption app for android by using AES algorithm ,where should i store the key. the idea is that the user provides a password and a key is generated.how can i do this process safer.thanks in advance
2 Answers
im try develop a encryption app for android by using AES algorithm ,where should i store the key. the idea is that the user provides a password and a key is generated
Then you do not store the key. When the user supplies the password -- either for the initial encryption or for later decryption -- you generate the key from the password.

- 986,068
- 189
- 2,389
- 2,491
-
Question: what do you do with the key generated via PBKDF2 if you want to use it for decrypting later? – Joe Plante Mar 08 '13 at 20:27
-
@JoePlante: I suspect that you attached your comment to the wrong answer. – CommonsWare Mar 08 '13 at 20:29
-
Ah, I'm thinking of another situation – Joe Plante Mar 08 '13 at 20:32
As @CommonWare indicates, you should generate a key from the password. The correct way to do this is using the PBKDF2 algorithm together with a salt (*). There are other good algorithms such as bcrypt and scrypt, but PBKDF2 is the most established standard. For Android implementations, see PBKDF2 function in Android.
(*) The salt is a random number that is required as part of the PBKDF2 algorithm. This salt is not a secret; you can store it any way you like. But you need to keep track of it for later decryption. Typically you prepend the salt, along with the random IV used by CBC, to the ciphertext when you store it.

- 1
- 1

- 286,113
- 34
- 456
- 610