Page MenuHomePhabricator

Make password hashing modular
ClosedPublic

Authored by epriestley on Feb 18 2014, 5:57 PM.
Tags
None
Referenced Files
F14099886: D8268.diff
Tue, Nov 26, 12:52 PM
Unknown Object (File)
Mon, Nov 18, 10:52 AM
Unknown Object (File)
Sun, Nov 10, 3:20 PM
Unknown Object (File)
Wed, Oct 30, 9:12 PM
Unknown Object (File)
Oct 26 2024, 6:22 AM
Unknown Object (File)
Oct 22 2024, 9:57 AM
Unknown Object (File)
Oct 18 2024, 9:57 PM
Unknown Object (File)
Oct 17 2024, 12:06 PM
Subscribers

Details

Summary

Ref T4443. Make hashing algorithms pluggable and extensible so we can deal with the attendant complexities more easily.

This moves "Iterated MD5" to a modular implementation, and adds a tiny bit of hack-glue so we don't need to migrate the DB in this patch. I'll migrate in the next patch, then add bcrypt.

Test Plan
  • Verified that the same stuff gets stored in the DB (i.e., no functional changes):
    • Logged into an old password account.
    • Changed password.
    • Registered a new account.
    • Changed password.
    • Switched back to master.
    • Logged in / out, changed password.
    • Switched back, logged in.
  • Ran unit tests (they aren't super extensive, but cover some of the basics).

Diff Detail

Repository
rP Phabricator
Branch
hashalg1
Lint
Lint Passed
Unit
Tests Passed

Event Timeline

Here's the new table to help administrators understand hashing:

{F115237}

I was going to ask "why?" Then I had the fun read of T4443. You sir are quite kind to existing installs re: php extensions. :)

src/infrastructure/util/password/PhabricatorPasswordHasher.php
10

hasher

Gave this a quick read-through; looks well-designed to handle corner cases such as moving to an install that has fewer hashers available, etc.

Yeah, on the one hand this is sort of overkill. If we had reasonable access to bcrypt in PHP 5.2.3 without extensions I would probably just switch all new hashing over and then opportunistically migrate the md5 stuff. However, we don't have convenient access until 5.5.0, and have no non-extension access to scrypt.

In defense of the complexity involved here, the underlying problem really is a migration problem (i.e., the cost factor of the hashing algorithm should theoretically be keeping pace with the speed of hardware), and this isn't that complex, and lets us reframe the problem completely as a migration problem: you specify the best algorithm, and everything moves toward it on average. After D8271, we can bump the cost factor every couple of years with one line of code.

I like all the transparency this brings around algorithms, too. And we can also share all this code in the VCS password stuff (coming shortly).

epriestley updated this revision to Unknown Object (????).Feb 18 2014, 8:07 PM
  • Fix spelling.

Whoops, I meant to accept earlier.