Live data from Hacker News

How I implemented my own crypto

loup-vaillant.fr

321–330 of 409 posts

Re: How I implemented my own crypto

#321
Hey, fantastic work! Really happy to see some amateur crypto development out there. I started as an amateur also, now I work in crypto product dev.

Definitely impressed if this is your first crypto work. I really like the simplicity, reminds me of OpenSSH.

I gotta agree with some of the naysayers though - this needs more time to brew. Even if it's perfect, there still more proof to show.

My suggestions:

* A long-running interoperability test between your lib and another. Test vectors don't catch everything. Run it for a week, check results and publish the results.

* Fuzzing. You need to to catch false results, random crashes, stack overflows, etc. Fuzz every input, do it for random lengths (both underflow and overflow).

* Maybe port it and test on Win, Mac, ARM, MIPS. I find a lot of bugs shake out during ports.

* Timing. You can't prevent all side-channel attacks, but bits going out are easy attack vectors. Use a high-precision timing mechanism to catch any unusual spikes. Capture a few hours of points for each functional path, and publish the results. (crypto_aead_unlock has two return paths, it might be better to maintain timing).

* Personal preferences: Rather than using int returns, use bool. Zero your ctx vars, e.g. a_ctx ctx = {0,};

I spend more time in testing products than development, honestly. Publish as much relevant data as you can.

Re: How I implemented my own crypto

#322
post #258

I would like to clarify: The thing that I said was "table stakes" for implementing cryptography was passing the algorithm test vectors , which this author's previous post claimed as a security feature. If you're unfamiliar with the concept, a test vector is a series of strings and intermediate values used to ensure that your (say) OCB3 is the same as everyone else's OCB3. Had he asked, I'd further claim that not havi…

> You just have to know what a carry propagation bug is This is one of the things that drives me nuts about the crypto community. The natural response upon reading, "You just have to know X" if you don't already know is to go search for X. Well, if you go search for "carry propagation bug" you will find lots of examples of carry propagation bugs being found and fixed, but no explanation of what one is. The thing that…

Isn't this the point of the usual advice, "don't write your own crypto"? There are a million gotchas, and most of these you've just gotta know.

Re: How I implemented my own crypto

#323
post #258

I would like to clarify: The thing that I said was "table stakes" for implementing cryptography was passing the algorithm test vectors , which this author's previous post claimed as a security feature. If you're unfamiliar with the concept, a test vector is a series of strings and intermediate values used to ensure that your (say) OCB3 is the same as everyone else's OCB3. Had he asked, I'd further claim that not havi…

> You just have to know what a carry propagation bug is This is one of the things that drives me nuts about the crypto community. The natural response upon reading, "You just have to know X" if you don't already know is to go search for X. Well, if you go search for "carry propagation bug" you will find lots of examples of carry propagation bugs being found and fixed, but no explanation of what one is. The thing that…

Isn't this the point of the usual advice, "don't write your own crypto"? There are a million gotchas, and most of these you've just gotta know.

Re: How I implemented my own crypto

#324
post #258

Earlier quoted context omitted.

> You just have to know what a carry propagation bug is This is one of the things that drives me nuts about the crypto community. The natural response upon reading, "You just have to know X" if you don't already know is to go search for X. Well, if you go search for "carry propagation bug" you will find lots of examples of carry propagation bugs being found and fixed, but no explanation of what one is. The thing that…

Give me a fucking break. Sean, Marcin, and I spent the better part of a year individually replying to tens of thousands of emails from people doing the Cryptopals challenges that we wrote and published for free. Do you know how much work that was? Here's a hint: it was a lot of work. There are a lot of charges you can level at me to try to win a dumb message board argument, but the one where I want cryptography to be…

I do sincerely apologize for taking my frustrations out on you, because you have indeed gone above and beyond the call to help make crypto accessible.

Nonetheless, I still stand by the substance of my comment: when you (not you specifically, but anyone) say, "You have to know X" you should check that doing a Google search for X yields some reasonable results, and if it doesn't, provide a hint on how to proceed.

Re: How I implemented my own crypto

#325
post #320
post #302

Earlier quoted context omitted.

With all due respect, some things should only be done by trained professionals. Crypto is one of them. Flying a commercial airliner is another.

Funny you should choose flying an airliner as your example because I happen to be a pilot. I don't fly airliners. I'm just a private pilot who flies small planes. But despite the fact that I'm not a "trained professional", I can fly a plane safely. And the reason I can do this is because the flying community does not have this attitude that flying should only be done by trained professionals. To the contrary, the fly…

The "flying community" does not have the attitude that any random person should take the stick on a 737. Like the cryptography community, the flying community encourages newcomers to learn and get certified.

This is a genuinely weird argument you're trying to make.

Re: How I implemented my own crypto

#326
post #315
post #313

Earlier quoted context omitted.

