≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Feature request #1618

Feature request #1618: Switch to bcrypt for passphrase hashing

Kind feature request
Product wincent.dev
When Created 2010-07-23T05:26:09Z, updated 2015-03-29T00:31:20Z
Status closed
Reporter Greg Hurrell
Tags no tags

Description

Low priority, but something to do in the future.

Inspired by:

  • http://jasonseifer.com/2010/03/21/on-passwords

bcrypt can be tuned to make hash calculation more expensive, therefore making bruteforcing less feasible.

Migrating the hashes? It could either be done via explicitly resets (via the resets controller), or on a successful login.

Comments

  1. Greg Hurrell 2011-02-01T11:53:47Z

    Thinking about it more, I definitely like the idea of doing it on a successful login.

    We are in no hurry to rush this particular migration, so it doesn't matter how long people take to actually log in and update their hash.

    The basic plan would be this:

    1. Add a hash-type column to the users table.
    2. When a user logs in successfully using the old hash, at that point we store a new hash and update the hash-type as well; we can do this because we have the plaintext password at that point.

    Pretty simple really.

    As for how to do the bcrypt digesting, there is a bcrypt-ruby gem:

    • http://bcrypt-ruby.rubyforge.org/

    But I think you can make bcrypt digests using the OpenSSL module which is in the standard library. Just checking that out now.

  2. Greg Hurrell 2011-02-01T11:57:44Z

    Looks like this isn't exposed in the standard library module, at least as far as I can tell.

    The source code for the bcrypt-ruby gem calls into the OpenSSH library from inside a C extension:

    • https://github.com/codahale/bcrypt-ruby/blob/master/ext/mri/bcrypt_ext.c
  3. Greg Hurrell 2011-02-01T12:01:48Z

    The thing about the bcrypt-ruby gem that gives me the creeps is this:

    $ irb -r bcrypt
    >> pass = BCrypt::Password.create('secret')
    => "$2a$10$kfrJ4wG9T1N96lemyy8pX.OIoIIrYpxZWawfl/6FLuaDlKc8Mag8i"
    >> pass == 'guess'
    => false
    >> pass == 'secret'
    => true
    >> 'secret' == pass
    => false

    Something about overriding the == operator in such a way that a == b but b != a just makes me feel queasy (I understand why you can't make b == a work, seeing as this is by definition a one-way hash function and you can't therefore make a useful to_s method on it, but to me that's an indication that you shouldn't be overriding the == operator in the first place).

  4. Greg Hurrell 2015-03-28T04:04:23Z

    For shits and giggles, check out the bickering on this HN thread about the ups/downs of taking a "salt & pepper" approach.

  5. Greg Hurrell 2015-03-28T04:21:49Z

    There are some things I don't particularly like about the design of the bcrypt-ruby gem. An in-standard-library alternative is PBKDF2. Arguably not as secure, but still much more secure than a normal crypto hash (ie. one not designed for password hashing).

  6. Greg Hurrell 2015-03-29T00:31:20Z

    Status changed:

    • From: new
    • To: closed
Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets