2

I have recently starting looking into AES encryption for a side project. I am researching this till now so if there is something wrong about my concept please correct it.

According to me If i want to encrypt something in AES I have to encrypt it by a 128bit key which The user must preserve for encryption and decryption of data.

Two options that I by now came to know after my research are PBKDF2 and bcrypt I am still to try implementation. so, I thought of asking here first.

So for my project I have two options that I generate that key and tell user to preserve that key which will be my plan B. I wanted to generate a key using user login details which will be generated every time user logins he can use that key for encryption and decryption.

But I cannot figure out a way to convert credentials into 128bit key.

Thank you for any support. I possible can anyone please refer some resources for learning about AES more.

1 Answer 1

1

As in the question use a key derivation function such as PBKDF2 or better yet if available Argon2.

Just feed in the login credentials along with a random value, the random value can be saved with the credentials, it just ensures that the same credential from another user will not produce the same key. The key derivation function will provide the key of the appropriate size.

But keep in mind that getting encryption correct (secure) is hard, if this is a real project get your scheme and code reviewed by a seasoned crypto expert.

5
  • bcrypt isn't designed to be a KDF. However it might still be better than PBKDF2 with a tiny hack like truncate(sha512(salt, password, bcrypt_output), 128), Nov 24, 2018 at 1:21
  • Thanks ! It's just my small side project. So, I guess its nice time to just experiment with It. Still finding resources for better learning hope I can get project started soon, Thanks anyway. :)
    – SOMEONE
    Nov 24, 2018 at 10:22
  • Correct, removed bcrypt. As for PBKDF2 some major platforms (Apple) still do not provide Argon2 or the SHA3 series.
    – zaph
    Nov 24, 2018 at 16:16
  • @FutureSecurity why the truncation? (asking for a different situation). If someone was doing a dictionary attack, could they not simply see if the hash occurs in their output?
    – J.A.K.
    Nov 24, 2018 at 20:18
  • @J.A.K. SHA-512's output is larger than 128 bits. (The desired key size.) You could safely use any size up to 512 bits. If you're doing password hashing for the purpose of validating logins instead of key derivation then plain bcrypt is enough. The extra hash randomizes and de-biases the concatenated string. I believe it should be at least as unpredictable as sha512(salt, password) while taking at least as much effort as bcrypt to test a candidate password. Nov 24, 2018 at 21:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .