summaryrefslogtreecommitdiff
path: root/passlib/utils
Commit message (Collapse)AuthorAgeFilesLines
* Merge from defaultironpython-support-devEli Collins2012-04-175-212/+364
|\
| * disabling saslprep() support under Jython - it lacks the stringprep moduleEli Collins2012-04-172-6/+31
| |
| * a bunch of bugfixes found during unittestingEli Collins2012-04-171-2/+2
| | | | | | | | | | | | | | | | | | | | * bsdi_crypt apparently available on openbsd 4.9 * typo fixes * ConfigParser apparently only uses OrderedDict for >= PY27, adjusted CryptContext test accordingly * fixed test that depended on sha256_crypt.default_rounds * handle os_crypt backend w/ no fallback (bcrypt) * let _norm_rounds accept longs
| * updated passlib.apache module's api - more flexible to use, changed some ↵Eli Collins2012-04-171-5/+34
| | | | | | | | ambiguous method names
| * work on des_crypt familyEli Collins2012-04-131-115/+238
| | | | | | | | | | * cleaned up source of des_crypt variants and DES util functions * DES utils functions now have tighter input validation, full UT coverage
| * assorted bugfixes, tweaks, and tests added; based on coverage examinationEli Collins2012-04-124-82/+73
| | | | | | | | | | | | | | * test os_crypt backend has functional fallback * test handler methods accept all unicode/bytes combinations for secret & hash * fixed some incorrect error messages & types being caught & raised * other minor cleanups
* | wrote out all the known issues; made an attempt at deal w/ unicode-v-bytes ↵Eli Collins2012-04-122-30/+88
| | | | | | | | issues, will try again some other time
* | starting branch to add ironpython supportEli Collins2012-04-121-2/+23
|/ | | | * adds hack to disable saslprep() since stringprep is missing
* ran full UTs, found and fixed a few bugs introduced in last few commits.Eli Collins2012-04-111-0/+2
|
* clarify behavior for secret=None and hash=NoneEli Collins2012-04-114-71/+58
| | | | | | | | | | | | | | | | | | | | | | | * passing a non-string secret or non-string hash to any CryptContext or handler method will now reliably result in a TypeError. previously, passing hash=None to many handler identify() and verify() methods would return False, while others would raise a TypeError. other handler methods would alternately throw ValueError or TypeError when passed a value that wasn't unicode or bytes. the various CryptContext methods also behaved inconsistently, depending on the behavior of the underlying handler. all of these behaviors are gone, they should all raise the same TypeError. * redid many of the from_string() methods to verify the hash type. * moved secret type & size validation to GenericHandler's encrypt/genhash/verify methods. this cheaply made the secret validation global to all hashes, and lets _calc_digest() implementations trust that the secret is valid. * updated the CryptContext and handler unittests to verify the above behavior is adhered to.
* replaced some common string ops with util funcs (repeat_string, ↵Eli Collins2012-04-102-11/+20
| | | | right_pad_string)
* md5_crypt / sha2-crypt cleanupEli Collins2012-04-102-1/+10
| | | | | * tried to clarify documentation & alg for builtin md5_crypt / sha2-crypt backends * replaced regex parser in sha2-crypt with index-based one - less redundant, and should be faster.
* parse_mc3/render_mc3 helpers now handle rounds str<->int, consolidated a ↵Eli Collins2012-04-101-14/+68
| | | | bunch of redundant code
* passlib.exc: added constructors for common errors, should normalize error ↵Eli Collins2012-04-101-45/+60
| | | | messages
* fixed issue 29 - m2crypto crash may be triggered by keylen > 32, not > 41 as ↵Eli Collins2012-04-091-5/+7
| | | | I previously thought
* *all* hashes now throw PasswordSizeError if password is larger than 4096 ↵Eli Collins2012-04-092-1/+12
| | | | chars; to prevent DOS issues.
* bcrypt workEli Collins2012-03-121-1/+4
| | | | | | | * added code to shoehorn $2$-support wrapper for bcryptor backend * added PasslibSecurityWarning when builtin backend is enabled (still considered whether it should be enabled by default) * py3 compat fix for repair_unused
* doc tweaksEli Collins2012-03-121-3/+3
|
* updated test support & py3 compat code from an external libraryEli Collins2012-03-124-120/+130
| | | | | | | | | | | | | | | | passlib.tests ------------- * deprecated support for unittest 1... accumulated too many backports, planning to require unittest2 in next release. * case_prefix renamed to shortDescription * test case now archives & clears warning registry state in addition to warning filter state passlib.utils.compat -------------------- * a bunch of the bytes-related functions were renamed for clarity * NativeStringIO alias added * trange alias merged into irange
* to_bytes, to_unicode, to_native_str: added special TypeErrors for None, ↵Eli Collins2012-03-101-7/+17
| | | | other small tweaks
* safe_crypt() now handles "*0" and similar error returns from crypt()Eli Collins2012-03-101-6/+21
|
* added some notesEli Collins2012-03-101-1/+5
|
* various bcrypt improvementsEli Collins2012-03-102-7/+130
| | | | | | | | | | | | * studied crypt_blowfish's 8bit bug - verified none of passlib's backends were affected - added recognition (but not support) for crypt_blowfish's $2x$ hash prefix - added support for crypt_blowfish's $2y$ hash prefix - note in docs about Passlib's current handling of crypt_blowfish 8bit issues. * refactored bcrypt's salt-unused-bits repair code into Base64Engine.repair_unused(), making the code cleaner and more isolated. a bunch more tests. * added bcrypt64 (bcrypt-base64 variant) to utils * added LazyBase64Engine to reduce memory / startup time
* cleanup of scram hash; improved norm_digest_name() and moved it to utils.pbkdf2Eli Collins2012-03-101-1/+104
|
* added support for Cisco PIX & Type 7 hashesEli Collins2012-03-101-0/+18
| | | | | | | | * Cisco Type 5 appears to be same as md5_crypt * added requires_user=False support to HandlerCase * added more through salt-generation test (since cisco_pix has only 4 bits of salt) * added HandlerCase test to ensure user is used as salt
* utils.handlers framework reworked; removed a bunch of boilerplate codeEli Collins2012-03-091-285/+337
| | | | | | | | | | | | | | | | | | | | | | | | | | | * StaticHandler is now subclass of GenericHandler - _calc_checksum() should be implemented instead of encrypt(). (compatibility stub added so old code should continue to work) - _norm_hash() no longer needs to handle ->unicode conversion - default from_string() contains a bunch of features, including stripping a known prefix, etc. * context kwds now pulled into constructor, so GenericHandler supports context kwds properly; HasUserContext mixin added to support common 'user' context kwd * identify_regexp & identify_prefix removed, functionality rolled into default GenericHandler.identify() implementation. - default identify checks _hash_regex as potential way to identify hashes * HasStubChecksum removed, functionality rolled into GenericHandler * HasRawChecksum now just sets a flag, functionality moved into GenericHandler * HasManyIdents._parse_ident() helper added to valid & split identifier from hashes. * GenericHandler._norm_checksum() is now strict about unicode / bytes
* renamed calc_checksum() -> _calc_checksum(), hiding the last of the private ↵Eli Collins2012-02-081-17/+17
| | | | methods of most handlers
* renamed passlib.exc warning classesEli Collins2012-02-081-4/+4
|
* documentation updates for last two commitsEli Collins2012-02-081-95/+98
|
* minor tweaks & fixesEli Collins2012-02-081-1/+1
|
* large refactor of GenericHandler internalsEli Collins2012-02-081-166/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strict keyword -------------- * GenericHandler's "strict" keyword had poorly defined semantics; replaced this with "use_defaults" and "relaxed" keywords. Most handlers' from_string() method specified strict=True. This is now the default behavior, use_defaults=True is enabled only for encrypt() and genconfig(). relaxed=True is enabled only for specific handlers (and unittests) whose code requires it. This *does* break backward compat with passlib 1.5 handlers, but this is mostly and internal class. * missing required settings now throws a TypeError instead of a ValueError, to be more in line with std python behavior. * The norm_xxx functions provided by the GenericHandler mixins (e.g. norm_salt) have been renamed to _norm_xxx() to reflect their private nature; and converted from class methods to instance methods, to simplify their call signature for subclassing. misc ---- * rewrote GenericHandler unittests to use constructor only, instead of poking into norm_salt/norm_rounds internals. * checksum/salt charset checks speed up using set comparison * some small cleanups to FHSP implementation
* simplified crypt.crypt() wrappersEli Collins2012-01-192-45/+64
| | | | | | | * safe_crypt() improved - accepts unicode/bytes for salt, checks for NULL, returns None on failure * added test_crypt() wrapper to simplify backend checks. * removed native=True from most to_string() implementations, unused now. * updated UTs
* split exceptions/warnings to separate module; added some additional warning ↵Eli Collins2012-01-184-34/+23
| | | | classes to make filtering easier
* misc bugfixes from round of changesEli Collins2012-01-183-37/+112
| | | | | | | | | * added str_to_[ub]ascii to wrap hexdigest() calls * fixed some h64big calls I missed * some py3 fixes * removed utils.compat.aliases, using overlay to replace real compat module instead (to agree w/ imports already in code)
* StaticHandler._norm_hash() should return native str typeEli Collins2012-01-181-6/+8
|
* import cleanupsEli Collins2012-01-187-111/+114
| | | | | | | | | | | | | | | * moved bytes compat functions from utils to utils.compat (bord, bjoin, bjoin_ints, bjoin_elems, ujoin) * renamed bord -> belem_ord for clarify * a bunch of to_native_str() always use ascii, and have fixed input types (always bytes or always unicode). these don't need overhead of to_native_str(), so replaced those calls with two new funcs: compat.bascii_to_str() / compat.uascii_to_str() * cleaned up a lot of imports from utils/utils.compat to pull from correct module * simplified the to_string() logic of a bunch of handlers to reduce unicode<->byte transitions
* cleanups to utilsEli Collins2012-01-183-92/+77
|
* reordered contents of utilsEli Collins2012-01-181-271/+264
|
* deprecated unused int<->bytes utilsEli Collins2012-01-182-42/+13
|
* cleaned up utils a littleEli Collins2012-01-182-64/+61
|
* renamed the utils.handlers.XX_CHARS constants to match utils.XX_CHARS (old ↵Eli Collins2012-01-182-18/+18
| | | | aliases kept for now)
* replaced utils.h64 module with utils.Base64Engine instanceEli Collins2012-01-183-401/+517
| | | | | | | | | | | * new utils.Base64Engine() provides flexible class for encoding arbitrary base64 charmaps. it should also be a bit faster than the old h64 module. * predefined 'h64' instance has mostly the same methods as the old h64 module which it takes the place off - so imports should be unaffected. (the only the exception of the xxx_dc_xxx methods, which now use the 'h64big' instance) * replaced utils._blowfish base64 encoding with custom Base64Engine instance to reduce code duplication. * more through unittests for Base64Engine.
* added some function deprecation helpersEli Collins2012-01-181-6/+83
|
* lots of work on scram hashEli Collins2012-01-093-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | handler ------- * added 'scram' to default registry list * handler 'algs' keyword now parsed & validated correctly * digest names normalized -> IANA spec * saslprep() integrated into code * added config string format related ------- * added documentation (still needs cleaning up though) * added majority of UTs, still need to add a few edge cases other ----- * redid context->handler deprecation link - code now looks for handler._deprecated_detector(settings) to generate a callable, should be more efficient, and allow errors to be throw at bind-time instead of call-time. * pbkdf2() function now treats keylen = -1 as request for keylen = PRF digest size.
* clarified border case where verify() accepted configuration strings instead ↵Eli Collins2012-01-091-1/+27
| | | | of throwing ValueError for some handlers
* renamed utils.timer -> utils.tickEli Collins2012-01-051-4/+4
|
* move vm constants to compat moduleEli Collins2011-12-283-7/+6
|
* mvt code now uses time.clock() under win32Eli Collins2011-12-281-0/+36
|
* removed Undef singleton, private _NOTSET singletons are cleaner.Eli Collins2011-12-281-21/+0
|
* deprecated to_hash_str, replaced all instances with to_native_strEli Collins2011-12-284-31/+28
| | | | | | decided that to_hash_str will always return native string, feature of hashes being returned as unicode under python 2 is better done through a CryptContext option.