Live data from Hacker News

Rolling your own crypto: Everything you need to build AES from scratch

github.com

41–50 of 92 posts

Re: Rolling your own crypto: Everything you need to build AES from scratch

#42
post #31

Earlier quoted context omitted.

Isn't table lookup constant time?

These are called "cache-timing attacks". In presence of caches, no memory lookup can be guaranteed to be constant time. Any memory lookups that use secret indices are thus not timing-safe, however non-secret indices are OK. See https://cr.yp.to/antiforgery/cachetiming-20050414.pdf Here's an implementation that doesn't use tables: https://github.com/openbsd/src/blob/master/sys/crypto/aes.c

(That implementation comes from BearSSL, whose website also has a discussion of the issue and a performance comparison[1].)

[1] https://www.bearssl.org/constanttime.html

Re: Rolling your own crypto: Everything you need to build AES from scratch

#43
post #22

Earlier quoted context omitted.

Just no. This idea that people are not allowed to learn by doing things and must read huge books first is absurd. The guidelines for learning you gave here are impractical for majority of people who are interested. It is actually good when people are trying to learn about security. Just about worst thing these absurd rules achieve is that effectively only rule breakers are allowed in.

> Just no. This idea that people are not allowed to learn by doing things and must read huge books first is absurd. No, its not absurd. Sure, I agree, for many things in life you can "learn by doing". But this is cryptography. There is no escaping that cryptography IS mathematics and an algorithm built on top of that mathematics. Unfortunately the only way to learn the theory is by reading and understanding books or…

This is kind of ridiculous. Everyone has to start somewhere whether it is by doing or by reading books. Even crypto experts started by doing at some point. It's not like the person is going to be using their own crypto in production.

Re: Rolling your own crypto: Everything you need to build AES from scratch

#44
post #36

Earlier quoted context omitted.

You mostly learn cryptography by doing cryptanalysis, and that certainly is a form of playing with ciphers. To be fair, modern cryptanalysis also involves a bit of math and reading some papers. None of this is something that hobby cryptographers can't do. In fact, there is no real difference between "professional" and hobby cryptographers. Many of the professional ones started as hobby cryptographers, and there are p…

The "don't roll your own crypto" is a mantra mostly useful for deciding what to put into production, not as a general ban on even touching the stuff before you become some kind of mythical, long-bearded, tome-possessing wizard. I thought this was pretty obvious but I guess this important context was not sufficiently disseminated given the prevalence of the latter position.

Almost all mantras that are stated in absolutes will be accepted by the public in every single possible way. Unfortunately, and I know it sounds unbelievable, for a lot of people it really has become "don't even think of learning about crypto", not just "don't use your own crypto in prod"

Re: Rolling your own crypto: Everything you need to build AES from scratch

#45
Can other people’s crypto binaries ever be fully trusted? - and there’s the other issue of ‘software rot’ making those binaries and associated data potentially unusable in the future. Home risk is mainly theft of hardware by burglars looking for cash resale rather than cryptanalyst hackers - so for purely personal use, and to guarantee future readability, perhaps rolling your own AES from source isn’t so misguided if it’s just to protect the odd spreadsheet or personal letter from prying eyes?

Re: Rolling your own crypto: Everything you need to build AES from scratch

#46

Earlier quoted context omitted.

It’s absolutely worth it to roll your own crypto if you want to learn from it. I feel like there is almost a stigma against articles like these because we’ve all been conditioned so much to avoid even thinking about it lol. I did some deep dive into AES and RSA at some point in a distant past, it was a learning experience that to this day allows me to make much better decisions when choosing algorithms.

> It’s absolutely worth it to roll your own crypto if you want to learn from it No. If you want to "learn from it", the first thing you should do is buy a copy of Bruce Schneier's Applied Cryptography . Just reading (and fully understanding !) that book will alone put you in a position where you already know more about cryptography than 90% of other people. If after that you still want to play around with rolling you…

Obligatory reply to an endorsement of Applied Cryptography: https://sockpuppet.org/blog/2013/07/22/applied-practical-cry...

Re: Rolling your own crypto: Everything you need to build AES from scratch

#47
post #4

Refreshing to see "crypto" meaning cryptography, not cryptocurrencies... And also good that they mention right from the start that you shouldn't use your (or their) self-made cryptography in production (although they could have emphasized it a bit more).

> you shouldn't use your (or their) self-made cryptography in production Absolutely, and that was the very first thing I thought when I saw the title. For some reason I've got the "don't roll your own crypto" commandment heavily ingrained into my brain (even though I've never been in any context where I might have tried), together with "don't let the frying pan handle stick out over the edge of the cooker in case a k…

"don't roll your own crypto" is good advice, but it's also against the hacker ethos. It's another way of saying "you'll never really understand this so don't try, just rely on a mysterious cabal of experts".

May be true, but not exactly a great message.

Re: Rolling your own crypto: Everything you need to build AES from scratch

#48
post #22

Earlier quoted context omitted.

Just no. This idea that people are not allowed to learn by doing things and must read huge books first is absurd. The guidelines for learning you gave here are impractical for majority of people who are interested. It is actually good when people are trying to learn about security. Just about worst thing these absurd rules achieve is that effectively only rule breakers are allowed in.

> Just no. This idea that people are not allowed to learn by doing things and must read huge books first is absurd. No, its not absurd. Sure, I agree, for many things in life you can "learn by doing". But this is cryptography. There is no escaping that cryptography IS mathematics and an algorithm built on top of that mathematics. Unfortunately the only way to learn the theory is by reading and understanding books or…

... and people making serious mistakes in their toy experiments at home is a problem how?

Re: Rolling your own crypto: Everything you need to build AES from scratch

#49
post #4

Refreshing to see "crypto" meaning cryptography, not cryptocurrencies... And also good that they mention right from the start that you shouldn't use your (or their) self-made cryptography in production (although they could have emphasized it a bit more).

> you shouldn't use your (or their) self-made cryptography in production Absolutely, and that was the very first thing I thought when I saw the title. For some reason I've got the "don't roll your own crypto" commandment heavily ingrained into my brain (even though I've never been in any context where I might have tried), together with "don't let the frying pan handle stick out over the edge of the cooker in case a k…

How does crypto even get created, then? Like, those cryptography experts — they do roll their own crypto, and then it gets standardized as Blowfish/AES/Salsa20/etc. How did they learn to make ciphers that are "good enough" to use in production? Are those people special somehow, and it's not possible to become one of them?

Re: Rolling your own crypto: Everything you need to build AES from scratch

#50

Earlier quoted context omitted.

> you shouldn't use your (or their) self-made cryptography in production Absolutely, and that was the very first thing I thought when I saw the title. For some reason I've got the "don't roll your own crypto" commandment heavily ingrained into my brain (even though I've never been in any context where I might have tried), together with "don't let the frying pan handle stick out over the edge of the cooker in case a k…

How does crypto even get created, then? Like, those cryptography experts — they do roll their own crypto, and then it gets standardized as Blowfish/AES/Salsa20/etc. How did they learn to make ciphers that are "good enough" to use in production? Are those people special somehow, and it's not possible to become one of them?

They're not special. Cryptographers are mostly (but not exclusively) the products of a few academic programs around the world that teach the specialized math involved in developing and proving (and breaking) crypto algorithms.

The standards are either the outcome of competitions the US government (through NIST) has held over the years, or they're de-facto standards because they're provably better for certain use cases than other algorithms.

Post reply on HN