Live data from Hacker News

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

matasano.com

51–60 of 76 posts

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

#51
post #50
post #39

Earlier quoted context omitted.

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

http://www.isg.rhul.ac.uk/~kp/padding.pdf

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

#52
post #47
post #44

Earlier quoted context omitted.

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.

Agreed. Still, I can't decipher the IKE spec, but does it really prevent this - i.e. do any of the other building blocks actually prevent the conversation from continuing using a compromised shared key?

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

#53
post #5

So, is there much to be gained from encryption anyway? If, as the candidate, I suggested sending a cookie as 'userId=39493&role=user&timestamp=1414919&hash= ' then would I lose brownie points? I assume my hash comparison function is constant time (eg. XOR(a[x],b[x])==0), rather than comparing of char-by-char.

> hash=

Oops, you invented your own keyed MAC and now I can append any data I want.

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

#54
post #37

It was a nice read, but the screenplay delivery added a lot of confusion that I felt detracted from the point of the actual message. Maybe if it hadn't been so fragmented. Still, educational, though moderately confusing.

So I wrote out a straight prose version of this post, and even after a second draft it came out 40% longer and as dry and dense as melba toast. But I actually kind of agree (at the very least, it's visually noisier than the prose wall of text). There's a backstory to this; I haven't blogged in almost a year, and my most infamous blog post from before that was also a screenplay, so doing this post in this style was al…

great post. on the readability - i think the screenplay makes it more approachable but the visual formatting makes it rather hard to read. It seems like the slightly shortened, indented lines that run into the hard vertical line on the right, combined with the center aligned names, disrupts the eye flow. my eyes are drawn immediately to the center/end of line because that's where the most tension is but that's not where the line begins. i found the hex dumps to be the easiest part for my eyes to latch on to because it felt consistent.

all that is a long way of saying, in spite of the visual formatting, it's a very interesting article. and personally, i think the the screenplay itself works.

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

#55
post #54
post #37

Earlier quoted context omitted.

So I wrote out a straight prose version of this post, and even after a second draft it came out 40% longer and as dry and dense as melba toast. But I actually kind of agree (at the very least, it's visually noisier than the prose wall of text). There's a backstory to this; I haven't blogged in almost a year, and my most infamous blog post from before that was also a screenplay, so doing this post in this style was al…

great post. on the readability - i think the screenplay makes it more approachable but the visual formatting makes it rather hard to read. It seems like the slightly shortened, indented lines that run into the hard vertical line on the right, combined with the center aligned names, disrupts the eye flow. my eyes are drawn immediately to the center/end of line because that's where the most tension is but that's not wh…

Thanks for the feedback! I thought the same thing; I think I'll mod my hacked-up version of Markdown to dim the center lines.

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

#56
post #53
post #5

So, is there much to be gained from encryption anyway? If, as the candidate, I suggested sending a cookie as 'userId=39493&role=user&timestamp=1414919&hash= ' then would I lose brownie points? I assume my hash comparison function is constant time (eg. XOR(a[x],b[x])==0), rather than comparing of char-by-char.

> hash= Oops, you invented your own keyed MAC and now I can append any data I want.

Sorry, I would really be using a proper RFC 2104 HMAC implementation (eg. python's hmac module).

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

#58
Great post, not that I can claim to understand all of it. One question:

Just put a “for” loop around SHA-1 and run it 1000 times to generate the key; that’ll at least slow down a brute force attack. SHA-1 is lightning fast. By itself, it’s a crappy way to generate a key.

I see the purpose of this, but doesn't it also provide 999 more opportunities for a hash collision to happen? Are you so confident in the collision resistance of SHA-1 that this isn't an issue?

My (probably naive) proposal would be to keep the result of the first hash and XOR it with the result of each subsequent hash. Bad idea?

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

#59
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.

So, in the context of the SSO cookie, could tampering with the encrypted data be prevented by signing the ciphertext (please excuse the terminology if it's not correct)? What I mean by that is, encrypt the cookie's plaintext (e.g. "user=username, role=admin, etc."), and then sign it, so the value stored in cookie is something like :?

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

#60
post #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?

yeah I think the standard answer is "don't store credentials i the cookie". session key only and central session storage.
Post reply on HN