summaryrefslogtreecommitdiff
path: root/docs/password_hash_api.rst
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-06-01 12:58:09 -0400
committerEli Collins <elic@assurancetechnologies.com>2011-06-01 12:58:09 -0400
commit92f3982bbcc94fae90794da52844f5b4f62d942f (patch)
treed00fc46240d99c3d95ded6aa351c1f8da7c85ac4 /docs/password_hash_api.rst
parent0365e4aba1c3e3af42b7aca1e9ece96b7dbf9c36 (diff)
downloadpasslib-92f3982bbcc94fae90794da52844f5b4f62d942f.tar.gz
various documentation updates
Diffstat (limited to 'docs/password_hash_api.rst')
-rw-r--r--docs/password_hash_api.rst47
1 files changed, 28 insertions, 19 deletions
diff --git a/docs/password_hash_api.rst b/docs/password_hash_api.rst
index 609b8c2..7b9e167 100644
--- a/docs/password_hash_api.rst
+++ b/docs/password_hash_api.rst
@@ -15,7 +15,7 @@ Overview
All of the hashes supported by PassLib are implemented using classes [#otypes]_
which support an identical interface; this document describes that
interface in terms of a non-existent abstract class called :class:`!PasswordHash`.
-All of the supported password hashes [#supported]_ expose (at a minimum) the following:
+All of the supported password hashes [#supported]_ provide the following methods and attributes:
:ref:`required-attributes`
@@ -34,7 +34,7 @@ All of the supported password hashes [#supported]_ expose (at a minimum) the fol
This interface consists of the :meth:`~PasswordHash.genconfig`
and :meth:`~PasswordHash.genhash` classmethods.
- This mimics the standard unix crypt interface,
+ These methods mimic the standard unix crypt interface,
and are not usually needed by applications.
:ref:`optional-attributes`
@@ -114,16 +114,19 @@ Required Attributes
``salt``
If present, this means the algorithm contains some number of bits of salt
- which should vary with every new hash created.
+ which should vary with every new hash created.
- Providing this as a keyword should allow the application to select
- a specific salt string; though not only is this far from needed
- for most cases, the salt string's content constraints vary for each algorithm.
+ Additionally, this means
+ :meth:`~PasswordHash.genconfig` and :meth:`~PasswordHash.encrypt`
+ should both accept an optional ``salt`` keyword allowing the user
+ to specify a bare salt string. Note that this feature is rarely
+ needed, and the constraints on the size & content of this string
+ will vary for each algorithm.
``salt_size``
- If present, this means the algorithm will auto-generate a salt
- of the specified number of characters
- (assuming ``salt`` is not specified explicitly).
+ Most algorithms which support ``salt`` will auto-generate a salt string
+ if none is provided. If this keyword is also present, it means it
+ can be used to select the size of the auto-generated salt.
If omitted, most algorithms will fall back to a default salt size.
``rounds``
@@ -150,7 +153,7 @@ Required Attributes
Some algorithms require external contextual information
in order to generate a checksum for a password.
An example of this is :doc:`Postgres' MD5 algorithm <lib/passlib.hash.postgres_md5>`,
- which requires the username to be provided when generating a hash
+ which requires the username be provided when generating a hash
(see that class for an example of how this works in pratice).
Since most password hashes require no external information,
@@ -227,10 +230,16 @@ which scheme a hash belongs to when multiple schemes are in use.
.. note::
- Some handlers may or may not return ``True`` for malformed hashes.
- Those that do will raise a ValueError once the hash is passed to :meth:`~PasswordHash.verify`.
- Most handlers, however, will just return ``False``.
-
+ The goal of this method is positively identify the correct
+ handler for a given hash, and do it as efficiently as possible.
+ In order to accomplish this, many implementations perform only minimal
+ validation of the candidate hashes. Thus, they may return ``True``
+ for hashes which are identifiable, but malformed enough that
+ a :exc:`ValueError` when the string is passed to
+ :func:`~PasswordHash.verify` or :func:`~PasswordHash.genhash`.
+ Because of this, applications should rely on this method only for identification,
+ not confirmation that a hash is correctly formed.
+
.. classmethod:: PasswordHash.verify(secret, hash, \*\*context_kwds)
verify a secret against an existing hash.
@@ -365,7 +374,7 @@ across all handlers in passlib.
.. todo::
Consider making these attributes required for all hashes
- which support the appropriate :attr:`settings` keyword.
+ which support the appropriate keyword in :attr:`~PasswordHash.setting_kwds`.
.. _optional-rounds-attributes:
@@ -428,22 +437,22 @@ the following attributes are usually exposed.
.. attribute:: PasswordHash.min_salt_size
- minimum number of characters required in salt string,
- if provided to :meth:`~PasswordHash.genconfig` or :meth:`~PasswordHash.encrypt`.
+ minimum number of characters required for any salt string
+ provided to :meth:`~PasswordHash.genconfig` or :meth:`~PasswordHash.encrypt`.
must be an integer within ``range(0,max_salt_size+1)``.
.. attribute:: PasswordHash.default_salt_size
size of salts generated by genconfig
when no salt is provided by caller.
- for most hashes, this defaults to :attr:`!PasswordHash.max_salt_size`.
+ for most hashes, this defaults to :attr:`~PasswordHash.max_salt_size`.
this value must be within ``range(min_salt_size, max_salt_size+1)``.
.. attribute:: PasswordHash.salt_chars
string containing list of all characters which are allowed
to be specified in salt parameter.
- for most hashes, this is equal to `passlib.utils.h64.CHARS`.
+ for most hashes, this is equal to :data:`passlib.utils.h64.CHARS`.
.. warning::