z3c.bcrypt
z3c.bcrypt provides zope.password compatible “password manager” utilities that use bcrypt (or alternatively pbkdf2) encoding for storing passwords.
Both encoding schemes are implemented in the cryptacular library that is a dependency for this package.
Using z3c.bcrypt
>>> from zope.interface.verify import verifyObject >>> from zope.password.interfaces import IPasswordManager >>> from z3c.bcrypt import BcryptPasswordManager >>> manager = BcryptPasswordManager() >>> verifyObject(IPasswordManager, manager) True>>> password = u"right \N{CYRILLIC CAPITAL LETTER A}">>> encoded = manager.encodePassword(password) >>> encoded '$2a$...' >>> manager.checkPassword(encoded, password) True >>> manager.checkPassword(encoded, password + u"wrong") False>>> from z3c.bcrypt import PBKDF2PasswordManager >>> manager = PBKDF2PasswordManager() >>> verifyObject(IPasswordManager, manager) True>>> encoded = manager.encodePassword(password) >>> encoded u'$p5k2$...' >>> manager.checkPassword(encoded, password) True >>> manager.checkPassword(encoded, password + u"wrong") False>>> # A previously encoded password, should be decodable even if the >>> # current encoding of the same password is different:: >>> previouslyencoded = ( ... '$p5k2$1000$LgAFPIlc9CgrlSaxHyTUMA=' ... '=$IuUYplhMkR4qCl8-ONRVjEgJNwE=') >>> encoded == previouslyencoded False >>> manager.checkPassword(previouslyencoded , password) True
Excessively long “passwords” will take up a lot of computation time that can be used as a DOS attack vector. The password managers in z3c.bcrypt will only use the first 4096 characters of the incoming password for checking.
This is inspired by:
This test would take significantly longer if the 4096 length limit would not be in place. XXX how to test that reliably?
>>> incomming = '$p5k2$1000$' + 'a' * 1024 * 1024 * 100 # lot of data. >>> manager.checkPassword(encoded, incomming) False
Configuration
This package provides a configure.zcml which installs implementations of the IPasswordManager as utilities:
>>> from zope.configuration import xmlconfig >>> _ = xmlconfig.string(""" ... <configure ... xmlns="http://namespaces.zope.org/zope"> ... ... <include package="z3c.bcrypt" /> ... </configure> ... """)>>> from zope import component >>> from zope.password.interfaces import IPasswordManager >>> component.getUtility(IPasswordManager, name='bcrypt') <z3c.bcrypt.passwordmanager.BcryptPasswordManager object at ...> >>> component.getUtility(IPasswordManager, name='pbkdf2') <z3c.bcrypt.passwordmanager.PBKDF2PasswordManager object at ...>
Changelog of z3c.bcrypt
2.0.1 (2018-08-01)
Package is deprecated in favor of zope.password.
2.0.0 (2017-05-10)
Standardize namespace __init__.
Add support for Python 3.4, 3.5, 3.6 and PyPy.
1.2 (2013-10-10)
Only verify the first 4096 characters of a password to prevent denial-of-service attacks through repeated submission of large passwords, tying up server resources in the expensive computation of the corresponding hashes.
See: https://www.djangoproject.com/weblog/2013/sep/15/security/
1.1 (2010-02-22)
Fixes in the configure.zcml.
1.0 (2010-02-18)
Initial public release.
Metadata
Release files for z3c.bcrypt 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| z3c.bcrypt-2.0.1.tar.gz | 7.6 kB | Without provenance | Details for z3c.bcrypt-2.0.1.tar.gz |
Release files / z3c.bcrypt-2.0.1.tar.gz
| Download URL | z3c.bcrypt-2.0.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f12b07769d71596babb553a172088426ca2b92c28a034ecb948a138056c1f1f
|
|
BLAKE2b-256 checksum How to use checksums |
c36944e1fd04b264e9efc670f4d55e3da34ddfbf827d6bcdcb617f7f9c958a2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|
Security for z3c.bcrypt 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.