3 ms·
I've done it and feel ok about it. Others here have done it and done a good job. But yeah, there are different levels you can work at, you always have to be c
by throwaway81523 5y ago
I've done it and feel ok about it. Others here have done it and done a good job. But yeah, there are different levels you can work at, you always have to be careful, and you have to know some theory in order to be able to even think clearly about the topic. I found Bellare and Rogaway's old lecture notes[0] demystified the subject for me a lot. There are some actual textbooks now that are more up to date and complete, though I don't happen to know of titles offhand.
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/book/main.pdf https://web.cs.ucdavis.edu/~rogaway/classes/227/spring05/boo...
- eternityforest 5y agoAny particular reason you'd ever do this? Obviously it kinda makes sense as a hobby project never used for something important... but in production?
- throwaway81523 5y agoI don't understand the question. Code has to come from somewhere, and there's not always a pre-written library you can use. That's what keeps programmers employed. 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.
- eternityforest 5y agoThe weird special primitives definitely makes sense. Not much you can do when you've got a legacy system. 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.
- throwaway81523 5y agoObviously the Rust (etc.) stack would have to be reviewed in beta for a while before being declared ready for prime time (no pun intended). The OpenSSL primitives don't try to defeat power analysis as far as I know (that's more for smart cards and HSM's), and they mostly don't try to defeat timing analysis (e.g. the DES and AES implementations use lookup tables). On the other hand with DJB's primitives, it's harder to get that wrong. This is for symmetric crypto: public-key is more complicated. 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.
- throwaway81523 5y agoI want to add one other remark: I sympathize with the anxiety you're conveying about implementing this stuff. I used to feel the same way. The Bellare/Rogaway notes I linked above boosted my confidence a ton. I know perfectly well that protocol XYZ was designed by someone smarter and more experienced than me, whose engineering judgment is better than mine. So what makes me think I have any chance? 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.
- CuriousCosmic 5y agoWhy would you do such a thing? There's very few good reasons to. The only ones I can think of are: 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.