Live data from Hacker News

How I implemented my own crypto

loup-vaillant.fr

121–130 of 409 posts

Re: How I implemented my own crypto

#121
post #104

Earlier quoted context omitted.

Could you list the main pitfalls you are thinking about? Also, I may have mentioned some of them in this earlier article: http://loup-vaillant.fr/articles/rolling-your-own-crypto

Hey, like you I decided to dive into cryptography coming from a different background. Although this quote is not directly related to your problem it can be safely applied to it: "Almost certainly you will get the urge to invent new cryptographic algorithms, and will believe that they are unbreakable. Don't resist the urge; this is one of the fun parts. But resist the belief; almost certainly your creations will be br…

Note that the author is not inventing crypto algorithms, rather implementing them (although the part about XChaCha20 being a mix of ChaCha20 and XSalsa20 is IMHO dancing on the line). Still a risky business, and tricky to get right, but several orders of magnitude safer than "hey, what if we just XORed everything with a random number? Unbreakable, eh?"

Re: How I implemented my own crypto

#122
post #51

Earlier quoted context omitted.

We've had to wait till C99 to get stdint.h, clearly portability is kind of an afterthought in C. C is meant to map easily to a wide range of hardware without overhead, conceptually it's almost the opposite of portability since it precludes creating standard abstractions that would hold true across architectures as those could not map to native functionality across the board. It's easy to compile C programs on a diffe…

> We've had to wait till C99 to get stdint.h, clearly portability is kind of an afterthought in C. C provided "at least N bits" guarantees for its integer types since its first standard (for the curious: char at least 8-bit, short at least 16-bit, long at least 32-bit; in C99, long long as least 64-bit). This is the most that you can get if you want absolute portability, because there are architectures out there wher…

It's actually int_least32_t and int_fast32_t.

Re: How I implemented my own crypto

#123
post #20
post #13

Earlier quoted context omitted.

Interestingly it looks like there was a bug in every Argon2 implementation specifically because everyone just used the reference implementation. Personally, I think the intention of the phrase "don't roll your own crypto" was lost over time. It was advice to companies to use standard cryptographic algorithms rather than everyone coming up with their own thing for no good reason. It doesn't mean that only some blessed…

Those are two separate arguments. Of course there should be competition in crypto libraries. However the " don't roll your own " advice is to prevent people who don't have sufficient experience, education nor resources to write their own library that can compete - effectively leaving their systems vulnerable. The thing about the " don't roll your own " advice is it's aimed at people who don't competently know what th…

How do you expect people to become competent if you constantly tell them to not do something? All that will happen is that people who don't listen to warnings will write crypto libraries and everyone will be forced to use them because nobody else wrote one.

The fact that there was no independent implementation of Argon2 that found there was a bug in the reference implementation shows that the "don't roll your own" advice is discouraging competition in crypto libraries to the point where the reference implementation wasn't sufficiently verified to produce correct output.

Re: How I implemented my own crypto

#124

It was a fun read, except when all the C bugs were listed. It's getting tiresome to hear about folks writing nominally Important software in a language where it is extraordinarily difficult to get things absolutely correct, with paltry excuses such as "it needs to be fast" or "it needs to be portable [0] to a VAX-11/750." It doesn't give me confidence that these completely usual bugs popped up early on, and it will n…

It's even more tiresome hearing a new generation of programmers constantly lamenting the fact that C requires a great deal of skill to develop in and that X or Y new language completely avoids C pitfalls. Not only is it dishonest but it seems to be marketing 70% of the time.

Portability does not equal 'without blemishes'. It simply means that when compiled across platforms it will perform as expected.

Re: How I implemented my own crypto

#125

Earlier quoted context omitted.

"Hey y'all, hold my beer and look at this!" There are [1] several non-aviation examples: - Blood transfusion - Steam-powered bicycles - Rotary printing presses - Submarines - Luminescent paint - Hi-speed jet-powered railcars - Ropes /pulleys to help the user get out of bed [1] https://en.wikipedia.org/wiki/List_of_inventors_killed_by_th...

> - Steam-powered bicycles On a first read I though "yeah, sure, looks quite dangerous indeed", then I read: Sylvester H. Roper, inventor of the eponymous steam-powered bicycle, died of a heart attack or subsequent crash during a public speed trial in 1896. It is unknown whether the crash caused the heart attack or vice versa.

This seems to mean "killed in an interesting way". People killed by their inventions in petrol-based transportation seem to be too numerous even for a Wikipedia list: "yeah, people die in cars en masse, that's not really newsworthy."

Re: How I implemented my own crypto

#126
post #7

Earlier quoted context omitted.

Parachute?

Actually you do roll your own parachute once you have done enough jumps. But your reserve chute is always rolled by a certified professional specifically certified to roll reserve chutes, and not by yourself. (if I remember correctly, my memory is a bit fuzzy from when I jumped a couple of years back)

Well, you are using the product, but not manufacturing it.

Re: How I implemented my own crypto

#127

TLDR: Crypto library with two claimed advantages: Better usability and smaller code than libsodium. However, it is also slower.

Having all of that would be great, but most of the time you need to weigh one against another. Smaller code means smaller attack surface and supposedly fewer ways to shoot yourself in the foot ("I know, I'll use CBC"); of course, checking whether the author doesn't shoot you in the foot by choice of algorithms, or their implementation, is advised.

Re: How I implemented my own crypto

#128
post #104

Earlier quoted context omitted.

Hey, like you I decided to dive into cryptography coming from a different background. Although this quote is not directly related to your problem it can be safely applied to it: "Almost certainly you will get the urge to invent new cryptographic algorithms, and will believe that they are unbreakable. Don't resist the urge; this is one of the fun parts. But resist the belief; almost certainly your creations will be br…

Note that the author is not inventing crypto algorithms, rather implementing them (although the part about XChaCha20 being a mix of ChaCha20 and XSalsa20 is IMHO dancing on the line). Still a risky business, and tricky to get right, but several orders of magnitude safer than "hey, what if we just XORed everything with a random number? Unbreakable, eh?"

What's wrong with xoring with a stream of random numbers? Isn't it how stream ciphers work? Get a good cryptographic RNG, initialize it properly with a long enough key and you should be fine.

Re: How I implemented my own crypto

#129

Earlier quoted context omitted.

Note that the author is not inventing crypto algorithms, rather implementing them (although the part about XChaCha20 being a mix of ChaCha20 and XSalsa20 is IMHO dancing on the line). Still a risky business, and tricky to get right, but several orders of magnitude safer than "hey, what if we just XORed everything with a random number? Unbreakable, eh?"

What's wrong with xoring with a stream of random numbers? Isn't it how stream ciphers work? Get a good cryptographic RNG, initialize it properly with a long enough key and you should be fine.

There's nothing wrong with that. You are right, that's how stream ciphers work.

Re: How I implemented my own crypto

#130

It was a fun read, except when all the C bugs were listed. It's getting tiresome to hear about folks writing nominally Important software in a language where it is extraordinarily difficult to get things absolutely correct, with paltry excuses such as "it needs to be fast" or "it needs to be portable [0] to a VAX-11/750." It doesn't give me confidence that these completely usual bugs popped up early on, and it will n…

It is getting even more tiresome to have the obligatory anti C comment every time someone implements a C library (probably in his spare time).

Can you direct us to a repository where we can see your output?

Post reply on HN