Blame README.md

Packit Bot e13ba5
[![Build Status](https://travis-ci.org/besser82/libxcrypt.svg?branch=develop)](https://travis-ci.org/besser82/libxcrypt)
Packit Bot e13ba5
[![codecov](https://codecov.io/gh/besser82/libxcrypt/branch/develop/graph/badge.svg)](https://codecov.io/gh/besser82/libxcrypt)
Packit Bot e13ba5
Packit Bot e13ba5
README for libxcrypt
Packit Bot e13ba5
====================
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt is a modern library for one-way hashing of passwords.  It
Packit Bot e13ba5
supports DES, MD5, NTHASH, SUNMD5, SHA-2-256, SHA-2-512, and
Packit Bot e13ba5
bcrypt-based password hashes, and provides the traditional Unix `crypt`
Packit Bot e13ba5
and `crypt_r` interfaces, as well as a set of extended interfaces
Packit Bot e13ba5
pioneered by Openwall Linux, `crypt_rn`, `crypt_ra`, `crypt_gensalt`,
Packit Bot e13ba5
`crypt_gensalt_rn`, and `crypt_gensalt_ra`.
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt is intended to be used by `login(1)`, `passwd(1)`, and other
Packit Bot e13ba5
similar programs; that is, to hash a small number of passwords during
Packit Bot e13ba5
an interactive authentication dialogue with a human.  It is not
Packit Bot e13ba5
suitable for use in bulk password-cracking applications, or in any
Packit Bot e13ba5
other situation where speed is more important than careful handling of
Packit Bot e13ba5
sensitive data.  However, it *is* intended to be fast and lightweight
Packit Bot e13ba5
enough for use in servers that must field thousands of login attempts
Packit Bot e13ba5
per minute.
Packit Bot e13ba5
Packit Bot e13ba5
Authorship and Licensing
Packit Bot e13ba5
------------------------
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt is currently maintained by Björn Esser and Zack Weinberg.
Packit Bot e13ba5
Many people have contributed to the code making up libxcrypt, often
Packit Bot e13ba5
under the aegis of a different project.  We particularly wish to thank
Packit Bot e13ba5
Solar Designer, Ulrich Drepper, David Burren, and Thorsten Kukuk.
Packit Bot e13ba5
Please see the AUTHORS and THANKS files for a full set of credits.
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt as a whole is licensed under the GNU Lesser General Public
Packit Bot e13ba5
License (version 2.1, or at your option, any later version).  However,
Packit Bot e13ba5
many individual files may be reused under more permissive licenses if
Packit Bot e13ba5
separated from the library.  Please see the LICENSING file for a
Packit Bot e13ba5
comprehensive inventory of licenses, and COPYING.LIB for the terms of
Packit Bot e13ba5
the LGPL.
Packit Bot e13ba5
Packit Bot e13ba5
Bug Reports, Feature Requests, Contributions, Etc.
Packit Bot e13ba5
--------------------------------------------------
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt is currently maintained at Github: the canonical repository
Packit Bot e13ba5
URL is <https://github.com/besser82/libxcrypt>.  Please file bug
Packit Bot e13ba5
reports at <https://github.com/besser82/libxcrypt/issues>.  This is
Packit Bot e13ba5
also the appropriate place to suggest new features, offer patches,
Packit Bot e13ba5
etc.  All your feedback is welcome and will eventually receive a
Packit Bot e13ba5
response, but this is a spare-time project for all of the present
Packit Bot e13ba5
maintainers, so please be patient.
Packit Bot e13ba5
Packit Bot e13ba5
Portability Notes
Packit Bot e13ba5
-----------------
Packit Bot e13ba5
Packit Bot e13ba5
libxcrypt should be buildable with any ISO C1999-compliant C compiler,
Packit Bot e13ba5
with one critical exception: the symbol versioning macros in
Packit Bot e13ba5
`crypt-port.h` only work with compilers that implement certain GCC/GNU
Packit Bot e13ba5
Binutils extensions (`.symver`, `__asm__`, and `__attribute__((alias)))`.
Packit Bot e13ba5
Packit Bot e13ba5
A few C2011 features are used; the intention is not to use any of them
Packit Bot e13ba5
without a fallback, but we do not currently test this.  A few POSIX
Packit Bot e13ba5
and nonstandard-but-widespread Unix APIs are also used; again, the
Packit Bot e13ba5
intention is not to use any of them without a fallback, but we do not
Packit Bot e13ba5
currently test this.  In particular, the crypt_gensalt functions may
Packit Bot e13ba5
not always be able to retrieve cryptographically-sound random numbers
Packit Bot e13ba5
from the operating system; if you call these functions with a null
Packit Bot e13ba5
pointer for the "rbytes" argument, be prepared for them to fail.
Packit Bot e13ba5
Packit Bot e13ba5
Compatibility Notes
Packit Bot e13ba5
-------------------
Packit Bot e13ba5
Packit Bot e13ba5
On Linux-based systems, by default libxcrypt will be binary backward
Packit Bot e13ba5
compatible with the libcrypt.so.1 shipped as part of the GNU C
Packit Bot e13ba5
Library.  This means that all existing binary executables linked
Packit Bot e13ba5
against glibc's libcrypt should work unmodified with this library's
Packit Bot e13ba5
libcrypt.so.1.  We have taken pains to provide exactly the same
Packit Bot e13ba5
"symbol versions" as were used by glibc on various CPU architectures,
Packit Bot e13ba5
and to account for the variety of ways in which the Openwall
Packit Bot e13ba5
extensions were patched into glibc's libcrypt by some Linux
Packit Bot e13ba5
distributions.  (For instance, compatibility symlinks for SUSE's
Packit Bot e13ba5
"libowcrypt" are provided.)
Packit Bot e13ba5
Packit Bot e13ba5
However, the converse is not true: programs linked against libxcrypt
Packit Bot e13ba5
will not work with glibc's libcrypt.  Also, programs that use certain
Packit Bot e13ba5
legacy APIs supplied by glibc's libcrypt (`encrypt`, `encrypt_r`,
Packit Bot e13ba5
`setkey`, `setkey_r`, and `fcrypt`) cannot be *compiled* against
Packit Bot e13ba5
libxcrypt.
Packit Bot e13ba5
Packit Bot e13ba5
Binary backward compatibility can be disabled by supplying the
Packit Bot e13ba5
`--disable-obsolete-api` switch to `configure`, in which case libxcrypt
Packit Bot e13ba5
will install libcrypt.so.2 instead of libcrypt.so.1.  This
Packit Bot e13ba5
configuration is always used on all operating systems other than
Packit Bot e13ba5
Linux.  We are willing to consider adding binary backward
Packit Bot e13ba5
compatibility for other operating systems' existing libcrypts, but we
Packit Bot e13ba5
don't currently plan to do that work ourselves.
Packit Bot e13ba5
Packit Bot e13ba5
Individual hash functions may be enabled or disabled by use of the
Packit Bot e13ba5
`--enable-hashes` switch to `configure`.  The default is to enable all
Packit Bot e13ba5
supported hashes.  Disabling the traditional 'des' hash algorithm
Packit Bot e13ba5
implies `--disable-obsolete-api`.  Security-conscious environments
Packit Bot e13ba5
without backward compatibility constraints are encouraged to use
Packit Bot e13ba5
`--enable-hashes=strong`, which enables only the hash functions that
Packit Bot e13ba5
are strong enough to be safe for newly hashed passwords.
Packit Bot e13ba5
Packit Bot e13ba5
The original implementation of the SUNMD5 hashing algorithm has a bug,
Packit Bot e13ba5
which is mimicked by libxcrypt to be fully compatible with hashes
Packit Bot e13ba5
generated on (Open)Solaris: According to the only existing
Packit Bot e13ba5
[documentation of this algorithm](https://dropsafe.crypticide.com/article/1389),
Packit Bot e13ba5
its hashes were supposed to have the format
Packit Bot e13ba5
`$md5[,rounds=%u]$<salt>$<checksum>`, and include only the bare
Packit Bot e13ba5
string `$md5[,rounds=%u]$<salt>` in the salt digest step. However,
Packit Bot e13ba5
almost all hashes encountered in production environments have the
Packit Bot e13ba5
format `$md5[,rounds=%u]$<salt>$$<checksum>` (note the double $$).
Packit Bot e13ba5
Unfortunately, it is not merely a cosmetic difference: hashes of this
Packit Bot e13ba5
format incorporate the first $ after the salt within the salt digest
Packit Bot e13ba5
step, so the resulting checksum is different.
Packit Bot e13ba5
The documentation hints that this stems from a bug within the
Packit Bot e13ba5
production implementation’s parser.  This bug causes the
Packit Bot e13ba5
implementation to return `$$`-format hashes when passed a configuration
Packit Bot e13ba5
string that ends with `$`.  It returns the intended original format
Packit Bot e13ba5
and checksum only if there is at least one letter after the `$`,
Packit Bot e13ba5
e.g. `$md5[,rounds=%u]$<salt>$x`.
Packit Bot e13ba5
Packit Bot e13ba5
The NTHASH algorithm, in its original implementation, never came with
Packit Bot e13ba5
any `gensalt` function, because the algorithm does not use any.
Packit Bot e13ba5
libxcrypt ships a bogus `gensalt` function for the NTHASH algorithm,
Packit Bot e13ba5
which simply returns `$3$__not_used__XXXXXXXXXXXXXX`, where the `X`s
Packit Bot e13ba5
stand for some more or less random salt.  There is no difference in
Packit Bot e13ba5
the resulting hash returned by the `crypt` function, whether using
Packit Bot e13ba5
one of the hashes returned by `gensalt` or simply using `$3$` as a
Packit Bot e13ba5
setting for hashing a password with NTHASH.
Packit Bot e13ba5
Packit Bot e13ba5
As a final compatibility note, glibc's libcrypt could optionally be
Packit Bot e13ba5
configured to use Mozilla's NSS library's implementations of the
Packit Bot e13ba5
cryptographic primitives MD5, SHA-2-256, and SHA-2-512.  This option
Packit Bot e13ba5
does not currently exist in libxcrypt, because we do not currently
Packit Bot e13ba5
believe it is a desirable option.  The stated rationale for the option
Packit Bot e13ba5
in glibc is to source all cryptographic primitives from a library that
Packit Bot e13ba5
has undergone FIPS certification, but we believe FIPS certification
Packit Bot e13ba5
would need to cover all of libxcrypt itself to have any meaningful
Packit Bot e13ba5
value.  Moreover, the primitive currently recommended for use by new
Packit Bot e13ba5
password hashes, bcrypt, is not available from NSS, so the
Packit Bot e13ba5
certification would not cover any part of what will hopefully be the
Packit Bot e13ba5
most used code path.