3 ms·
A nice tool to play with and to make ppl see how easily home-grown crypto can be broken and why those simple hash(secret || data) constructions are not a replac
by pointernil 13y ago
A nice tool to play with and to make ppl see how easily home-grown crypto can be broken and why those simple hash(secret || data) constructions are not a replacement for a true HMAC implementation.
Note to self: Again, never ever implement your own crypto. Ever.
- Strilanc 13y agoI can easily imagine someone thinking that "crypto" covers the choice of hash function, but not the prepend-secret-and-hash construction. (I'm actually not sure how to quantify what is and isn't crypto, in a way that's easy for a beginner to understand.)
- pointernil 13y agoAgree. Well, maybe stating, that RNGs, hash functions (and XOR ;) are just building blocks and tools to build true functionality out of them, would help. I see it quite similar to statistics. Yes I do know and understand mathematical operations, "numbers" and some statistical operations like average, median and maybe even variance but no way I'm capable to setup a proper statistical trial or analysis. I tend to fall back to: describing what I'd like to achieve with what kind of properties of the result and let ppl really knowledgeable on the topic find the correct keywords, tools and in the end algorithms. But boy is it tempting to just mash some hash functions together based on some actually quite naive understanding of their properties ;)
- DenisM 13y agoI think I know: only use as directed. Only use a crypto component for the exact purpose that is stated on the tin. Hash function turns lengthy text into a short unique digest. That's the only thing you can use it for. If you try to use it for any other purpose, you will likely screw it up.
- Strilanc 13y agoSure, but you need to then do something with that digest. Store it, compare it against other digests, etc. Whether or not those actions constitute "crypto" is hard to determine. For example, git uses SHA-1 digests as unique identifiers for commits. Isn't that extending hash functions from unpredictable digest to identity? What happens when someone finally finds a SHA-1 collision? When Linus made that choice, was he breaking the rule about writing your own crypto?
- DenisM 13y agoHe was inventing his own crypto. The point is not to avoid design decisions that reinvent crypto, the point is to recognize that's what you're trying to do and seek expert help to guide your hand.
- finnw 13y agoI don't imagine many developers see hash(secret||data) as a replacement from HMAC. I made that mistake once, but I had not yet heard of HMAC at the time.
- pointernil 13y agoYup, that's exactly the point! Quite some developers are re-inventing this kind of things without knowing how their solutions are lacking. It's tempting and fun and in the end in case of crypto insecure.