0

My algorithm is basically as follows :

input password
hash(password)
AES on file using the hash

in this case, does the hash algorithm matter as long as it's distribution is somewhat uniform?

would some weak algorithm like md5 be fine, or should a better algorithm be used?

in the case someone tries to brute-force, slower algorithms will perform better, so I'm not taking this into account as it can be offset by using more rounds.

I'm doing that because AES needs a 128 bit key (or 192 or 256), and the user might not want to input a password this size.

4

You shouldn't be using a hash function to derive a cryptographic key from an user supplied passphrase. Instead, use a Key Derivation Function such as PBKDF2.

The following topics explain the topic in more depth:

TLDR; Hash functions are very fast (therefore easier to brute force) whereas key derivation functions are generally much slower and their speed can be adjusted.

  • from what I understand, adding multiple passes and a salt to a hash that has an uniform distribution is kinda like rolling your own KDF, is that so? – satibel Apr 12 '17 at 12:50
  • 2
    @satibel: it's "like rolling your own KDF" in that it's a terrible idea, yes. – dandavis Apr 12 '17 at 19:10
  • @dandavis though it seems to be what VeraCrypt (the successor of TrueCrypt) does : "For standard containers and other partitions, VeraCrypt uses 655,331 iterations of RIPEMD160 and 500,000 iterations of SHA-2 and Whirlpool." so it doesn't seem to be such a terrible idea if implemented right. – satibel Apr 13 '17 at 6:25
  • @satibel "rolling your own encryption" is never a terrible idea when implemented right. The point is in general it won't be implemented right, and if you are asking the sort of questions the OP is, it definitely won't be implemented right. In other words if Joan Daemen or Vincent Rijmen "roll their own encryption" I'll be happy to use it, otherwise not so much. – DRF Apr 13 '17 at 7:28
  • 1
    @satibel: rolling your own surgery, done right, might save a lot, but it's more likely to kill you. – dandavis Apr 13 '17 at 21:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.