For ECC with NIST curves, Menezes, Vanstone, et al have a book that gives very explicit step by step implementation instructions.
[0] https://web.cs.ucdavis.edu/~rogaway/classes/227/spring05/boo...
For ECC with NIST curves, Menezes, Vanstone, et al have a book that gives very explicit step by step implementation instructions.
[0] https://web.cs.ucdavis.edu/~rogaway/classes/227/spring05/boo...
Crypto primitives are actually not that dangerous to implement, since there will usually be test vectors and/or other implementations you can check against. You get in trouble if you try to develop your own protocols, make mistakes with parameter selection, and that sort of thing.
Added: Here is some code that needs to be written, if it hasn't been already:
* TLS stack written in Rust, so we don't have to keep using the legacy OpenSSL stack. Or similarly, in Ada.
* SSH stack, same same.
* High speed primitives in RISC-V assembly language, in multiple versions optimized for different architecture implementations
* Lots of weird special primitives used in things like old fashioned payment protocols. I dealt with this somewhat when working on POS terminals.
* Hardware implementations in VHDL and Verilog
* Etc.
I'd feel comfortable working on the first two of the above. Someone has to do it, and we can't always get DJB to do everything, so that leaves people like us.
Still, as much as I think C/C++ are garbage languages, I'd rather have OpenSSL than any alternative that didn't have review by security specialists.
Some fraction of general programmers may also have that kind of experience, but it's like handymen doing plumbing. Some unlicensed people have the skills, but if you yourself don't know the subtle pitfalls of plumbing, how can you evaluate their work?
I don't know what side channel attacks are possible and what ones aren't. I don't know what instructions have hidden power analysis attack implications.
I could study for months, and try to learn those things, but I could also just use OpenSSL, since it's free. Less effort AND probably safer.
The specialists will get to the Rust redo eventually, I'd rather let them handle it, just like they'd probably rather let me fuss with boring web UI framework version upgrade issues.
Part of the reason C programs need such intense review and shakedown is that C itself is so hazardous. When you write in better languages, issues tend to settle out faster.
I don't claim to be a major crypto wizard like DJB, but I've been at it a while, have been in the industry, know other implementers shipping significant products and can see that they do the same type of stuff that I do. The big brains in the field are e.g. mathematicians designing primitives. Merely implementing them is just engineering and following specs and standards. It's much less big of a deal.
If you study those notes, you'll understand how cryptographers think, how security proofs work, and how modern protocols (though usually not older ones) are designed so that the proofs come along with them. Instead of having to rely on impossible-to-capture shades of finely tuned judgment, you get actual theorems that are bulletproof. So if you have a reasonable math background, you know what proofs are, you know that if your thing is done right then (against the designed-for threat model) your stuff is secure, and you know what it means for your thing to be done right.
So that just leaves executing the latter, which is still the usual error-prone engineering. But good languages and software (look e.g. at Cryptol on galois.com) can help with that too. Most OpenSSL CVE's lately are things like heap overflows rather than crypto misdesign. Coding in Rust is supposed to eliminate those (idk if it always does in practice).
I can't prove in a few sentences that this isn't false confidence but I think there is something to it. At the very least, understanding some theory brings a great improvement to one's clarity of thought.
It's definitely possible for an individual do this stuff, if it can be mathematically proven(My math level is a bit below grade school algebra so I can't really evaluate it there), proofs don't lie, regardless of who proved them, they are in themselves a way better authority than any human.
But anyone who truly does learn all that IS one of those rare crypto experts, and there aren't that many. Who can code review? If someone leaves the team, does anyone else have that level of skill to be able to maintain it?
It might be worth learning crypto for the same reason as any of the other random things they say coders should know, like Haskell and LISP or the dreaded FORTH though.
As for threat models, NaCl and OpenSSL don't magically mitigate against currently unknown threats. Really paranoid crypto is usually wrapped in HSM's (electromagnetically shielded, tamper resistant etc.) in the hope of blocking some of that.
Yeah, this is the really scary part. It's also the part not amenable proofs.
I had to implement some crypto primitives at one point in my career (for a boring combination of legal and technical reasons). Yes, I was nervous, but you pay attention to details and take careful stock of the tools you available (e.g. what's my environment's constant-time comparison function? what's my CSPRNG?) and it's not really harder in the end than implementing lots of other algorithms, you just feel like it is because the stakes are higher. As mentioned many times in this thread, some of the primitives today are also really hard to mis-implement!
But those were also part of a system that had to be secure. That was the terrifying part, because our threat models were relatively unique. But this is also the part that developers do all the time without thinking about it - any time you roll a middleware that looks directly at a JWT, or your own web session bootstrapping, or read a regexp from a user, you're committing the same kind of sin. Having a PhD in lattice reduction on-board for that isn't any help. Having security experts helps a lot for this, but when you have them they're not applying any complex math, they're just exceptionally good at getting into a Red Team mindset.
tl;dr: If you're debating implementing your own ed25519, you're probably already way too far down the rabbit hole to instead grab libnacl and claim some pride that you didn't "roll your own crypto"; even if you take libnacl at that point you've already made most of the security decisions that will make or break you.
I say that just to point out that your confidence is probably not false, and neither is everyone elses lack of confidence in touching crypto.
1. Writing a HW crypto module in an HDL like Verilog or VHDL where one doesn't exist or you don't have access to it.
2. Adding support for a given algorithm on an architecture or platform where none of the other implementations will work (due to either arch differences, memory/cpu constraints, exotic HW, etc).
I can't think of why you'd write such a thing and put it in production otherwise. It's just too expensive to get wrong IMHO however I'd love to be proven wrong.