| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
place.
* renamed TOTP.verify() to TOTP.match() -- this matches the TotpMatch class name
a little better, and frees up TOTP.verify() for something new.
* added new TOTP.verify() which handles parsing TOTP config source,
and calling TOTP.match(), in one go. Main purpose of this is that
it has same signature (and roughly the same behavior) as PasswordHash.verify().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the application secrets needing for encryption -- renamed to AppWallet()
* AppWallet class dedicated to just holding application secrets,
rather than providing awkward frontend for TOTP construction.
Intended method for invoking it is through TOTP.using(),
which handles the details of construction.
* Renamed TOTP.context attr to TOTP.wallet
* Removed 'context' keyword from TOTP.from_source() etc,
callers should now bind the wallet via TOTP.using().from_source().
* Made AppWallet.default_tag a public attr,
renamed 'cost' attr to 'encrypt_cost'
* Removed the passlib.totp toplevel constructors (new, from_uri, from_json) --
can now do all that from TOTP class.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
configuration options
(such as secrets) already bound to the class.
* added TOTP.using() helper
* removed 'now' keyword from TOTP() constructor,
can now only be specified via TOTP.using() -- adjusted UTs accordingly
*
|
| |
|
|
| |
and added TOTP.from_dict() for explicitly deserializing from dict format.
|
| |
|
|
|
| |
to provider .cache_seconds & .cache_time attributes to help applications
decide how long the counter value should be cached.
|
| |
|
|
|
|
|
| |
TOTP.last_counter).
switching to purely stateless object, will update docs so that apps are
instructed to persist verify()'s last_counter value independantly.
|
| |
|
|
| |
since there's no need for the subdivision.
|
| |
|
|
|
|
|
|
|
|
| |
In preparation for merging BaseOTP & TOTP:
* removed BaseOTP.type attr & ._type_map,
* hardcoded TOTP class a few places since _type_map is gone
* removed 'type' parameter from dict/json format (not needed since HTOP gone)
* replaced refs to BaseOTP.from_*()/to_*() with TOTP.from_*()/to_*(),
since the base class methods no longer work.
|
| |
|
|
| |
to justify the contortions it requires in the shared BaseOTP api.
|
| |
|
|
| |
argon2 PHC compatibility.
|
| |
|
|
| |
to_dict() method.
|
| |
|
|
|
|
|
| |
into their own sections of file so they're easier to navigate.
tutorial covers a bunch of the basics, but still need to document OTPContext,
and give a highlevel integration example.
|
| |
|
|
|
|
|
|
|
|
| |
* reordering into 'narrative' and 'reference' sections,
to take advantage of 'fulltoc' extension making
all pages visible in sidebar.
* styling updates, requires latest cloud_sptheme
* wording improvements to various bits of content
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
application secrets
This reworks a large portion of the totp module's API, to make it fit better
with the needs of the applications it's been integrated into so far.
* Key encryption encapsulated in new OTPContext() class,
which not only handles encryption of keys, but supports
multiple application secrets, allowing migration to new secrets
(whether periodic, or after a breach).
This makes workflow of OTP object serialization *much* simpler.
* encryption format changed to use a simple dict, which gets embedded
into overall json data; eliminates need for custom binary format.
* BaseOTP.generate_next() has been renamed to .advance(),
to make it distinct from .generate(), and give better hinting
that it modifies the internal state
BaseOTP.verify_next() has been renamed to .consume() for similar reasons.
* All .verify() and .verify_next() methods have been modified
so they throw an InvalidTokenError if the token doesn't match,
instead of returning False.
This reduces the boilerplate needed to implement them,
as code already had to catch ValueErrors for malformed tokens & reused tokens.
- the HotpMatch / TotpMatch objects were adjusted to account
for fact that they're only used when token matches successfully.
* better exception hierarchy: added base TokenError,
as well as subclasses for specific cases (MalformedTokenError,
InvalidTokenError, UsedTokenError).
* renamed BaseOTP.dirty -> BaseOTP.changed
* BaseOTP now detects if encryption is old, and flags that re-encryption
+ re-serialization is needed.
* .from_string() / .to_string() renamed to .from_json() / .to_json()
to disambiguate with .from_uri() / .to_uri(), which also returns a string.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
v1.6 deprecated the "min_verify_time" feature, since it required admins
to awkwardly hard-code the amount of time they wanted .verify() to take.
This was a useful feature, though, since it provided the ability for
contexts to mask which accounts had older, weaker, hashes.
This commit adds in a replacement feature: CryptContext now supports
a "harden_verify" flag, which causes it to autocalculate how long
the default hash should take, and make sure to spend at least that much time.
Another improvement is that this autocalc is performed at the context level,
not per hash like min_verify_time was, making it overall more reliable.
It also offers a new "context.dummy_verify()" call for faking the delay
for missing accounts.
Changes:
* Added "harden_verify" option to CryptContext,
along with code to autocalculate min_verify_time delay via timing
when context is first accessed.
XXX: this timing code needs some battle-testing, and may be adjusted later.
* Added .dummy_verify() method, integrated it into .verify()
and .verify_and_update().
* updated warnings & docs to report harden_verify as replacement
for "min_verify_time" option.
* to help workflow for adding delay on missing accounts,
.verify() and .verify_and_update() now support passing in hash=None,
and treat it as "never verifying"
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Added PasswordHash.truncate_size info attribute, to detect hashes
which truncate the password.
* All such hashes (bcrypt, des_crypt, some others) now accept a "truncate_error"
option, allowing them to be switched from silent truncation to throwing
an error instead. This option is also supported by CryptContext.
* tests/HandlerCase:
- removed .secret_size config flag, can now just read handler.truncate_size instead.
- reworked truncation tests to use new API, and test 'truncate_error' policy support.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* PasswordHash.is_disabled flag now present, to programmatically detect
disabled hashers (unix_disabled, etc)
* CryptContext now offers methods for disabling, enabling, and testing
hashes to see if they're tied to a real hash or not.
* disabled hashers now offer .disable() and .enable() helpers,
as backend for CryptContext methods.
* django_disabled now appends random alphanumeric string, per Django.
* adjusted HandlerCase:
- checks handler.is_disabled,
- handle django_disabled via disabled_contains_salt flag
- tests .disable() and .enable() api if present
|
| |
|
|
|
|
| |
* switched to custom sphinx-fulltoc branch for now, due to readthedocs issue
* added tox.ini environment to test documentation building
* fixed rst warnings about dup target & missing document
|
| |
|
|
|
| |
* updated new_application_quickstart to account for Argon2
* added doc page for passlib.crypto
|
| |
|
|
|
|
|
| |
* tweaked passlib's format to follow argon2 and
use explicit param names + normal base64 encoding
* added support for openwall's $7$ format
* moved hash tests to separate file
|
| |
|
|
|
|
|
| |
* digest code now checks for fastpbkdf2 & hashlib backends
* tests: added some more test vectors from fastpbkdf2
* to match hashlib, now throwing OverflowError on large keylens, not ValueError.
* to match hashlib, now throwing ValueError on keylen=0, previously returned b""
|
| |
|
|
|
|
|
|
|
|
| |
* passlib.handlers.argon2 module contains 'argon2' hasher class,
for both argon2_cffi & argon2pure packages as backends.
* added UTs from argon2 clib source, as well as some from argon2_cffi,
and some more custom hashes.
* UT harness: added limit so salt range test doesn't eat up all the memory under argon2.
|
| | |
|
| |
|
|
|
| |
this basically reversed rev 5c41b0153d4f; after using it a bit more,
decided the name didn't indicate as well what the method was doing.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
callers should use handler.replace(**settings).hash() instead.
this is being done because it greatly streamlines the internals of the .hash()
implementation, and allows some redundant configuration parsing to be extracted
from the .hash() methods and merged in with existing code in .replace().
this also opens things up for alternate code architectures for implementing new hashers,
making it easier to wrap existing libraries (e.g. argon2).
internals
---------
* replaced a bunch of internal .hash(**settings) calls
* GenericHandler
- stripped out 'relaxed' keyword from constructor, since it's no longer
passed by hash() etc.
- _norm_checksum() now only invoked if checksum is specified (simplifies logic).
keeping support for 'relaxed' mode, but only as explicit keyword.
- removed some unused comments about .from_string() & .to_string()
* HasSalt mixin:
- .replace() now supports 'salt' keyword, creates variant
which has a fixed salt string.
- 'salt size' keyword removed from ctor, now handled by .replace() call
- _norm_salt() converted to class method so it can be
used by .replace() 'salt' keyword code.
- per-instance bits of _norm_salt() relocated to HasSalt.__init__ proper
- _generate_salt() converted to class method, since no longer depends on instance config.
* HasRounds mixin:
- similar to HasSalt, relocates per-instance bits of _norm_rounds()
into HasRounds.__init__() proper.
- remainder of _norm_rounds() turned into class method, merged
with ._clip_to_valid_rounds() helper to reduce duplication.
- _generate_rounds() converted to class method, since no longer depends on instance config.
hashers
-------
* fshp: added support for 'variant' keyword to replace()
* unix_disabled: added support for 'marker' keyword to replace(), added UTs.
* cisco_type7: to match HasSalt, added support for 'salt' keyword to replace(), added UTs.
* sha256/512_crypt: now uses custom salt & rounds parsing, rather than relaxed kwd,
to handle correctable-but-invalid config strings.
unittests
---------
* removed checks for PasslibConfigWarning when setting hash(rounds=) out of policy bounds,
since that now *is* setting the policy.
* adapted some handler ctor to deal w/ lack of 'relaxed' kwd
docs
----
* updated docstrings listing hash() keywords for each scheme to list them
as .replace() keywords.
* updated example code to use .replace()
* fleshed out api docs about the change
|
| |
|
|
| |
3.3 and up
|
| |
|
|
|
|
|
| |
* now preserves whitespace & comments to match htpasswd.
* now warns about & skips duplicate entries for same user.
* added semi-private .set_hash() helpers for writing hash directly.
* some internal cleanups to Htdigest's realm handling
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* scrypt kdf code
- relocated scrypt kdf code to passlib.crypto.scrypt
- py3 compat fixes
- split UTs out into separate file
- removed "non-power of 2" support, not needed.
- added wrapper which can toggle between builtin backend,
and extenrnal scrypt package.
- factored out n/r/p validation code so it can be used independantly
of calling kdf itself.
* passlib.handlers.scrypt: added scrypt handler which wraps the kdf.
- added some custom test strings, as well as adapted some reference values
from the scrypt whitepaper.
- added documentation page
- integrated scrypt kdf wrapper w/ hash's HasManyBackends api
|
| |
|
|
|
|
|
|
|
|
|
| |
as a fallback for 'default_rounds', 'min_rounds', and 'max_rounds'.
this makes it easier to specify a django-style policy of "deprecate all hashes
which have a differing rounds value".
* removed special handling from 'rounds' from CryptContext parser
* tweaked affected CryptContext serialization tests
* added test for new behavior
|
| |
|
|
|
|
|
|
|
|
| |
only legitimate use was for 'vary_rounds' option, which is being phased out,
and other uses like 'min_rounds' were a security issue.
* fixed CryptContext() tests to stop uses "all" kwds
* issue dep warning if "all" scheme is used
* issue config warning if anything but "vary_rounds" is used,
since config needs to be changed (regardless of passlib version)
|
| |
|
|
|
|
|
| |
and not worth the amount of code it requires to support it.
* stripped out vary_rounds from all internal presets
* added deprecation warning if it's ever used
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
.encrypt()
----------
hash.encrypt() & context.encrypt() have been renamed to .hash().
this should take care of the long-standing issue 21 (the poor naming of .encrypt).
per docs, legacy aliases will remain in place until passlib 2.0.
.genhash() / .genconfig()
-------------------------
taking advantage of this reorganization to also deprecate .genconfig()
and .genhash() -- they're not really useful in a modern system,
nor as needed for historical support as initially thought:
.genconfig() will be retired completely in passlib 2.0;
.genhash() is rolled into the new .hash() method along with .encrypt().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* split generate() into genword() & genphrase() --
APIs are just too different to keep combined.
* renamed internal calc funcs to better reflect their purpose.
* commented out PhraseGenerator's min_chars code, can't confirm
it's doing correct thing.
* commented out password strength estimator, too half-baked.
* tried to simplify SequenceGenerator attributes.
* genword(): defined some base charsets to work with
* genphrase(): wordsets now stored uncompressed (not really that big,
and .whl will compress everything for transport).
* fleshed out UTs for genword() & genphrase()
* updated docs
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
and moved them to a separate passlib.crypto subpackage.
along with this move, made a few api cleanups:
* unified all code that's looking up hashes
to use new passlib.crypto.lookup_hash() wrapper, which takes
care of hash name normalization, loading fallback implementations,
and alg metadata inspection, all hidden behind a memoized function.
* deprecated pbkdf2() in favor of pbkdf2_hmac() -- only real use,
and new signature matches stdlib function. additionally,
this version is a bit faster, due to some assumptions that
can be made due to the PRF always being HMAC based.
* added compile_hmac() helper which does an even more efficient
job of pre-compiling a keyed HMAC function; this helped speed up pbkdf2 a bit more.
|
| |
|
|
|
|
|
|
|
| |
announcement
motivation is that django hashers framework has matured greatly
as of django 1.8, and dropping all prior versions not only eases support burden,
but opens up opportunity for integration via less invasive method in a
future passlib release, using django 1.8 as a common base.
|
| |\ |
|
| | |
| |
| |
| |
| |
| | |
the context,
and they will only be passed on for the hashes that support them (fixes issue 63).
|
| |\ \
| |/ |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* split cisco ASA 7.0 code out into separate 'cisco_asa' class,
some minor reformatting of the internals (no alg changes).
* updated documentation to reflect the two different classes,
added to changelog.
* added some reference vectors generated by current implementation --
vectors chosen to verify thresholds around various if/thens in the ASA alg.
added note that these still need to be verified by official implementation.
|
| |\ \ |
|
| | |\ \
| | |/ |
|
| | | | |
|