8 ms·
Nitpick: This includes some attacks that I don't think really ever occur in the real world (bad private exponent size, Franklin-Reiter) and misses one of the g
by tptacek 7y ago
Nitpick:
This includes some attacks that I don't think really ever occur in the real world (bad private exponent size, Franklin-Reiter) and misses one of the great RSA attacks, Bleichenbacher's "rump session" e=3 signature attack, about which there was an excellent NDSS paper (also being presented at Black Hat) just this year.
So I guess I'm saying: RSA is even worse than this blog post suggests.
https://www.ndss-symposium.org/wp-content/uploads/2019/02/ndss2019_04A-4_Chau_paper.pdf https://www.ndss-symposium.org/wp-content/uploads/2019/02/nd...
- philbarr 7y agoWhile the rule for devs is, "never roll your own crypto", what is the authoritative resource for what we should use?
- masklinn 7y ago> Trail of Bits recommends using Curve25519 for key exchange and digital signatures. Encryption needs to be done using a protocol called ECIES which combines an elliptic curve key exchange with a symmetric encryption algorithm. Curve25519 was designed to entirely prevent some of the things that can go wrong with other curves, and is very performant. Even better, it is implemented in libsodium, which has easy-to-read documentation and is available for most languages. (it's unclear from the text whether ECIES is implemented in libsodium or only Curve25519, the internet seems to believe nacl (/libsodium) implements its own superior variant of ECIES called crypto_box)
- lvh 7y agoECIES is part of a family of things that are all more or less just ElGamal with a symmetric primitive attached. libsodium implements one version of that with Curve25519 + secretbox (which in turn is XSalsa20.) It's really mostly just superior in the sense that it's a) fully specified, including test vectors b) all the knobs twiddled for safety, c) incidentally, very performant.
- doomrobo 7y agoI don't think ECIES uses any PKI. The setup is: given a DH pubkey P, generate a DH ephemeral key Q, do the DHKE to derive k, encrypt your message m, then send (Q, E_k(m)).
- munchbunny 7y agoIt depends on what you're trying to accomplish. Rule of thumb is: just use TLS 1.3 if you can. That includes using TLS 1.3 in mutual auth mode if you need to validate both client and server identities. It comes with a lot of PKI for free to help address the "how do you know you can trust the other guy on the line?" problem. If you want the client/server to trust a restricted list of servers/clients, most clients and servers have that capability. If SSL/TLS won't suffice and you just need to create an end to end "thing" with proof of identity, then libsodium is probably fine. If you're looking for a more general purpose crypto library where you need to mix and match algorithms, I'd recommend something like Google Tink (https://github.com/google/tink https://github.com/google/tink), or the high level interface to the native API's that come with the OS. On OS X that's the native security framework (https://developer.apple.com/documentation/security https://developer.apple.com/documentation/security), and on Windows that's the .NET cryptography library (https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=netframework-4.8 https://docs.microsoft.com/en-us/dotnet/api/system.security....). If you need even more flexibility and are willing to do the research to avoid the footguns, there's always OpenSSL/LibreSSL, but that comes with a huge footgun warning.
- loup-vaillant 7y ago> It comes with a lot of PKI for free to help address the "how do you know you can trust the other guy on the line?" I would hesitate to trust a high stakes system (like, controlling a regional power grid) with TLS's default PKI. There are hundreds of certificate authorities out there, all of which can vouch for everything. Compromising one certificate authority is enough to mount a man in the middle attack. Granted, this is not a trivial attack, and TLS as it is now is mostly sufficient for your regular online shopping. More critical applications however need a dedicated PKI.
- munchbunny 7y agoAbsolutely, which is why I included the extra point: If you want the client/server to trust a restricted list of servers/clients, most clients and servers have that capability. If you are running a regional power grid, TLS as a technology is still fine, but you should absolutely not trust the default PKI.
- cobbzilla 7y agoFrom the article: “When e = 3, or a similarly small number, many things can go wrong.“ This seems to be an oblique reference to the attack you were referring to.
- lvh 7y agoThe textbook e=3 attack is Hastad's broadcast attack (on textbook RSA), which is much simpler than the e=3 signature verification problem. (So the article is right that _lots_ of things go wrong, 'tptacek's example is just more exciting and mine is easier to grok :-))
- dguido 7y agoIs that covered in the last paragraph of the public exponent section? I think Ben linked to an older ImperialViolet explanation over that paper, which maybe we should fix.
- commandlinefan 7y agoI was sort of surprised that he wrote a whole blog post about what's wrong with RSA and never mentioned that it doesn't provide perfect forward secrecy - if the private key is ever compromised, every communication that was ever secured using that key can be decrypted after the fact (if we're nitpicking).
- ma2rten 7y agoIs this different with other algorithms, such as the one implemented by libsodium?
- commandlinefan 7y agoIt's different with all Diffie-Hellman key agreements (which I _think_ libsodium's key exchange API uses, although it's sort of difficult to tell for sure from the docs). Diffie-Hellman key agreements generate a new key on the fly and then throw it away so that there's nothing to compromise later.
- floatboth 7y agoYes, of course. It uses X25519 which is an elliptic curve Diffie-Hellman exchange.
- baby 7y agoTechnically not true. You can generate an ephemeral RSA public key.
- samirm 7y agoIt's in the video linked in the post.