News for hackers. Stuff that matters.
Re:How to prevent cryptographic pitfalls by design [video] by tptacek on Thursday February 07, 2019 @10:48AM (#19105893)
Problem (a) is pretty silly. If you use a library with a vulnerability in it, you need to be prepared to upgrade the library. How many people using (for instance) Markdown libraries understand how their library handles memory management or recursion? Meanwhile, the alternative in cryptography is hand-hacked direct-to-primitives coding that is likely to create more bugs. Further, the primitives that are most likely to "need swapping" aren't algorithms (AES and SHA2 may never fall, just like 3DES, but for its block size, still hasn't) but constructions, which are hidden in hand-rolled crypto code.

If you "scramble to get algorithms together because you know them" and use AES-256-CTR with HMAC-SHA256, in my experience auditing crypto code, you're very likely to have scrambled together at leave two game-over crypto flaws that libraries like Tink and libsodium avoid for you.

Re:How to prevent cryptographic pitfalls by design [video] by throwawaymath on Thursday February 07, 2019 @03:09PM (#19108095)
While I agree with your second paragraph, I don't think you need it to justify the position that

    crypto.secret_box.encrypt
is almost always better to use than a combination of

    crypto.primitives.aes.ctr
and

    crypto.primitives.hmac.sha256
Aside from the obvious argument that rolling your own cryptography is dangerous, at a more abstract level you just generally don't want to work with raw primitives in most types of software. Specialization isn't just the lifeblood of the economy, it's also the way software productivity works. If your core competency isn't X, why should you be re-implementing X using its raw primitives? You should generally be importing known-good library implementations if possible. Even in adversarial scenarios (like cryptography) this principle remains the same.

Given that I don't really understand the parent commenter's point. You touched on this a little with your example of a Markdown library - as software engineers we use things which are substantially black boxes all the time. It seems strange to me that you'd want to do surgery on the raw primitives of a library instead of updating it to suit your needs. In this case, that means just use a reputable crypto library and update it when there's a reported security vulnerability.

You don't even need to buy into, "Don't roll your own crypto" to lean into this.

Re:How to prevent cryptographic pitfalls by design [video] by tptacek on Thursday February 07, 2019 @03:31PM (#19108288)
I took the original argument to be "if you use secret_box, you don't even know that you're using Salsa20, so if a cryptanalysis of Salsa20 is published, you might not realize and know to fix that problem".

Which is, I think, a silly argument; if someone finds a stack overflow in a Markdown library, I still need the maintainers of that library to tell me about it --- nobody is going to tell me about it directly. I have more information to act on in the secret_box scenario, not less.

But I was a little confused by the argument too, so maybe I'm not making that much sense either.