4 ms·
Not a very helpful way to express the advice; if you tell people "don't hash secrets" the natural interpretation is "send them in the clear". HMACs have their
by lmm 13y ago
Not a very helpful way to express the advice; if you tell people "don't hash secrets" the natural interpretation is "send them in the clear".
HMACs have their use case, and it's good to use them for that, but honestly it's a tiny corner of the possibilities for "hashing secrets", and an effective approximation (hash(message + hash(secret)), as mentioned towards the end of the article) is the obvious approach if you have any idea how hashes work, and just as effective as a dedicated HMAC.
- Skalman 13y agoI think the point is that that is not necessarily true for all hash functions, since reordering your example with SHA1 renders it weaker. If I understood correctly sha1(sha1(secret) + message) is not safe, because from that hash you can calculate sha1(sha1(secret) + message + ANYTHING)
- Mindless2112 13y agoSo why not sha1(sha1(secret) + sha1(message))? Or is that essentially an MAC?
- StavrosK 13y agoOne rule of thumb I've discovered: Whenever you say "why not X?", where "X" is some nonstandard construction, the answer is "because X is horribly broken in ways you can't even imagine".
- tptacek 13y agoFor one thing, you're incurring one more SHA1 invocation than you need; for another, you're clumsily duplicating HMAC, which has other security features (albeit not hugely practical ones). But the core feature of HMAC is indeed hashing the secret separately from the message.
- tptacek 13y agoCorrect; H(H(secret) || message) just scrambles the secret, but doesn't change the MAC construction.
- jessedhillon 13y ago...if you tell people "don't hash secrets" the natural interpretation is "send them in the clear" What? When you see a sign by the pool that says "Don't Run" do you get down on your belly and start crawling? Some assumptions are safe to make -- e.g. most people who care enough to read this know not to send secrets in the clear.
- StavrosK 13y ago> Not a very helpful way to express the advice; if you tell people "don't hash secrets" the natural interpretation is "send them in the clear". Yeah, a better title would be "Don't just hash secrets."
- kmm 13y agoIt's terrible advice, just like that "Don't do cryptography" from some time ago. It just seems like people are trying to be too clever. I admit I learned something, but the tone of the article could be better.
- baddox 13y agoI don't think that anyone who understands what "hashing secrets" means would think that "don't hash secrets" means "send them in the clear."