Re: [RFC][Discussion] Add PASSWORD_BCRYPT_WRAP
| From: | Mirco Babin | Date: | Thu, 19 Nov 2026 18:45:43 +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-133127@lists.php.net to get a copy of this message | ||
Hello Andrey Andreev,
>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?
(Andrey Andreev)
>I am against any character type validation and Bcrypt itself has
>issues related to character types.
(Mirco Babin)
What issues does Bcrypt have with character types? Where can these
issues be found, where are they listed?
What are the reasons against character type validation? It seems to me
that a password has to be human typeable? 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.
Also in favor for validation:
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 5
=========
(Andrey Andreev)
>You can use PBKDF2 if you want -- it's already in ext/hash -- but
>I'm not interested in it being a password_hash() option for a number
>of reasons:
>- It is neither memory-hard nor cache-hard. Argon2 won the PHC
> because it is memory-hard and NIST still favors that property,
> while cryptographers currently favor Bcrypt for being cache-hard.
> The only thing everyone agrees on is that PBKDF2 would be a
> downgrade.
>- It supports *too many* hash primitives, and its work factor
> (iterations) varies wildly both with each hash function and in how
> frequently it needs to be updated. Our current default Bcrypt cost
> of 12 is good for many years ahead, whereas we'd need to update
> PBKDF2 recommended settings all the time.
>- The previous point makes it very hard to maintain secure defaults
> both in terms of PHP support and as a broader recommendation.
> bcrypt-wrap is designed so that you *can* say "just use
> bcrypt-wrap" and not have to explain details.
(Mirco Babin)
This is a very strong argument against this non-standard
self-invented-security-algorithm RFC and in favor of the
NIST and OWASP favored security standard PASSWORD_ARGON2ID.
The last point is false. Because "bcrypt-wrap" is not a standard,
doest not have a NIST specification, does not have a IETF
specification, does not have an OpenBsd specification, one cannot say
to a C#-programmer or LUA-programmer or security officer "just use
bcrypt-wrap".
============
Comment 7(a)
============
(Mirco Babin)
>Why is bcrypt-prehashing needed below 73 password-bytes? Bcrypt can
>handle 72 bytes just fine.
(Mirco Babin)
This is still unanswered. Why does BCRYPT_WRAP not do:
```php
if (strlen($password) <= 72 && strpos($password, "\0") === false) {
// use PASSWORD_BCRYPT, it can handle this
} else {
// use PASSWORD_ARGON2ID
}
```
But then: why not use PASSWORD_ARGON2ID in all cases?
============
Comment 7(b)
============
(Mirco Babin)
>Why is something being proposed, that deteriorates security?
(Andrey Andreev)
>As I said in my last reply, your remaining questions were already
>very directly answered in the RFC FAQ.
>Not only was this not unanswered, it was the very first critique I
>received and there's a full screen worth of text addressing it (even
>includes arguments against this new COBS suggestion):
>https://wiki.php.net/rfc/password_bcrypt_wrap#doesn_t_decreased_input_space_reduce_bcrypt_security
(Mirco Babin)
See my reply to Rowan Tommins at
https://news-web.php.net/php.internals/133126
The prehash-function *does* truncate the password to 54*8 significant
inputbits for Bcrypt.
The RFC states:
>A more space-efficient encoding was actually considered during the
>design, in part for elegancy and in part to diffuse arguments like
>this one. That's still an option if these fears persist. However,
>Base64 is a pragmatic choice that makes implementation less complex
>and portability easier, with reduced risk of mistakes.
This is not an argument against COBS or another more space-efficient
encoding. The substantiation for the decision is, in fact, missing.
Unpadded-base64 is also not very portable. Also a
space-efficient algorithm (like COBS) really is not the complex part
of the non-standard self-invented-security-algorithm presented in
this RFC. Finding or implementing a reliable cSHAKE256 library is.
=========
Comment 8
=========
(Mirco Babin)
>The RFC as is still has no smileys in any example. Please add smileys
>into the example in the Proposal section. Like:
>
>$password = "A really, really long password, that's over 72 bytes
> and also includes a nice smiley face 😀";
>
>Also it is unwanted that $password contains a 0-byte. It is not human
>typable, does not make any sense. It should not be allowed.
(Andrey Andreev)
>If that's what you want, stick to pure Bcrypt. I will not be adding
>smileys to the example at this time - it is already very obvious that
>there are no character limitations, and emoji are no more special
>than any multibyte character.
(Mirco Babin)
Why is a 0x00-character then included in the example, if it is already
very obvious that there are no character limitations?
If I have to stick to pure Bcrypt, why is this RFC then even proposing
a non-standard self-invented-security-algorithm BCRYPT_WRAP?
Kind regards,
Mirco Babin