News for hackers. Stuff that matters.
Re:It's Dangerous, a Python cryptographic signing module by ctz on Sunday June 10, 2012 @07:09AM (#4090761)
Use of SHA-1 for this signature/MAC purposes in new applications is deprecated and will be disallowed from next year (source: NIST).

I repeat: do not use SHA-1 in new applications. Do not use this module.

Re:It's Dangerous, a Python cryptographic signing module by Luit on Sunday June 10, 2012 @07:26AM (#4090782)
Well then fork it and make it use HMAC with SHA256/512... Additionally, "Do not use this module" is bad advice if it leads to someone making their own MAC implementation, because that's almost always a bad idea. HMAC-SHA1 still is good security for this purpose.

I bet that as soon as standards bodies (like NIST) actively encourage you to use better hash functions (which they will probably do soon) the developer of this module will decide on what is safe enough for this purpose.

Re:It's Dangerous, a Python cryptographic signing module by gambler on Sunday June 10, 2012 @08:20AM (#4090853)
You advise to "fork it", but immediately after that you add the notorious "do not write your own" meme. Can you see the inconsistency of the messages?

Part of security is being up-to-date in regards to things like hashes. If authors don't update their own libraries and you need to tweak them manually, how is it different from "writing your own"?

Re:It's Dangerous, a Python cryptographic signing module by Luit on Sunday June 10, 2012 @11:31AM (#4091305)
I agree I'm a bit inconsistent, but the library is well written, and exchanging the hashing function is a trivial task. That's not really quite "writing your own". I just mean to discourage people who aren't 100% sure they know what they're doing.

