summaryrefslogtreecommitdiff
path: root/docs/lib/passlib.hash.bcrypt.rst
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-02-02 03:31:58 +0000
committerEli Collins <elic@assurancetechnologies.com>2011-02-02 03:31:58 +0000
commit7f90636c844c8ca9184ce9240989178195f7dc6e (patch)
treed9f4abf2ce95687eb47fce3f9b5518492e743eb6 /docs/lib/passlib.hash.bcrypt.rst
parent710fd478750b9be544f3cc72dcfeb36c9a564428 (diff)
downloadpasslib-7f90636c844c8ca9184ce9240989178195f7dc6e.tar.gz
more documentation work
Diffstat (limited to 'docs/lib/passlib.hash.bcrypt.rst')
-rw-r--r--docs/lib/passlib.hash.bcrypt.rst60
1 files changed, 58 insertions, 2 deletions
diff --git a/docs/lib/passlib.hash.bcrypt.rst b/docs/lib/passlib.hash.bcrypt.rst
index 5c68a22..32842fc 100644
--- a/docs/lib/passlib.hash.bcrypt.rst
+++ b/docs/lib/passlib.hash.bcrypt.rst
@@ -1,10 +1,66 @@
==================================================================
-:mod:`passlib.hash.bcrypt` - BCrypt password hash
+:mod:`passlib.hash.bcrypt` - BCrypt
==================================================================
.. module:: passlib.hash.bcrypt
:synopsis: BCrypt
+BCrypt was developed to replace :mod:`~passlib.hash.md5_crypt` for BSD systems.
+It uses a modified version of the Blowfish stream cipher. Featuring
+a large salt and variable number of rounds, it's currently the default
+password hash for many systems (notably BSD), and has no known weaknesses.
+
+.. note::
+
+ It is strongly recommended to install PyBcrypt if this algorithm
+ is going to be used.
+
+Usage
+=====
+
.. todo::
- write documentation
+ write usage instructions
+
+Functions
+=========
+.. autofunction:: genconfig
+.. autofunction:: genhash
+.. autofunction:: encrypt
+.. autofunction:: identify
+.. autofunction:: verify
+
+Format & Algorithm
+==================
+Bcrypt is compatible with the :ref:`modular-crypt-format`, and uses ``$2$`` and ``$2a$`` as the identifying prefix
+for all it's strings (``$2$`` is seen only for legacy hashes which used an older version of Bcrypt).
+An example hash (of ``password``) is ``$2a$12$GhvMmNVjRW29ulnudl.LbuAnUtN/LRfe1JsBm1Xu6LE3059z5Tr8m``.
+Bcrypt hashes have the format ``$2a${cost}${salt}{checksum}``, where:
+
+* ``{cost}`` is the cost parameter, encoded as 2 zero-padded decimal digits,
+ which determines the number of rounds used via ``rounds=2**cost`` (cost is 12 in the example).
+* ``{salt}`` is the 22 character salt string, using the characters ``[./A-Za-z0-9]`` (``GhvMmNVjRW29ulnudl.Lbu`` in the example).
+* ``{checksum}`` is the 31 character checksum, using the same characters as the salt (``AnUtN/LRfe1JsBm1Xu6LE3059z5Tr8m`` in the example).
+
+BCrypt's algorithm is described in detail in it's specification document,
+listed below.
+
+Deviations
+==========
+This implementation of bcrypt differs from others in a few ways:
+
+* The bcrypt specification (and implementations) have no predefined
+ or predictable behavior when passed a salt containing characters
+ outside of the base64 range. To avoid this situtation,
+ PassLib will simply throw an error if invalid characters
+ are provided for the salt.
+
+* Before generating a hash, PassLib encodes unicode passwords using UTF-8.
+ While the algorithm accepts passwords containing any 8-bit value
+ except for ``\x00``, it specifies no preference for encodings,
+ or for handling unicode strings.
+
+References
+==========
+* `<http://www.usenix.org/event/usenix99/provos/provos_html/>`_ - the bcrypt format specification
+* `<http://www.mindrot.org/projects/jBCrypt/>`_ - java implementation used as reference for PassLib