4 ms·
Cryptographic Right Answers
- sunir 17y agoPossibly truly stupid question, but what is the attack on md5ing passwords if you also generate a random salt for each user? I could not find anything online in the past ten minutes that suggests an attack, except for the md5 collision problem. I don't understand the collision problem very well either. I know it's been used to crack a certificate here or there, but it seems like it took a lot of resources to crack one password.
- tptacek 17y agohttp://www.matasano.com/log/958/enough-with-the-rainbow-tables-what-you-need-to-know-about-secure-password-schemes/ http://www.matasano.com/log/958/enough-with-the-rainbow-tabl...
- sunir 17y agoThomas, thanks. That was immensely helpful. Now I have to figure out what I want to do going forward. At least I already have per-user random salts.
- jameskpolk 17y agoThe collision problem is a huge deal. You can no longer trust a MD5 signed object. http://www.mscs.dal.ca/~selinger/md5collision/ http://www.mscs.dal.ca/~selinger/md5collision/ has some great, and very scary examples.
- cperciva 17y agoThis was largely inspired by Thomas's blog post yesterday about AES vs. RC4 -- he started me thinking "gee, someone really should sit down and tell people what they should be using so that they don't keep doing dumb things like using RC4".
- polos 17y agoThe overall message is: I trust human intelligence -- and this is positive (iff you're actually using your intelligence). In contrast, most crypto rants fall into the "laugh at them, as they're all equally stupid" trap, which is not going to change humans into better...
- tptacek 17y agoIf you're trained and experienced, there is probably nothing about performing standard appendectomy to challenge the intellect. But you're crazy if you think that optimism about human intelligence is enough to allow an ordinary smart person --- or maybe even an ER nurse --- to conduct one based on a guidebook.
- by 17y agoThere are things to be learned from the article at more levels than just the design of new protocols. For example, I would say this good advice that applies to ordinary smart people: "Do NOT store users' passwords. Do NOT hash them with MD5. Use a real key derivation algorithm. PBKDF2 is the most official standard; but scrypt is stronger. Please keep in mind that even if YOUR application isn't particularly sensitive, your users are probably re-using passwords which they have used on other, more sensitive, websites -- so if you screw up how you store your users' passwords, you might end up doing them a lot of harm."
- tptacek 17y agoFirst, I'll quibble with some of these recommendations --- even though Colin (and Alex Ross, and probably Bruce) is more qualified to have an opinion here. For instance, CTR+HMAC is a weird recommendation. Not because of speed (though HMAC does pessimize speed) and not because of cryptographic strength, but because it introduces another moving part in your design. Colin can deal with the junction between plaintext, ciphertext, and HMAC, because this is mostly all he thinks about. You can't. A simpler recommendation would have been to use CCM or EAX mode. These have the advantages of being NIST standards-tracked and heavily vetted, and of providing both authentication and encryption in the same construction. If your libraries are good, you get both these features just by switching the name of your block mode. Second, I'll quibble with the content of the post: these recommendations are exactly what Nate was talking about in his Yahoo talk about how bad cryptographic guidance has gotten. Key size and hash function selection (as long as you're not using MD5) are the least important design considerations you have. Here's a design consideration this post doesn't even touch on: renewability. How do you safely design a system so that your selection of algorithms, modes, and key sizes isn't set in stone? Because if you don't get that right today, what you inevitably do to handle it 2 years from now is going to be a vulnerability. Finally, a real concern about the structure of these recommendations: telling people to keep group negotiation out of Diffie-Hellman protocols is fine --- a good recommendation, since there's a really scary sounding, really easily-exploitable vulnerability that eliminates. But that's --- I think --- the only place in this post where Colin actually addresses something that actually does go wrong in crypto protocols. If you follow all of Colin's recommendations here from scratch in a reasonably complicated, and you have never found a crypto vulnerability or fixed two reported crypto vulnerabilities, I will bet $500 that you end up with a broken system. Colin won't. But you will.
- tptacek 17y agoOh and another thing Colin, you jerk: All of your recommendations die in embedded applications, where nobody will use HMAC-SHA256 (or SHA256 at all) or RSA. ;)
- cperciva 17y agoThis depends on how small your embedded systems are. If your system is too small to run RSA, it's probably too small to use any asymmetric crypto; and if it's too small to use HMAC-SHA256, it's probably too small to use any crypto at all. There are certainly applications where I would revise my recommendations, but embedded isn't particularly one of them.
- artlogic 17y agoCan anyone explain: "Client-server application security: Distribute the server's public RSA key with the client code, and do not use SSL." It seems like the point of this is to make sure that when communication moves from the client, only the server with the proper private key can decrypt it - BUT, aren't you just going to use OpenSSL to implement this (via TLS)? Is there some other way to accomplish this I'm not aware of? What's he specifically warning us against?
- cperciva 17y agoI'm warning you against using a complex and error-prone protocol where you don't need all the complexity. You might end up using OpenSSL anyway, but using OpenSSL to perform an RSA encryption is vastly safer than using OpenSSL to verify a certificate chain.
- CrLf 17y agoImplementing your own protocol is far worse than taking SSL and all its "complexity", which is there for a reason. In fact, never implement your own cryptographic protocol unless you _really_ have to. And even then, think twice.
- cscott 17y agoI'm concerned about the lack of revocation that comes with bundling a key in source. Shouldn't you warn people in your note that if the key is compromised, you're going to have a difficult time?
- cperciva 17y agoYou should already have a mechanism in place for alerting people to vulnerabilities in your client code -- for all practical purposes, a compromised server key is just a vulnerability in the client code which needs to be corrected by upgrading to a newer version of the client.
- rcoder 17y agoThis is all the more critical when you consider how the usual web developer handles the complexities of chained certificate verification: namely, by disabling verification entirely, and instead trusting every upstream certificate as offered. For example, as of Rails 2.3, ActiveResource (the default RESTful web service API client used in many Rails applications) disables all SSL verification whenever SSL is used, without so much as a configuration flag to enable it again.
- sweis 17y agoThis is a good post, Colin. One thing people reading it may not realize is the importance of picking good IVs and the necessity of including them in the MAC. Someone might just authenticate the ciphertext and neglect to include the IV, leaving themselves open to a few attacks.