diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2016-11-27 12:22:41 -0500 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2016-11-27 12:22:41 -0500 |
| commit | 8ee063dd5f436fdd035e6f596b82ba61bde079a6 (patch) | |
| tree | b85ae4bd5355c38ca312e2894f447bd96f14ec89 /docs | |
| parent | 5e230694bdc3c16a6962d3a57ec821584dccdc23 (diff) | |
| download | passlib-8ee063dd5f436fdd035e6f596b82ba61bde079a6.tar.gz | |
docs: wording tweaks, emphasized 1.7 changes in hash tutorial, added note about saslprep()
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/lib/passlib.hash.rst | 14 | ||||
| -rw-r--r-- | docs/narr/hash-tutorial.rst | 71 |
2 files changed, 48 insertions, 37 deletions
diff --git a/docs/lib/passlib.hash.rst b/docs/lib/passlib.hash.rst index f5a728c..3211066 100644 --- a/docs/lib/passlib.hash.rst +++ b/docs/lib/passlib.hash.rst @@ -20,11 +20,9 @@ including its format, underlying algorithm, and known security issues. **Many of the hash algorithms listed below are *NOT* secure.** Passlib supports a wide array of hash algorithms, primarily to - support dealing with legacy data and systems. - - If you're looking to choose a hash algorithm for a new application, - see the :doc:`Quickstart Guide </narr/quickstart>` instead of picking - one from this list. + support legacy data and systems. + If you want to choose a secure algorithm for a new application, + see the :doc:`Quickstart Guide </narr/quickstart>`. .. rst-class:: float-center @@ -49,7 +47,7 @@ by other applications and password hash schemes. Active Unix Hashes ------------------ -All these schemes are actively in use by various Unix flavors to store user passwords. +All the following schemes are actively in use by various Unix flavors to store user passwords They all follow the modular crypt format. .. toctree:: @@ -73,8 +71,8 @@ found in many Linux & BSD password files: Deprecated Unix Hashes ---------------------- The following schemes are supported by various Unix systems -use the modular crypt format, and are noticably stronger than the previous group. -However, they have all since been deprecated in favor of stronger algorithms: +using the modular crypt format, but are no longer considered secure, +and have been deprecated in favor of the `Active Unix Hashes`_ (above). * :class:`passlib.hash.bsd_nthash` - FreeBSD's MCF-compatible encoding of :doc:`nthash <passlib.hash.nthash>` digests diff --git a/docs/narr/hash-tutorial.rst b/docs/narr/hash-tutorial.rst index e32058c..b19de99 100644 --- a/docs/narr/hash-tutorial.rst +++ b/docs/narr/hash-tutorial.rst @@ -44,21 +44,19 @@ which fall into three general categories: Hashing & Verifying =================== -.. rst-class:: float-right without-title +While all the hashers in :mod:`passlib.hash` offer a range of methods and attributes, +the main activities applications will need to perform is hashing and verifying passwords. +This can be done with the :meth:`PasswordHash.hash` and :meth:`PasswordHash.verify` methods. + +.. rst-class:: float-center without-title .. caution:: **Changed in 1.7:** - This section has changed under Passlib 1.7. Prior releases used - :meth:`PasswordHash.encrypt`, which has now been renamed - to :meth:`PasswordHash.hash`. A legacy alias is present in 1.7, - but will be removed in Passlib 2.0. - -While all the hashers in :mod:`passlib.hash` offer a range of methods and attributes, -the main activities applications will need to perform is hashing and verifying passwords. - -This can be done with the :meth:`PasswordHash.hash` and :meth:`PasswordHash.verify` methods. + Prior releases used :meth:`PasswordHash.encrypt` for hashing, + which has now been renamed to :meth:`PasswordHash.hash`. + A compatibility alias is present in 1.7, but will be removed in Passlib 2.0. Hashing ------- @@ -108,35 +106,41 @@ using a different character encoding. In this case, passwords should be encoded using the correct encoding before they are passed to :meth:`!verify`; otherwise users may not be able to log in successfully. +For proper internationalization, applications should also take care to ensure +unicode inputs are normalized to a single representation before hashing. +The :func:`passlib.utils.saslprep` function can be used for this purpose. + .. _hash-configuring: Customizing the Configuration ============================= -.. rst-class:: float-right without-title -.. caution:: +The using() Method +------------------ +Each hasher contains a number of :ref:`informational attributes <informational-attributes>`. +many of which can be customized to change the properties of the hashes +generated by :meth:`PasswordHash.hash`. When you want to change the defaults, +you don't have to modify the hasher class directly, or pass in the options to each call to :meth:`!PasswordHash.hash`. - **Changed in 1.7:** +Instead, all the hashes offer a :meth:`PasswordHash.using` method. +This is a powerful method which accepts most hash informational attributes, +as well as some other hash-specific configuration keywords; and returns +a subclass of the original hasher (or a object with an identical interface). +The returned object inherits the defaults settings from it's parent, +but integrates any values you choose to override. - This section has changed under Passlib 1.7. Prior releases required you - to pass configuration options to each call of :meth:`PasswordHash.encrypt` - That pattern is deprecated, and will be removed in Passlib 2.0; - code should be switched to use :meth:`PasswordHash.using` + :meth:`PasswordHash.hash`... +.. rst-class:: float-center without-title -Each hasher contains a number of :ref:`informational attributes <informational-attributes>`, -many of which can be customized to change the properties of the hashes -generated by :meth:`PasswordHash.hash`. +.. caution:: -Instead of modifying the hasher class directly, or having to pass in -the options to each call to :meth:`!PasswordHash.hash`, -all the hashes offer a :meth:`PasswordHash.using` method. + **Changed in 1.7:** -This is a powerful method which accepts most hash informational attributes, -as well as some other hash-specific configuration keywords; and returns -a subclass of the original hasher (or an equivalent workalike). This object -inherits the defaults from it's parent, but integrates any values you -choose to override. + Prior releases required you to pass custom settings to each :meth:`PasswordHash.encrypt` call. + That usage pattern is deprecated, and will be removed in Passlib 2.0; + code should be switched to use :meth:`PasswordHash.using`, as shown below. +Usage Example +------------- As an example, if the hasher you select supports a variable number of iterations (such as :class:`~passlib.hash.pbkdf2_sha256`), you can specify a custom value using the ``rounds`` keyword. @@ -162,6 +166,8 @@ But if we call :meth:`PasswordHash.using`, we can override this value:: '$pbkdf2-sha256$123456$QwjBmJPSOsf4HyNE6L239g$8m1pnP69EYeOiKKb5sNSiYw9M8pJMyeW.CSm0KKO.GI' ^^^^^^ +Other Keywords +-------------- While hashes frequently have additional keywords supported by using, the basic set of settings you can customize can be found by inspecting the :attr:`PasswordHash.setting_kwds` attribute:: @@ -169,7 +175,14 @@ the :attr:`PasswordHash.setting_kwds` attribute:: >>> pbkdf2_sha256.settings_kwds ("salt", "salt_size", "rounds") -This method is additionally used internally by the :ref:`CryptContext <context-tutorial>` +For instance, the following generates pbkdf2 hashes with a 32-byte salt +instead of the default 16:: + + >>> pbkdf2_sha256.using(salt_size=8).hash("password") + '$pbkdf2-sha256$29000$tPZ.r5UyZgyhNEaI8Z5z7r1X6p1zTknJ.T/nHINwbq0$RlM49Qf5qRraHx.L7gq3hKIKSMLttrG1zWmWXyfXqc8' + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This method is also used internally by the :ref:`CryptContext <context-tutorial>` class it order to create a custom hasher configured based on the CryptContext policy it was provided. |
