summaryrefslogtreecommitdiff
path: root/docs/lib
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-06-15 17:43:31 -0400
committerEli Collins <elic@assurancetechnologies.com>2016-06-15 17:43:31 -0400
commit713c0bb81f3cec4ee15715657c627a9757a2edf2 (patch)
tree51161d33d6fb5ff95fdd643ec1a50465a0e16ae9 /docs/lib
parentd5ffe3e5645efa1737d659a564c54b45fff829d5 (diff)
downloadpasslib-713c0bb81f3cec4ee15715657c627a9757a2edf2.tar.gz
PasswordHash.hash() api shift: deprecating passing settings kwds into hash() --
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
Diffstat (limited to 'docs/lib')
-rw-r--r--docs/lib/passlib.context-tutorial.rst12
-rw-r--r--docs/lib/passlib.hash.bcrypt.rst2
-rw-r--r--docs/lib/passlib.hash.bcrypt_sha256.rst2
-rw-r--r--docs/lib/passlib.hash.bsdi_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.fshp.rst2
-rw-r--r--docs/lib/passlib.hash.md5_crypt.rst2
-rw-r--r--docs/lib/passlib.hash.pbkdf2_digest.rst2
-rw-r--r--docs/lib/passlib.hash.scram.rst4
-rw-r--r--docs/lib/passlib.hash.scrypt.rst2
-rw-r--r--docs/lib/passlib.hash.sha256_crypt.rst2
10 files changed, 11 insertions, 21 deletions
diff --git a/docs/lib/passlib.context-tutorial.rst b/docs/lib/passlib.context-tutorial.rst
index 2e7cc02..f9a5fce 100644
--- a/docs/lib/passlib.context-tutorial.rst
+++ b/docs/lib/passlib.context-tutorial.rst
@@ -346,17 +346,7 @@ New hashes generated by this context will always honor the minimum
>>> myctx.needs_update(hash1)
False
-Explicitly setting the rounds too low will cause a warning,
-and the minimum will be used anyways::
-
- >>> # explicit rounds passed to encrypt...
- >>> myctx.hash("password", rounds=1000)
- __main__:1: PasslibConfigWarning: sha256_crypt config requires rounds >= 131072,
- increasing value from 80000
- '$5$rounds=131072$86YrzUF3fGwY99oy$03e/pyh4l3N/G0509er9JiQmIxc0y9lrAJaLswX/iv8'
- ^^^^^^
-
-But if an existing hash below the minimum is tested, it will show up as needing rehashing::
+If an existing hash below the minimum is tested, it will show up as needing rehashing::
>>> # this has only 80000 rounds:
>>> hash3 = '$5$rounds=80000$qoCFY.akJr.flB7V$8cIZXLwSTzuCRLcJbgHlxqYKEK0cVCENy6nFIlROj05'
diff --git a/docs/lib/passlib.hash.bcrypt.rst b/docs/lib/passlib.hash.bcrypt.rst
index 039b178..68f6aea 100644
--- a/docs/lib/passlib.hash.bcrypt.rst
+++ b/docs/lib/passlib.hash.bcrypt.rst
@@ -19,7 +19,7 @@ for new applications. This class can be used directly as follows::
'$2a$12$NT0I31Sa7ihGEWpka9ASYrEFkhuTNeBQ2xfZskIiiJeyFXhRgS.Sy'
>>> # the same, but with an explicit number of rounds
- >>> bcrypt.hash("password", rounds=8)
+ >>> bcrypt.replace(rounds=8).hash("password")
'$2a$08$8wmNsdCH.M21f.LSBSnYjQrZ9l1EmtBc9uNPGL.9l75YE8D8FlnZC'
>>> # verify password
diff --git a/docs/lib/passlib.hash.bcrypt_sha256.rst b/docs/lib/passlib.hash.bcrypt_sha256.rst
index 8b8face..6d9fd7c 100644
--- a/docs/lib/passlib.hash.bcrypt_sha256.rst
+++ b/docs/lib/passlib.hash.bcrypt_sha256.rst
@@ -21,7 +21,7 @@ This class can be used directly as follows::
'$bcrypt-sha256$2a,12$LrmaIX5x4TRtAwEfwJZa1.$2ehnw6LvuIUTM0iz4iz9hTxv21B6KFO'
>>> # the same, but with an explicit number of rounds
- >>> bcrypt.hash("password", rounds=8)
+ >>> bcrypt.replace(rounds=8).hash("password")
'$bcrypt-sha256$2a,8$UE3dIZ.0I6XZtA/LdMrrle$Ag04/5zYu./12.OSqInXZnJ.WZoh1ua'
>>> # verify password
diff --git a/docs/lib/passlib.hash.bsdi_crypt.rst b/docs/lib/passlib.hash.bsdi_crypt.rst
index 082fd53..88bb49f 100644
--- a/docs/lib/passlib.hash.bsdi_crypt.rst
+++ b/docs/lib/passlib.hash.bsdi_crypt.rst
@@ -22,7 +22,7 @@ It class can be used directly as follows::
'_7C/.Bf/4gZk10RYRs4Y'
>>> # same, but with explict number of rounds
- >>> bsdi_crypt.hash("password", rounds=10001)
+ >>> bsdi_crypt.replace(rounds=10001).hash("password")
'_FQ0.amG/zwCMip7DnBk'
>>> # verify password
diff --git a/docs/lib/passlib.hash.fshp.rst b/docs/lib/passlib.hash.fshp.rst
index 5fd88db..640bb35 100644
--- a/docs/lib/passlib.hash.fshp.rst
+++ b/docs/lib/passlib.hash.fshp.rst
@@ -29,7 +29,7 @@ It can be used directly as follows::
'{FSHP1|16|16384}PtoqcGUetmVEy/uR8715TNqKa8+teMF9qZO1lA9lJNUm1EQBLPZ+qPRLeEPHqy6C'
>>> # the same, but with an explicit number of rounds, larger salt, and specific variant
- >>> fshp.hash("password", rounds=40000, salt_size=32, variant="sha512")
+ >>> fshp.replace(rounds=40000, salt_size=32, variant="sha512").hash("password")
'{FSHP3|32|40000}cB8yE/CuADSgUTQZjWy+YTf/cvbU11D/rHNKiUiB6z4dIaO77U/rmNW
pgZcZllZbCra5GJ8ZfFRNwCHirPqvYTAnbaQQeFQbWym/frRrRev3buoygFQRYexl4091Pc5m'
diff --git a/docs/lib/passlib.hash.md5_crypt.rst b/docs/lib/passlib.hash.md5_crypt.rst
index 3105c26..79cdad6 100644
--- a/docs/lib/passlib.hash.md5_crypt.rst
+++ b/docs/lib/passlib.hash.md5_crypt.rst
@@ -43,7 +43,7 @@ The :class:`!md5_crypt` class can be can be used directly as follows::
False
>>> # encrypt password using cisco-compatible 4-char salt
- >>> md5_crypt.hash("password", salt_size=4)
+ >>> md5_crypt.replace(salt_size=4).hash("password")
'$1$wu98$9UuD3hvrwehnqyF1D548N0'
.. seealso::
diff --git a/docs/lib/passlib.hash.pbkdf2_digest.rst b/docs/lib/passlib.hash.pbkdf2_digest.rst
index 8c5bca6..44e5419 100644
--- a/docs/lib/passlib.hash.pbkdf2_digest.rst
+++ b/docs/lib/passlib.hash.pbkdf2_digest.rst
@@ -32,7 +32,7 @@ All of these classes can be used directly as follows::
'$pbkdf2-sha256$6400$0ZrzXitFSGltTQnBWOsdAw$Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M'
>>> # same, but with an explicit number of rounds and salt length
- >>> pbkdf2_sha256.hash("password", rounds=8000, salt_size=10)
+ >>> pbkdf2_sha256.replace(rounds=8000, salt_size=10).hash("password")
'$pbkdf2-sha256$8000$XAuBMIYQQogxRg$tRRlz8hYn63B9LYiCd6PRo6FMiunY9ozmMMI3srxeRE'
>>> # verify the password
diff --git a/docs/lib/passlib.hash.scram.rst b/docs/lib/passlib.hash.scram.rst
index b1b6c3c..2836970 100644
--- a/docs/lib/passlib.hash.scram.rst
+++ b/docs/lib/passlib.hash.scram.rst
@@ -44,7 +44,7 @@ This class can be used like any other Passlib hash, as follows::
gzvGjbMeuWCtKve8TPjRMNoZK9EGyHQ6y0lW9OtWdHZrDZbBUhB9ou./VI2mlw'
>>> # same, but with an explicit number of rounds
- >>> scram.hash("password", rounds=8000)
+ >>> scram.replace(rounds=8000).hash("password")
'$scram$8000$Y0zp/R/DeO89h/De$sha-1=eE8dq1f1P1hZm21lfzsr3CMbiEA,sha-256=Nf
kaDFMzn/yHr/HTv7KEFZqaONo6psRu5LBBFLEbZ.o,sha-512=XnGG11X.J2VGSG1qTbkR3FVr
9j5JwsnV5Fd094uuC.GtVDE087m8e7rGoiVEgXnduL48B2fPsUD9grBjURjkiA'
@@ -64,7 +64,7 @@ Additionally, this class provides a number of useful methods for SCRAM-specific
* You can override the default list of digests, and/or the number of iterations::
- >>> hash = scram.hash("password", rounds=1000, algs="sha-1,sha-256,md5")
+ >>> hash = scram.replace(rounds=1000, algs="sha-1,sha-256,md5").hash("password")
>>> hash
'$scram$1000$RsgZo7T2/l8rBUBI$md5=iKsH555d3ctn795Za4S7bQ,sha-1=dRcE2AUjALLF
tX5DstdLCXZ9Afw,sha-256=WYE/LF7OntriUUdFXIrYE19OY2yL0N5qsQmdPNFn7JE'
diff --git a/docs/lib/passlib.hash.scrypt.rst b/docs/lib/passlib.hash.scrypt.rst
index 9629af7..b944360 100644
--- a/docs/lib/passlib.hash.scrypt.rst
+++ b/docs/lib/passlib.hash.scrypt.rst
@@ -27,7 +27,7 @@ This class can be used directly as follows::
'$2a$12$NT0I31Sa7ihGEWpka9ASYrEFkhuTNeBQ2xfZskIiiJeyFXhRgS.Sy'
>>> # the same, but with an explicit number of rounds
- >>> scrypt.hash("password", rounds=8)
+ >>> scrypt.replace(rounds=8).hash("password")
'$scrypt$16,8,1$aM15713r3Xsvxbi31lqr1Q$nFNh2CVHVjNldFVKDHDlm4CbdRSCdEBsjjJxD.iCs5E'
>>> # verify password
diff --git a/docs/lib/passlib.hash.sha256_crypt.rst b/docs/lib/passlib.hash.sha256_crypt.rst
index 069fc19..32c683c 100644
--- a/docs/lib/passlib.hash.sha256_crypt.rst
+++ b/docs/lib/passlib.hash.sha256_crypt.rst
@@ -23,7 +23,7 @@ This class can be used directly as follows::
'$5$rounds=80000$wnsT7Yr92oJoP28r$cKhJImk5mfuSKV9b3mumNzlbstFUplKtQXXMo4G6Ep5'
>>> # same, but with explict number of rounds
- >>> sha256_crypt.hash("password", rounds=12345)
+ >>> sha256_crypt.replace(rounds=12345).hash("password")
'$5$rounds=12345$q3hvJE5mn5jKRsW.$BbbYTFiaImz9rTy03GGi.Jf9YY5bmxN0LU3p3uI1iUB'
>>> # verify password