I re-read your GP comment, and I think I misread it the first time. Let me try this again. > If someone posted a message on HN about doing DIY appendectomies with Arduino-controlled robots and I pointed out that you need to go to med school to do surgeries, you would not in fact be harping on me for not having explained why. Actually, I might well harp on you for saying that, but that's a different topic. My complain…

https://www.google.com/search?client=ubuntu&channel=fs&q=+%2... I submit that "carry-propagation bug" is easily looked up. You're asking for people to provide footnotes and extra information so that you can learn what they're talking about when they delve into jargon. I get it. It makes it so much easier to follow along. Then you can learn! Two points come to mind. First, the bit of jargon you've picked on is in fact…

I clicked your link, and the results weren't useful. They were mostly links to reports about fixes for carry-propagation bugs in various pieces of software (which did not explain what a carry-propagation bug is).

Ironically, the fourth result was a link to a different HN discussion about someone trying to figure out what a carry-propagation bug is, and failing to find any good resources through Google. (Although, to be fair, if you dig into that link a bit more, someone does attempt to explain.)

So I wouldn't say it's impossible to find on one's own, but saying it's "easy" is a bit of a stretch.

Re: How I implemented my own crypto

#327
post #324

Earlier quoted context omitted.

Give me a fucking break. Sean, Marcin, and I spent the better part of a year individually replying to tens of thousands of emails from people doing the Cryptopals challenges that we wrote and published for free. Do you know how much work that was? Here's a hint: it was a lot of work. There are a lot of charges you can level at me to try to win a dumb message board argument, but the one where I want cryptography to be…

I do sincerely apologize for taking my frustrations out on you, because you have indeed gone above and beyond the call to help make crypto accessible. Nonetheless, I still stand by the substance of my comment: when you (not you specifically, but anyone) say, "You have to know X" you should check that doing a Google search for X yields some reasonable results, and if it doesn't, provide a hint on how to proceed.

Apology totally accepted, although I still agree with no part of any of your arguments on this thread. :)

Re: How I implemented my own crypto

#328
post #315
post #313

Earlier quoted context omitted.

I re-read your GP comment, and I think I misread it the first time. Let me try this again. > If someone posted a message on HN about doing DIY appendectomies with Arduino-controlled robots and I pointed out that you need to go to med school to do surgeries, you would not in fact be harping on me for not having explained why. Actually, I might well harp on you for saying that, but that's a different topic. My complain…

https://www.google.com/search?client=ubuntu&channel=fs&q=+%2... I submit that "carry-propagation bug" is easily looked up. You're asking for people to provide footnotes and extra information so that you can learn what they're talking about when they delve into jargon. I get it. It makes it so much easier to follow along. Then you can learn! Two points come to mind. First, the bit of jargon you've picked on is in fact…

> I submit that "carry-propagation bug" is easily looked up.

Well, obviously anything is easily looked up. The problem is that in this case the results aren't very helpful if you don't already know what it is. I even said this in my OP: " if you go search for "carry propagation bug" you will find lots of examples of carry propagation bugs being found and fixed, but no explanation of what one is."

Re: How I implemented my own crypto

#329
post #320

Earlier quoted context omitted.

Funny you should choose flying an airliner as your example because I happen to be a pilot. I don't fly airliners. I'm just a private pilot who flies small planes. But despite the fact that I'm not a "trained professional", I can fly a plane safely. And the reason I can do this is because the flying community does not have this attitude that flying should only be done by trained professionals. To the contrary, the fly…

The "flying community" does not have the attitude that any random person should take the stick on a 737. Like the cryptography community, the flying community encourages newcomers to learn and get certified. This is a genuinely weird argument you're trying to make.

As a member of both communities I can tell you that I perceive a genuine difference in attitudes. The crypto community says, "Don't write your own crypto." The aviation community says something more analogous to, "Absolutely, write your own crypto! Just don't use the results of your first effort for anything mission-critical until it has been checked out by someone who knows what they are doing. And oh by the way, here's a list of people you can contact who will be more than happy to help you." (In fact, the aviation community literally encourages people to build their own airplanes!)

Re: How I implemented my own crypto

#330
post #258

Earlier quoted context omitted.

> You just have to know what a carry propagation bug is This is one of the things that drives me nuts about the crypto community. The natural response upon reading, "You just have to know X" if you don't already know is to go search for X. Well, if you go search for "carry propagation bug" you will find lots of examples of carry propagation bugs being found and fixed, but no explanation of what one is. The thing that…

Isn't this the point of the usual advice, "don't write your own crypto"? There are a million gotchas, and most of these you've just gotta know.

Yes, and this is kind of the point I'm trying to make. "Don't write your own crypto" is the wrong message IMHO. The message should be something more like, "Absolutely, write your own crypto, because that's the best way to learn, and here's a pointer to how to get started. Just don't use the results of your early efforts for anything mission critical, and if you want to know why, read this..."

And, taking my own advice, here's the link everyone should be pointing to:

https://cryptopals.com

Post reply on HN