Re: [RFC][Discussion] Add PASSWORD_BCRYPT_WRAP
| From: | Rowan Tommins [IMSoP] | Date: | Thu, 03 Dec 2026 22:36:24 +0000 |
| Subject: | Re: [RFC][Discussion] Add PASSWORD_BCRYPT_WRAP | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-133289@lists.php.net to get a copy of this message | ||
Hi Mirco,
On 03/12/2026 16:03, Mirco Babin wrote:
The original RFC https://wiki.php.net/rfc/argon2_password_hash_enhancements only states libargon2 as an implementation. On what platforms are Libsodium or Openssl used for PASSWORD_ARGON2ID?The additional implementations were added later: - libsodium by RFC: https://wiki.php.net/rfc/sodium.argon.hash - openssl, as far as I can see, just by PR: https://github.com/php/php-src/pull/13635 It's not necessarily specific platforms, it's up to whoever builds PHP from source which implementation to use based on the libraries they have available. The choice is transparent to the user, because they all register the same hash identifier.
Libargon2 looks not that big, see https://github.com/P-H-C/phc-winner-argon2 ; I don't see any reason why this can not be embedded?Looking at the original PR when argon2 was first added, I see this comment from @jpauli [https://github.com/php/php-src/pull/1997#issuecomment-231669727]:
I'm 👎 to bundle yet another lib, and to have to maintain it. This is a pain with libgd, libpcre and other libs we bundle, so please, rely on the OS distro.Feel free to open a discussion on that topic, though; I'm not claiming to know the final outcome, just trying to explain the current situation.
"significant inputbits" is my own term. I can rephrase that to: The bcrypt-plain is giving 2 ^ 72x8 bitcombinations to Bcrypt. The bcrypt-wrap-prehashed-password is giving 2 ^ 54x8 bitcombinations to Bcrypt. That is a deterioration of 2 ^ 18x8 bitcombinations, or 25%.However many ways you rephrase it, it's still a name you've made up, for a property that you can't explain the significance of. I could count the number of if statements in two hashing algorithms, and say that one had "19% lower if-density" than the other, and it would be about as meaningful.
That is not fully correct. Bcrypt outputs a 24 bytes hash...This an entirely pointless piece of pedantry. "23 bytes and 2 leftover bits" is still significantly lower than 54 bits, which is the only comparison that is relevant to the discussion.
"If the algorithm is perfectly uniform" is going into assumptions with this non-standard self-invented-security-algorithm Bcrypt-Wrap. Security should not be an assumption, it should be a fact.That paragraph was not making any claims or assumptions, it was stating a mathematical limit. Let me rephrase:
Even if we imagine an algorithm that is perfectly uniform, then it is still guaranteed by the Pigeonhole Principle that the same "23 bytes and 2 leftover bits" will be produced by multiple inputs at any input length larger than that. An imperfect algorithm may have more collisions, but not fewer.
"doesn't seem to have any mathematical significance" is another assumption with this non-standard self-invented-security-algorithm Bcrypt-Wrap. Security should not be an assumption, it should be a fact.Again, I made no claims or assumptions. You made the claim that the difference in "inputbits" was a "deterioration", so I asked you to back up that claim.
And what about side-channel effects, like timing or others? More assumptions will be raised etc. etc. etc. Self-designing and/or self-justifying a non-standard self-invented-security-algorithm is not the way to go for Php.Finally, you make an actually reasonable point - there is a danger in non-experts creating security primitives.
Userland can handle non-standard self-invented-security-algorithms, it is not a job for Php core. Just create a Composer installable library for this kind of self-rolled-security stuff.... and then you undermine yourself. Either people should be using these algorithms, and they should be easily available; or they should not be using them, wherever they're implemented.
If anything can be added to Php, it is hash('shake128'), hash('shake256'), hash('cshake128') and hash('cshake256') as defined in: https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.202.pdf https://csrc.nist.gov/pubs/sp/800/185/finalThat does indeed sound like it would be useful, with or without any use of them in the password hashing wrappers. -- Rowan Tommins [IMSoP]