I was testing this today as a potential alternative for passlib with bcrypt 5, and found a blocking issue.
bcrypt_sha256.verify() returns False for a hash that bcrypt_sha256.hash() just produced from the same password in the same process. Happens with bcrypt==4.3.0 and bcrypt==5.0.0. Doesn't happen on passlib==1.7.4, so this looks like a libpass-side regression rather than a bcrypt-compat thing.
Reproducer
# pip install libpass==1.9.3 bcrypt==4.3.0
from passlib.hash import bcrypt_sha256
h = bcrypt_sha256.using(rounds=12).hash("password")
print("hash: ", h)
print("verify:", bcrypt_sha256.verify("password", h))
Observed
hash: $bcrypt-sha256$v=2,t=2b,r=12$TkheP1Z9v6iFcmKaS8WyLu$t81vvvUJi9VS7mino2oycdr2dTDMzKe
verify: False
Expected
verify: True. passlib==1.7.4 on the same Python and same bcrypt returns True.
Compatibility matrix
| passlib package |
bcrypt |
hash → verify |
passlib==1.7.4 |
4.3.0 |
True |
libpass==1.9.3 |
4.3.0 |
False (this bug) |
libpass==1.9.3 |
5.0.0 |
False (this bug) |
libpass<=1.9.2 |
5.0.0 |
backend init throws (see note) |
On libpass<=1.9.2 + bcrypt==5.0.0 no verify ever runs: the wrap-bug probe in _finalize_backend_mixin calls bcrypt.hashpw with a 255-byte secret, and bcrypt 5.0 rejects it with ValueError: password cannot be longer than 72 bytes....
v=1 is broken too (bcrypt_sha256.using(version=1, rounds=12)), so it's not the HMAC change in v=2.
Environment
- Python 3.13
- macOS (haven't tried other platforms)
I was testing this today as a potential alternative for passlib with bcrypt 5, and found a blocking issue.
bcrypt_sha256.verify()returnsFalsefor a hash thatbcrypt_sha256.hash()just produced from the same password in the same process. Happens withbcrypt==4.3.0andbcrypt==5.0.0. Doesn't happen onpasslib==1.7.4, so this looks like a libpass-side regression rather than a bcrypt-compat thing.Reproducer
Observed
Expected
verify: True.passlib==1.7.4on the same Python and same bcrypt returns True.Compatibility matrix
hash → verifypasslib==1.7.44.3.0libpass==1.9.34.3.0libpass==1.9.35.0.0libpass<=1.9.25.0.0On
libpass<=1.9.2+bcrypt==5.0.0noverifyever runs: the wrap-bug probe in_finalize_backend_mixincallsbcrypt.hashpwwith a 255-byte secret, and bcrypt 5.0 rejects it withValueError: password cannot be longer than 72 bytes....v=1is broken too (bcrypt_sha256.using(version=1, rounds=12)), so it's not the HMAC change in v=2.Environment