Review main Merged

42342[FEATURE] Add PBKDF2 based password storage to EXT:saltedpasswords

Morton Jonuschat CR +2 V +2 Hard +790 −2 updated 01/15/16, 15:13

Commit message

Implement the PBKDF2 password hashing for EXT:saltedpasswords. PBKDF2 is
the NIST recommended way to store passwords in a FIPS compliant way.

The storage format is identical with passlib from Python to enable some
portability as there's no official storage format yet.

The choice of iteration count has been set to a value that matches the
performance characteristics of the Blowfish/Bcrypt hashing.

Review

  • Code review CR +2
    • Markus Klein +2
    • Georg Ringer +1
  • Verified V +2
    • Markus Klein +2
    • Georg Ringer +1

Issues 1

Files 7

Review log 27

Show 2 earlier messages
  1. Morton Jonuschat uploaded patch set 1 08/07/15, 07:33

  2. Mathias Brodala commented on patch set 1 08/07/15, 07:45

    Feature-28230-AddSupportForPBKDF2ToSaltedpasswords.rst:15

    ... in the extension configuration

    Feature-28230-AddSupportForPBKDF2ToSaltedpasswords.rst:15

    enabled

    Pbkdf2SaltTest.php:51

  1. Morton Jonuschat uploaded patch set 2 08/07/15, 11:17

  2. Oliver Hader uploaded patch set 3 10/09/15, 06:33

  3. Morton Jonuschat rebased onto patch set 4 01/08/16, 17:22

  4. Markus Klein commented on patch set 4 01/08/16, 17:48

    Pbkdf2Salt.php:93

    ===

    Pbkdf2Salt.php:111

    ===

    Pbkdf2Salt.php:113

    can be reduced to: return $this->isValidSalt($saltedHashPW) && $this->getHashedPassword($plainPW, $saltedHashPW) === $saltedHashPW;

    Pbkdf2Salt.php:128

    how can that ever be false? shoud be $firstSplitPos, right?

    Pbkdf2Salt.php:147

    shorten namespace pls

    Pbkdf2Salt.php:188

    0 would be treated as empty password, must be !== ''
  5. Morton Jonuschat uploaded patch set 5 01/08/16, 18:45

  6. Markus Klein voted on patch set 5 CR +1 01/09/16, 18:51

  7. Markus Klein commented on patch set 5 V +1 01/09/16, 19:06

    Index.rst:72

    actually that doesn't help an integrator at all to make the decision whether to use this option. I think we can skip that part. Maybe some autodetection is possible somehow/somewhere?
  8. Frank Nägler commented on patch set 5 01/11/16, 09:00

    ext_tables.sql:61

    why we need here 255? the hash length for PBKDF2 is 32 or not?
  9. Christian Kuhn commented on patch set 5 01/11/16, 14:14

    ext_tables.sql:61 Reply

    imho not needed. at least fe_users and be_users should be kept in sync.
  10. Christian Kuhn commented on patch set 5 01/11/16, 14:45

    basically +1 on reading, but i'd like to have a proof with a 3rd party application or the reference implementation that the created hash can be successfully used.

    ext_tables.sql:61 Reply

    ah, needed: the example salt from the test has 174 characters. so - please extend both fe_users and be_users field length.

    Pbkdf2Salt.php:74

    blowfish?

    Pbkdf2Salt.php:250

    blowfish

    Pbkdf2Salt.php:263

    blowfish?

    Pbkdf2Salt.php:266

    blowfish?

    Index.rst:72 Reply

    i'd skip the last sentence, hash_pbkdf2 is always available since 5.5.
  11. Frank Nägler commented on patch set 5 V -1 01/11/16, 14:49

    can't change my password in user settings with patch applied. I have changed config to the new PBKDF2 hash but, click on save results in an endless request. can't find the problem at the moment.
  12. Morton Jonuschat uploaded patch set 6 01/11/16, 17:10

  13. Markus Klein commented on patch set 6 01/11/16, 20:41

    Index.rst:72

    my comment from set 5 is still valid
  14. Morton Jonuschat wrote 01/12/16, 09:31

    Patch set 7: Published edit on patch set 6.
  15. Christian Kuhn commented on patch set 7 01/12/16, 16:14

    Had a quick chat with Marcus on this topic: * It would be great to implement the test vectors from rfc6070 to verify results * How was the prefix "$pbkdf2-sha512$" chosen? At best, this would be in line with other major products, or is there some standards definition for this?
  16. Christian Kuhn commented on patch set 7 01/12/16, 16:43

    i'd like to have this as "standard" compatible as possible, also on the storage end. there seems to be no strict definition on that however, so it would be great to have further information from others in this regard. according to one of the unit tests, current chosen storage format is: $pbkdf2_sha512$iterationcount$salthash google says others seem to use an additional $ between salt and hash. a reference from other big projects would be great.

    Pbkdf2Salt.php:33

    lastpass used 100.000 with sha256 in 2011, see https://blog.lastpass.com/2011/05/lastpass-security-notification.html/
  17. Christian Kuhn commented on patch set 7 01/12/16, 16:52

    django: https://pythonhosted.org/passlib/lib/passlib.hash.django_std.html pbkdf2_sha256$10000$s1w0UXDd00XB$+4ORmyvVWAQvoAEWlDgN34vlaJx1ZTZpa1pCSRey2Yk=
  18. Morton Jonuschat commented on patch set 5 01/12/16, 18:04

    The test vectors from RFC6070 are for HMAC-SHA1 and not applicable to HMAC-SHA512. Afaik there are no RFC test vectors for other hashing algorithms. As we are using the PHP provided implementation of PBKDF2 we would only be (re-)testing the actual implementation of the algorithm by PHP, not our usage. The identifier $pbkdf2-sha512$ was chosen based upon LDAP / Passlib which both use the same format (LDAP uses curly braces instead of $). The choice not to separate salt and hash is based upon the blowfish format from EXT:saltedpasswords which doesn't separate it either. The iteration count was set to a value that takes about the same time as the current blowfish implementation. An iteration count of 100.000 made the password verification take upwards of 500ms which results in a noticeable delay on login compared to the other options.
  19. Georg Ringer voted on patch set 7 CR +1 V +1 01/15/16, 09:33

  20. Christian Kuhn commented on patch set 7 01/15/16, 11:10

    ok, last question - why sha512 and not sha256 that most other implementations use that i found in the wild?
  21. Morton Jonuschat commented on patch set 7 01/15/16, 11:50

    No specific reason except for "strongest" default. As discussed in Slack will change to SHA256 and add the $ between salt and hash.
  22. Morton Jonuschat uploaded patch set 8 01/15/16, 14:43

  23. Georg Ringer voted on patch set 8 CR +1 V +1 01/15/16, 14:51

  24. Markus Klein voted on patch set 8 CR +2 V +2 01/15/16, 15:13

  25. Gerrit merged patch set 8 01/15/16, 15:13