<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Have you seen the PBKDF2 library?<div><br></div><div><a href="http://hackage.haskell.org/package/PBKDF2">http://hackage.haskell.org/package/PBKDF2</a></div><div><br></div><div><a href="http://hackage.haskell.org/package/PBKDF2"></a>&nbsp;Does that look like a reasonable way to store passwords securely?</div><div><br></div><div>- jeremy&nbsp;</div><div><br><div><div>On Feb 5, 2011, at 8:12 PM, Peter Scott wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">The usual advice on how to store passwords securely is "use bcrypt", but since there seem to be no Haskell bindings for bcrypt, the other good option is to iterate a salted hash function at least 1000 times. In order for people to get this right, there should be a library with a really simple API that makes it Just Work. I think I have such an API, but I'd like to hear if anybody else has suggestions before I go releasing it onto Hackage. The code is here:<div> <br></div><div><a href="https://github.com/PeterScott/pwstore">https://github.com/PeterScott/pwstore</a></div><div><br></div><div>The part of the API that people have to care about is two functions. makePassword creates a hashed, salted password that you can store in a database. verifyPassword takes this hashed, salted password and a user's password input, and tells you if it matches. Like this:</div> <div><br></div><div><div><div>&nbsp;&nbsp; &nbsp;&gt;&gt;&gt; makePassword (B.pack "hunter2") 12</div><div>&nbsp;&nbsp; &nbsp;"sha256|12|lMzlNz0XK9eiPIYPY96QCQ==|1ZJ/R3qLEF0oCBVNtvNKLwZLpXPM7bLEy/Nc6QBxWro="</div><div>&nbsp;&nbsp; &nbsp;</div><div> &nbsp;&nbsp; &nbsp;&gt;&gt;&gt; verifyPassword (B.pack "wrong guess") passwordHash</div><div>&nbsp;&nbsp; &nbsp;False</div><div>&nbsp;&nbsp; &nbsp;&gt;&gt;&gt; verifyPassword (B.pack "hunter2") passwordHash</div><div>&nbsp;&nbsp; &nbsp;True</div></div></div><div> <br></div><div>There's also a function for increasing the number of hash iterations on stored password hashes, to compensate for Moore's law.</div><div><br></div><div>Does this sound reasonable? Also, I have a pure-Haskell version and a version which depends on some C code, for speed (about 25x difference). Does anybody care about the pure Haskell version, or should I just drop it and require the faster C/Haskell mixed version?</div> <div><br></div><div>Thanks,</div><div>-Peter</div> _______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>http://www.haskell.org/mailman/listinfo/haskell-cafe<br></blockquote></div><br></div></body></html>