I strongly agree with Armin: HMAC-SHA1 (note, the combo, it's not just the latter) is still good security for most applications you'd consider this library for.

Re:It's Dangerous, a Python cryptographic signing module by ebiester on Sunday June 10, 2012 @09:13AM (#4090956)
I always thought the advice against "writing your own" spoke of the algorithm itself, not a library around the algorithm.
Re:It's Dangerous, a Python cryptographic signing module by Locke1689 on Sunday June 10, 2012 @11:27AM (#4091293)
Nope. Google Keyczar: standard algorithms; still screwed up. You should always use the highest level interface available.
Re:It's Dangerous, a Python cryptographic signing module by ch0wn on Sunday June 10, 2012 @08:03AM (#4090826)
It shouldn't be more than changing those two lines:

https://github.com/mitsuhiko/itsdangerous/blob/59f3bf7877e21...

And the tests, of course.

Re:It's Dangerous, a Python cryptographic signing module by Luit on Sunday June 10, 2012 @08:14AM (#4090842)
My point exactly! Armin (the maker/maintainer of the module) will probably consider doing this somewhere in the future.
Re:It's Dangerous, a Python cryptographic signing module by the_mitsuhiko on Sunday June 10, 2012 @10:53AM (#4091189)
I just pushed out a release that makes it possible to override the digest in a subclass easier.
Re:It's Dangerous, a Python cryptographic signing module by zokier on Sunday June 10, 2012 @01:06PM (#4091551)
While overrideability is good, wouldn't it be better to also be 'secure by default'? I'd imagine that SHA-2 would be more sensible default for most users.
Re:It's Dangerous, a Python cryptographic signing module by the_mitsuhiko on Sunday June 10, 2012 @10:55AM (#4091196)
> I repeat: do not use SHA-1 in new applications.

Probably, but not necessarily. It's not like the other sha versions are fixing the overall problem however.

> Do not use this module.

Even before the 0.13 release I just pushed out where you can override the module easier you could still easily change the hash method with a two line change. Also it's not like maintainers can't change things easily if modules are well defined.

And even if the module would not allow changing the hash method easily SHA1 with HMAC is still incredibly hard to exploit.

Re:It's Dangerous, a Python cryptographic signing module by tptacek on Sunday June 10, 2012 @02:31PM (#4091762)
SHA-1 and SHA-2 (SHA256, SHA512) are not the same algorithm. The problem with SHA-2 isn't that it's insecure; it's that it's slow for its current predicted level of security, and that it's MD-strengthened and so requires an HMAC construction to use in applications like MACs. The sentence "It's not like the other sha versions are fixing the overall problem" is wrong.

You would indeed be better off using SHA256.

But not much. It's worth pointing out though that dogmatism around not using SHA-1 is misplaced. There are still no practical attacks on HMAC-MD5, for instance, even though MD5 itself is effectively broken and its use in (for instance) X.509 certificates is insecure.

Re:It's Dangerous, a Python cryptographic signing module by the_mitsuhiko on Sunday June 10, 2012 @09:26PM (#4092828)
> SHA256

As it is, the size of that digest is also 14 bytes more and I don't feel happy truncating the hash. The bigger SHA2 versions are even longer. Considering that thing should go into cookies and URLs I did not feel very happy with that.

> You would indeed be better off using SHA256.

Probably. I was indeed under the impression that SHA2 is based on the same building blocks as SHA1 but I assume that is not the case. That being said: upgrading is not hard if it even comes to the point where it would be necessary.

Re:It's Dangerous, a Python cryptographic signing module by tptacek on Sunday June 10, 2012 @09:33PM (#4092841)
Do you really want to be the guy promoting a message verification library who won't use SHA-2 because of the extra 14 bytes of digest length? You made a design mistake here. Just fix it.
Re:It's Dangerous, a Python cryptographic signing module by marcinw on Sunday June 10, 2012 @09:53PM (#4092892)
Neils Ferguson, et. al of Cryptography Engineering (p. 95) suggest that truncating a HMAC-SHA-256 to 128 bits should be safe, given current knowledge in the field.
Re:It's Dangerous, a Python cryptographic signing module by tptacek on Sunday June 10, 2012 @10:00PM (#4092904)
This is code that's mostly going to be used in Python web apps (if at all). I thought about arguing in favor of truncating the hash, but then figured this guy would just say "well, I'm not so sure, so to be on the safe side... [I'll use an inferior hash]"... a better argument is, just eat the extra bytes and stick them on your message.
Re:It's Dangerous, a Python cryptographic signing module by jacques_chester on Sunday June 10, 2012 @07:26AM (#4090781)
To clarify very slightly, use SHA-256, SHA-384 or SHA-512 instead.

Sometime soon I believe SHA-3 will be chosen and we'll all be able to move onto that.

Re:It's Dangerous, a Python cryptographic signing module by fluffyllemon on Sunday June 10, 2012 @08:56AM (#4090919)
For those interested, NIST (National Institue of Standards and Technoology) announced a competition to find candidates for the SHA-3 algorithm back in November 2007:

"NIST also plans to host a final SHA-3 Candidate Conference in the spring of 2012 to discuss the public feedback on these candidates, and select the SHA-3 winner later in 2012." [http://csrc.nist.gov/groups/ST/hash/sha-3/Round3/index.html]

The final SHA-3 Candidate Conference was held March 22-23, so they should be picking the winner any day now.

Re:It's Dangerous, a Python cryptographic signing module by atto on Sunday June 10, 2012 @10:29AM (#4091129)
I forked the project and updated the hashing algorithm: https://github.com/andrewconner/itsdangerous
Re:It's Dangerous, a Python cryptographic signing module by the_mitsuhiko on Sunday June 10, 2012 @11:02AM (#4091219)
> I forked the project and updated the hashing algorithm: https://github.com/andrewconner/itsdangerous

That is not necessary, I adjusted the API so that you can easily subclass it and change the digestmod.

Re:It's Dangerous, a Python cryptographic signing module by tptacek on Sunday June 10, 2012 @02:34PM (#4091770)
It should default to a SHA-2 hash and you should deprecate the branch that defaulted to SHA-1.