Re: [RFC][Discussion] Add PASSWORD_BCRYPT_WRAP
| From: | Mirco Babin | Date: | Thu, 19 Nov 2026 18:40:33 +0000 |
| Subject: | Re: [RFC][Discussion] Add PASSWORD_BCRYPT_WRAP | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-133126@lists.php.net to get a copy of this message | ||
Hello Rowan Tommins,
>RFC link: https://wiki.php.net/rfc/password_bcrypt_wrap
=========
Comment 2
=========
(Mirco Babin)
> My question is misunderstood. Why does BCRYPT_WRAP not have a very
> first step 0 that validates that*password* is human typable, valid
> utf-8 and does not contain control characters?
(Rowan Tommins)
>Why would it? Is there some security or usability standard you can
>point to that suggests that password input be limited in this way?
(Mirco Babin)
When a password can consist of bytes, it is no longer a password
intended for human entry; instead, it functions more like an API key.
When the Bcrypt-2a revision was introduced, UTF-8 was apparently also
made mandatory. However, I cannot find a primary source for this
claim. A secondary source is:
https://javadoc.io/doc/at.favre.lib/bcrypt/latest/at/favre/lib/crypto/bcrypt/BCrypt.Version.html#VERSION_2A
=========
Comment 4
=========
(Mirco Babin)
> Why isn't this bugfixed then. So PASSWORD_ARGON2ID will become
> available out of the box?
(Rowan Tommins)
>It is not a "bug" to be "fixed"; it is a decision about what
>libraries are included in the source tree of PHP, and which are left
>as optional dependencies.
>
>PHP can have Argon2 support via one of three external libraries:
>libargon2, libsodium, or openssl. Making it available in all builds
>means including a copy of one of those libraries directly in the
>source tree.
So the decision can be made to make PASSWORD_ARGON2ID available
everywhere. The decision of supporting a security standard versus
introducing this non-standard self-invented-security-algorithm RFC
that violates OWASP recommendations. I assume Php does not consider
itself a LEGACY SYSTEM as OWASP calls it?
OWASP states:
https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#bcrypt
>The bcrypt password hashing function should only be used for
>password storage in legacy systems where Argon2 and scrypt are not
>available.
============
Comment 7(b)
============
(Rowan Tommins)
>This is a completely nonsensical comparison.
>A standard bcrypt output contains 23 bytes of final hash data; that's
>"only" 2.5 x 10^55 possible outputs. A 54-byte pre-hash has
>1.1 x 10^130 possible values.
(Mirco Babin)
I'm going to provide an example. Consider a password being
exactly 72 bytes, without 0x00-bytes.
The Bcrypt-plain scenario:
--------------------------
The input for the Bcrypt algorithm is exactly the
72-bytes-plain-password. There are 72*8 significant inputbits.
The Bcrypt-wrap scenario:
-------------------------
The RFC states:
>Whichever prehash function is chosen, 54 bytes of binary output
>are B64-encoded to fill the 72-byte space allowed by Bcrypt.
The 72-bytes-plain-password is prehashed. The hash-function is of no
importance, because Bcrypt-wrap states the prehash-ouput is always
54 bytes. Even though the 54 bytes are base64-encoded and expanded to
72 bytes, there are still only 54*8 significant inputbits after the
base64-encoding. These 54*8 significant inputbits are input for
Bcrypt.
Conclusion:
-----------
The bcrypt-plain is giving 72*8 significant inputbits to Bcrypt. The
bcrypt-wrap-prehashed-password is giving 54*8 significant inputbits to
Bcrypt. That is a deterioration of 18*8 bits, or 25%.
Kind regards,
Mirco Babin