Live data from Hacker News

Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

matasano.com

41–50 of 76 posts

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#41
post #22

As far as doing it wrong can we go back to "app ‘A’ set a cookie with your account ID in it" and discuss why on Earth the app works like that???

Because app A and app B can't share state directly, and can't talk directly to each other? You're basically asking why federation and single sign-on exist.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#42
post #21

Earlier quoted context omitted.

It's a Louis CK bit, and an inside joke because the bit does match up with Intelligentsia (there's actually one of those in LA, where LCK wrote the bit, so I've always wondered). Our office is in fact a few floors up from the Intelligentsia in the Monadnock building.

Very cool. I have always wanted to start a Haskell consultancy and run it out of that building ;)

Joking about names aside: highly recommend this building. Lots of cheap offices --- incl. some very small ones --- and the building itself is gorgeous inside and out.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#43
post #14

Earlier quoted context omitted.

Throw that book away, and buy Ferguson and Schneier's "Practical Cryptography", which Schneier contributed to in penance for writing "Applied Cryptography". Portions of the proceeds of "Practical Cryptography" are donated to a fund that helps the people who wrote crypto based on "Applied Cryptography".

What in particular is wrong with "Applied Cryptography" ?

Nothing, if you know exactly what you're doing. But it's not very good about explaining why e.g. throwing error messages is bad. It's sort of like a toolbox full of really sharp, pointy things with the implicit understanding that sticking your hand in blindly will hurt, and then being surprised when there's a rash of hand injuries.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#44
post #35

Thanks, Thomas. I just finished implementing my own crypto in a webapp I am working on. (AES, with Diffie Hellman for a shared secret we needed) You've made me so nervous about everything I thought was true that I did a hg revert and am looking at gpgme bindings. You've done a good deed, I think.

Diffie Hellman is also remarkably easy to screw up. Here's an old post of mine I don't think ever made it on to Hacker News: http://www.matasano.com/log/962/adam-bozanovich-did-not-unco...

Off topic of the main thread, but isn't the attack mentioned in that post still problematic if you can't reliably act as a MITM for a whole session, but you can disrupt the session long enough to confuse both sides into agreeing on an insecure session key?

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#45
post #7
post #2

Hm. I wrote this for our normal blog readers, who live and breathe security stuff, so I don't know how well it'll carry here.

You blogged the shit outta that post! Definitely an interesting read even for crypto dilettantes. Perhaps, especially for crypto dilettantes. I took Rivest's Computer and Network Security class in college and the most important takeaway for me, far outstripping all of the interesting technical content, was "Don't implement crypto."

"Perhaps, especially for crypto dilettantes." Yes, that's what I thought in the middle of it: he wrote it to educate his clients in an entertaining way to not have to explain this tricky thing for a millionths time. Good read, BTW.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#46
post #2

Hm. I wrote this for our normal blog readers, who live and breathe security stuff, so I don't know how well it'll carry here.

The chorus of "You just made me aware of how vastly unaware I was on the subject!" (which I'll join in on right now) indicates the value found here, I think. :)

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#47
post #44
post #35

Earlier quoted context omitted.

Diffie Hellman is also remarkably easy to screw up. Here's an old post of mine I don't think ever made it on to Hacker News: http://www.matasano.com/log/962/adam-bozanovich-did-not-unco...

Off topic of the main thread, but isn't the attack mentioned in that post still problematic if you can't reliably act as a MITM for a whole session, but you can disrupt the session long enough to confuse both sides into agreeing on an insecure session key?

If you can manipulate a DH exchange, you definitely have bigger problems than forgetting to check DH parameters. It's worth noting that DH is one of those crypto building blocks that by itself provides basically no security (for instance, DH in SSL/TLS is secure because it's backed by an RSA trust anchor). It's just a tool for making other crypto primitives more flexible.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#48
post #23

Isn't the whole problem in this situation that you are trusting the client with critical data? He takes possession of it, has unlimited time and opportunity to work on it, and successful falsification will be obvious for him? Why on earth trust the client with the data in the first place? I have never liked the "encrypted cookie" way of handling session storage. Just have a server side session store and all of this c…

Not to feed this rant too much, but I believe the cookie would be used for verifying a cross authentication attempt. Not exactly sure how it would be used but I'm pretty sure once you've got a session going on both servers the original token would be removed.

Also processes vs threads was just another interview question, it was only slightly more relevant to the story than unicorns in space.

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#49
Is there a shorthand name for "the industry standard answer; the cookie both apps honor to let you in, encrypted so users can’t change their account to someone else’s" pattern, especially that pattern 'done right'?

What's the best battle-tested library (and call) for implementing exactly that, without making any of the common mistakes?

Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong

#50
post #39
post #33

I don't understand what's so hard about encryption. There are simple, well-known rules (except the timing one that is sort of news), and if you follow them you should be safe, no? 1. Use a blocks-size unique prefix (IV) for each message (random will do as well) 2. SHA-256 your entire message before encryption and add the hash value at the end to prevent tampering 3. Use AES-256 with chaining to encrypt 4. Use SHA-256…

Almost everything you wrote just now has problems. 1. Has a well-known problem, which is why "Practical" suggests using a nonce. 2. SHA-256'ing a known plaintext doesn't authenticate a messge. In fact, even simply taking a secret key and appending it to your message before you SHA-256 the message isn't secure; there's a reason HMAC is as complicated as it is. 3. This whole blog post was about things that go wrong wit…

I am not advocating usage of passwords for encryption, I am saying that if you have to use passwords, this is how you use them. Obviously a strong random bytestring is the best key one could possibly have and should be used when possible.

Anyways, re padding - what if I hash the padding as well? surely an attacker would not get anything of value by playing with it?

Thanks

Post reply on HN