I am trying to implement a password manager in C and I had a question about the proper steps in implementing the crypto. I looked at some implementations, google talks on crypto and what the standards are.

so I just wanted to list out the steps in the program and I wanted to make sure I was doing it right.

  1. If its a first time the program is being used, it will ask the user for a password to use
  2. This password will then be hashed with some algorithm (SHA1?) and then stored in a file
  3. Then a password storage file is created and the user can add, delete or view the entries
  4. When the user is done, the password storage file is encrypted (use the user password as input to openssl, openssl aes-256-cbc -salt -in test.txt -out test.aes, this is from the command line...I'd have to do the equivalent in C)
  5. exit
  6. when the user reopens the application, the user password is checked against the stored hash
  7. if it passes, the password is sent to openssl to decrypt the password storage file
  8. the user does some stuff and exits, the password storage file is reencrypted

So what do you guys think? Let me know if there are C specific crypto resources I can use. Thanks for your help!

  • 3
    $\begingroup$ You are missing a critical point: given the hash of a password that most humans can remember, it is possible to find the password. There's an industry doing that, and variations. That's why we have password-based key derivation functions, and key stretching. Investigate scrypt. $\endgroup$ – fgrieu Apr 21 '14 at 7:24
  • $\begingroup$ i found this to be a helpful resource crackstation.net/hashing-security.htm $\endgroup$ – jti107 Apr 22 '14 at 6:00
  • $\begingroup$ I disagree with one sentence in the FAQ: (for password protection on a server) "What hash algorithm should I use? (..) Any modern well-tested cryptographic hash algorithm, such as SHA256, SHA512, RipeMD, WHIRLPOOL, SHA3, etc". This particular alternative forgets key stretching and is thus poor advice (other alternatives given in the same list are much better). $\endgroup$ – fgrieu Apr 22 '14 at 6:11