Live data from Hacker News

How To Safely Store A Password

codahale.com

151–160 of 215 posts

Re: How To Safely Store A Password

#152
post #116

Earlier quoted context omitted.

With smartphones this is increasingly feasible. Lots of sites already use smartphone based two factor authentication (similar to rsa keys). There's no reason why a challenge / response system couldn't be set up using smartphones. For example, a website gives you a string of numbers, you input those in your smartphone app and get the response which yiu then input back to the site, the site can't determine the response…

This is how blizzard (World of Warcraft) authenticators work. It's quite ironic how an online game has strong security mechanisms, yet many tools that people use just as often or more (gmail, facebook, pretty much all SaaS tools, including business) and that are are certainly more 'important' (in an objective sense, I understand that people are more attached to their WoW character than to their customer database) don…

gmail at least has two-factor authentication

http://googleblog.blogspot.com/2011/02/advanced-sign-in-secu...

yet my bank's web site, not so much.

Re: How To Safely Store A Password

#153

Or a stretched newer algorithm like Whirlpool. Or stretched SHA-256? What advantages does bcrypt have over them?

It's been around for years and remained solid. It's implemented in every language under the sun. It can be tuned to be plenty slow, even today.

That said, there's nothing wrong with choosing another password derivation scheme. glibc's crypt() provides three: PHK's MD5 scheme, and Ulrich Drepper's stretched SHA-{256,512}. Just don't roll your own and you'll be ahead of the majority of programmers.

Re: How To Safely Store A Password

#154
post #64

Earlier quoted context omitted.

An idea would be to use a JavaScript implementation of bcrypt to let clients do the math themselves and just send the encrypted password via HTTPS. This has several advantages. One being that the server-side performance is reduced heavily. Another one is that a password never shows up on the server in plaintext ever. Disadvantage: Clients need to have JavaScript enabled.

That doesn't work. Among other issues, Javascript is so much slower than C or CUDA at such tasks (no native integers!) that the client is going to take forever to calculate a sufficiently-hard hash.

I think the most significant issue is that JS on the client is an absolute minefield for cryptography. Apart from the speed issues, it's impossible to secure...

Re: How To Safely Store A Password

#156
post #78
post #75

Earlier quoted context omitted.

You can also initialize the words in more pythonic way: with open('/usr/share/dict/words') as wordlist: words = set(line[:-1] for line in wordlist) Or, for one time check you can stop reading on match: import sys lookup = '%s\n' % sys.argv[1] with open('/usr/share/dict/words') as wordlist: [ sys.stdout.write('Dictionary password: %s' % lookup) or sys.exit(1) for line in wordlist if line == lookup ] As for the objecti…

While I agree that the first code is pythonic and nice, the second code is quite the opposite of that. Why forcing imperative code into a list comprehension? It is a lot easier to read as nested loop, as it doesn't build a dummy list with some strange "or" operation: import sys lookup = '%s\n' % sys.argv[1] with open('/usr/share/dict/words') as wordlist: for line in wordlist: if line == lookup: sys.stdout.write('Dict…

better to pickle a frozenset and use that.

  import pickle

  # initialize:
  wordset = frozenset(line.lower().rstrip() for line in open('/usr/share/dict/words'))
  pickle.dump(wordset, open('/tmp/wordset.pkl', 'wb', -1))

  # when you want to use it:
  wordset = pickle.load(open('/tmp/wordset.pkl', 'rb'))

  'bear' in wordset # == True

Re: How To Safely Store A Password

#157
post #140

bcrypt is so flawed...

If you want to stand by that assertion, please provide some information to back it up. You'd become very popular in this community (and the security community at large) if you could provide a good basis for that statement.

Otherwise, you're just trolling, and I've committed a cardinal sin.

Re: How To Safely Store A Password

#158
post #135

Earlier quoted context omitted.

Then how in the world does your code know what salt to use when the user presents his or her password? If it is derived in code from some other piece of user data then it is still "known" if your DB leaks - you have to assume someone who stole your database also stole your code.

"you have to assume someone who stole your database also stole your code." Maybe, but that doesn't mean that a separate salt, not in the database, will prevent certain attacks, and as such is a viable option. Security is about layering, not about 'xyz isn't 100% secure in 100% of the cases, forget about it'.

That's fair, but it doesn't change the insanely wrong statement that triggered this comment chain:

"sha1 with a salt u cant find beats bcrypt with a key u know any day"

This is fractally wrong.

Re: How To Safely Store A Password

#159
post #91

Earlier quoted context omitted.

You can also write a new cipher, discover a new key derivation function, and invent a new hash function. But that's not the point. Use bcrypt or scrypt.

Any analogy between using a standard technique with a standard hash and going for DYI cryptography is a bit stretched.

Really? You just described a KDF, and advised people to use it without providing any references to implementations. "Just leave out k bits of salt and brute-force it" -- do you really expect non-cryptographers to be able to correctly implement this algorithm? If you insist on using hashes, at least you could tell people to use PBKDF2 to turn a standard hash into KDF.

Re: How To Safely Store A Password

#160

Earlier quoted context omitted.

Then how in the world does your code know what salt to use when the user presents his or her password? If it is derived in code from some other piece of user data then it is still "known" if your DB leaks - you have to assume someone who stole your database also stole your code.

"Then how in the world does your code know what salt to use when the user presents his or her password?" It brute forces the missing part. Obviously you may only leave out a number of bits that keeps it feasible.

Or you could use something like bcrypt with a configurable 'cost' and stop making up things that you think will secure your passwords.

Anything you can brute force with your hardware can be brute forced on someone else's hardware.

Post reply on HN