I'm developing an application that automates processes. The user connects to many accounts that the application uses then passwords are encrypted using AES. An example algorithm looks like this:

  1. When user add an account, password hash will generate
    • AES(password, SHA1(accountLogin) + SHA1(accountPassword) + SHA1(pin))
  2. Then this encrypted string is stored in the local database
  3. To decrypt this string, the user needs to be logged into the app, and user need to pass pin code which is not stored anywhere

Is it secure to store this password's encrypted string in the remote database so users can use the app on different devices? This is so that they don't need to provide the passwords for the accounts in the application.

  • 1
    Partially depends on how the encryption key is derived. Can you elaborate on that? – Ben Aug 29 at 12:39
  • App uses user login credentials, encrypted credentials are stored in the app session memory, user choose own pin-code which is not stored anywhere, pin-code is needed when user add a new account or want to use saved account's password - app will show prompt to user for the pin-code – Aleksander Niedźwiedź Aug 29 at 13:05
  • 1
    which is the master password? that makes a big diff. you don't want the only obstacle to be a sha1'd pin that anyone can bruteforce. that's a long password as well, and very quick. I would KDF both the hash stack and whatever raw password that is before feeding it to AES. – dandavis Aug 29 at 16:55
  • AES is the foundation of most modern encryption, but the raw AES operation have various vulnerabilities that makes it not secure enough for modern best practice. Depending on the cipher mode, KDF, password generation, and various other little tweaks, your AES-based encryption can range from very secure to ok but not very much. Better to use established high level libraries like GPG or OpenSSL or cryptography to provide your encryption and learn a little bit about the various trade offs between different cipher modes (and which cipher modes are just to avoid entirely). – Lie Ryan Aug 30 at 8:31
  • So, the encryption key for the AES encryption that protects a login password, is derived from a PIN using just SHA1? Then stored to a file/database? Nope, not gonna work, needs a better KDF. – Ben Aug 30 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.