News for hackers. Stuff that matters.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by roryokane on Saturday April 16, 2011 @08:32PM (#2455250)
As Anne_Ominous wrote in the comments, this solution needs salts to be truly secure. One reply to Anne links to a sentence in the bcrypt-ruby docs: "bcrypt-ruby automatically handles the storage and generation of these salts for you.". However, there's something I don't understand. Where are the salts stored? The linked article mentions only that the model needs a password_digest field. If the salt is stored alongside it, shouldn't we need a password_salt field too? And if the salt is stored in a separate database, isn't that inefficient and unscaleable?
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by createaccount94 on Saturday April 16, 2011 @09:59PM (#2455382)
>> hash = BCrypt::Password.create '123456'

=> "$2a$10$khoJWZR3hVA8Qcm3lW6sp.BQGOFKGo2xHCeH2YfDcQVRltEGCJe0S"

>> [hash.salt, hash.checksum]

=> ["$2a$10$khoJWZR3hVA8Qcm3lW6sp.", "BQGOFKGo2xHCeH2YfDcQVRltEGCJe0S"]

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by bodhi on Saturday April 16, 2011 @08:56PM (#2455291)
I believe, but I'd have to go check bcrypt to make sure, that the salt is stored as part of the digest.

Edit:

Actually, after minimal research, I see that salting the password is handled by the bcrypt ruby gem.

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by michaelfairley on Saturday April 16, 2011 @09:04PM (#2455306)
bcrypt stores the salt alongside the hash, so a single field is sufficient.