|
@ -1,4 +1,4 @@ |
|
|
.\" $OpenBSD: crypt.3,v 1.15 2000/04/15 02:15:22 aaron Exp $ |
|
|
|
|
|
|
|
|
.\" $OpenBSD: crypt.3,v 1.16 2000/04/18 02:31:34 aaron Exp $ |
|
|
.\" |
|
|
.\" |
|
|
.\" FreeSec: libcrypt |
|
|
.\" FreeSec: libcrypt |
|
|
.\" |
|
|
.\" |
|
@ -56,24 +56,32 @@ |
|
|
.Sh DESCRIPTION |
|
|
.Sh DESCRIPTION |
|
|
The |
|
|
The |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
|
function performs password encryption, based on the |
|
|
|
|
|
|
|
|
function performs password encryption based on the |
|
|
.Tn NBS |
|
|
.Tn NBS |
|
|
Data Encryption Standard (DES). |
|
|
Data Encryption Standard (DES). |
|
|
Additional code has been added to deter key search attempts and to use |
|
|
Additional code has been added to deter key search attempts and to use |
|
|
stronger hashing algorithms. |
|
|
stronger hashing algorithms. |
|
|
|
|
|
.Pp |
|
|
The first argument to |
|
|
The first argument to |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
|
is a |
|
|
is a |
|
|
.Dv null Ns -terminated |
|
|
.Dv null Ns -terminated |
|
|
string, typically a user's typed password. |
|
|
string, typically a user's typed password. |
|
|
The second is in one of three forms: |
|
|
The second is in one of three forms: |
|
|
if it begins with an underscore (``_'') then an extended format is used |
|
|
|
|
|
in interpreting both the key and the setting, as outlined below. If it begins |
|
|
|
|
|
with an string character (``$'') and a number then a different algorithm |
|
|
|
|
|
is used depending on the number. At the moment a ``$1'' chooses MD5 hashing |
|
|
|
|
|
and a ``$2'' chooses Blowfish hashing, see below for more information. |
|
|
|
|
|
.Ss Extended crypt: |
|
|
|
|
|
.Pp |
|
|
|
|
|
|
|
|
if it begins with an underscore |
|
|
|
|
|
.Pq Ql _ |
|
|
|
|
|
then an extended format is used |
|
|
|
|
|
in interpreting both the key and the setting, as outlined below. |
|
|
|
|
|
If it begins |
|
|
|
|
|
with a string character |
|
|
|
|
|
.Pq Ql $ |
|
|
|
|
|
and a number then a different algorithm is used depending on the number. |
|
|
|
|
|
At the moment a |
|
|
|
|
|
.Ql $1 |
|
|
|
|
|
chooses MD5 hashing and a |
|
|
|
|
|
.Ql $2 |
|
|
|
|
|
chooses Blowfish hashing; see below for more information. |
|
|
|
|
|
.Ss Extended crypt |
|
|
The |
|
|
The |
|
|
.Ar key |
|
|
.Ar key |
|
|
is divided into groups of 8 characters (the last group is null-padded) |
|
|
is divided into groups of 8 characters (the last group is null-padded) |
|
@ -87,61 +95,68 @@ The setting is a 9-character array consisting of an underscore followed |
|
|
by 4 bytes of iteration count and 4 bytes of salt. |
|
|
by 4 bytes of iteration count and 4 bytes of salt. |
|
|
These are encoded as printable characters, 6 bits per character, |
|
|
These are encoded as printable characters, 6 bits per character, |
|
|
least significant character first. |
|
|
least significant character first. |
|
|
The values 0 to 63 are encoded as ``./0-9A-Za-z''. |
|
|
|
|
|
|
|
|
The values 0 to 63 are encoded as |
|
|
|
|
|
.Dq \&./0-9A-Za-z . |
|
|
This allows 24 bits for both |
|
|
This allows 24 bits for both |
|
|
.Fa count |
|
|
.Fa count |
|
|
and |
|
|
and |
|
|
.Fa salt . |
|
|
.Fa salt . |
|
|
.Ss "MD5" crypt: |
|
|
|
|
|
.Pp |
|
|
|
|
|
|
|
|
.Ss "MD5" crypt |
|
|
For |
|
|
For |
|
|
.Tn MD5 |
|
|
.Tn MD5 |
|
|
crypt the version number, |
|
|
crypt the version number, |
|
|
.Fa salt |
|
|
.Fa salt |
|
|
and the hashed password are separated |
|
|
|
|
|
by the ``$'' character. The maximum length of a password is limited by |
|
|
|
|
|
|
|
|
and the hashed password are separated by the |
|
|
|
|
|
.Ql $ |
|
|
|
|
|
character. |
|
|
|
|
|
The maximum length of a password is limited by |
|
|
the length counter of the MD5 context, which is about |
|
|
the length counter of the MD5 context, which is about |
|
|
2**64. A valid MD5 password entry looks like this: |
|
|
|
|
|
|
|
|
2**64. |
|
|
|
|
|
A valid MD5 password entry looks like this: |
|
|
.Pp |
|
|
.Pp |
|
|
``$1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1''. |
|
|
|
|
|
|
|
|
.Dq $1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1 . |
|
|
.Pp |
|
|
.Pp |
|
|
The whole MD5 password string is passed as |
|
|
The whole MD5 password string is passed as |
|
|
.Fa setting |
|
|
.Fa setting |
|
|
for interpretation. |
|
|
for interpretation. |
|
|
.Ss "Blowfish" crypt: |
|
|
|
|
|
.Pp |
|
|
|
|
|
|
|
|
.Ss "Blowfish" crypt |
|
|
The |
|
|
The |
|
|
.Tn Blowfish |
|
|
.Tn Blowfish |
|
|
version of crypt has 128 bits of |
|
|
version of crypt has 128 bits of |
|
|
.Fa salt |
|
|
.Fa salt |
|
|
in order to make building |
|
|
|
|
|
dictionaries of common passwords space consuming. The initial state |
|
|
|
|
|
of the |
|
|
|
|
|
|
|
|
in order to make building dictionaries of common passwords space consuming. |
|
|
|
|
|
The initial state of the |
|
|
.Tn Blowfish |
|
|
.Tn Blowfish |
|
|
cipher is expanded using the |
|
|
cipher is expanded using the |
|
|
.Fa salt |
|
|
.Fa salt |
|
|
and the |
|
|
and the |
|
|
.Fa password |
|
|
.Fa password |
|
|
repeating the process a variable number of rounds, which is encoded in |
|
|
repeating the process a variable number of rounds, which is encoded in |
|
|
the password string. The maximum password length is 72. The final Blowfish |
|
|
|
|
|
password entry is created by encrypting |
|
|
|
|
|
the string ``OrpheanBeholderScryDoubt'' with the |
|
|
|
|
|
|
|
|
the password string. |
|
|
|
|
|
The maximum password length is 72. |
|
|
|
|
|
The final Blowfish password entry is created by encrypting the string |
|
|
|
|
|
.Pp |
|
|
|
|
|
.Dq OrpheanBeholderScryDoubt |
|
|
|
|
|
.Pp |
|
|
|
|
|
with the |
|
|
.Tn Blowfish |
|
|
.Tn Blowfish |
|
|
state 64 times. |
|
|
state 64 times. |
|
|
.Pp |
|
|
.Pp |
|
|
The version number, the logarithm of the number of rounds and |
|
|
The version number, the logarithm of the number of rounds and |
|
|
the concatenation of salt and |
|
|
|
|
|
hashed password are separated by the ``$'' character. An encoded ``8'' |
|
|
|
|
|
|
|
|
the concatenation of salt and hashed password are separated by the |
|
|
|
|
|
.Ql $ |
|
|
|
|
|
character. |
|
|
|
|
|
An encoded |
|
|
|
|
|
.Sq 8 |
|
|
would specify 256 rounds. |
|
|
would specify 256 rounds. |
|
|
A valid Blowfish password looks like this: |
|
|
A valid Blowfish password looks like this: |
|
|
.Pp |
|
|
.Pp |
|
|
``$2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC''. |
|
|
|
|
|
|
|
|
.Dq $2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC . |
|
|
.Pp |
|
|
.Pp |
|
|
The whole Blowfish password string is passed as |
|
|
The whole Blowfish password string is passed as |
|
|
.Fa setting |
|
|
.Fa setting |
|
|
for interpretation. |
|
|
for interpretation. |
|
|
.Ss "Traditional" crypt: |
|
|
|
|
|
.Pp |
|
|
|
|
|
|
|
|
.Ss "Traditional" crypt |
|
|
The first 8 bytes of the key are null-padded, and the low-order 7 bits of |
|
|
The first 8 bytes of the key are null-padded, and the low-order 7 bits of |
|
|
each character is used to form the 56-bit |
|
|
each character is used to form the 56-bit |
|
|
.Tn DES |
|
|
.Tn DES |
|
@ -153,8 +168,7 @@ Thus only 12 bits of |
|
|
are used. |
|
|
are used. |
|
|
.Fa count |
|
|
.Fa count |
|
|
is set to 25. |
|
|
is set to 25. |
|
|
.Ss DES Algorithm: |
|
|
|
|
|
.Pp |
|
|
|
|
|
|
|
|
.Ss DES Algorithm |
|
|
The |
|
|
The |
|
|
.Fa salt |
|
|
.Fa salt |
|
|
introduces disorder in the |
|
|
introduces disorder in the |
|
@ -182,10 +196,10 @@ string, 20 or 13 bytes (plus null) in length, consisting of the |
|
|
.Ar setting |
|
|
.Ar setting |
|
|
followed by the encoded 64-bit encryption. |
|
|
followed by the encoded 64-bit encryption. |
|
|
.Pp |
|
|
.Pp |
|
|
The functions, |
|
|
|
|
|
|
|
|
The functions |
|
|
.Fn encrypt , |
|
|
.Fn encrypt , |
|
|
.Fn setkey , |
|
|
.Fn setkey , |
|
|
.Fn des_setkey |
|
|
|
|
|
|
|
|
.Fn des_setkey , |
|
|
and |
|
|
and |
|
|
.Fn des_cipher |
|
|
.Fn des_cipher |
|
|
provide access to the |
|
|
provide access to the |
|
@ -243,7 +257,9 @@ E-box output as described above. |
|
|
.Pp |
|
|
.Pp |
|
|
The function |
|
|
The function |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
|
returns a pointer to the encrypted value on success, and NULL on failure. |
|
|
|
|
|
|
|
|
returns a pointer to the encrypted value on success, and |
|
|
|
|
|
.Dv NULL |
|
|
|
|
|
on failure. |
|
|
The functions |
|
|
The functions |
|
|
.Fn setkey , |
|
|
.Fn setkey , |
|
|
.Fn encrypt , |
|
|
.Fn encrypt , |
|
@ -254,7 +270,7 @@ return 0 on success and 1 on failure. |
|
|
.Pp |
|
|
.Pp |
|
|
The |
|
|
The |
|
|
.Fn crypt , |
|
|
.Fn crypt , |
|
|
.Fn setkey |
|
|
|
|
|
|
|
|
.Fn setkey , |
|
|
and |
|
|
and |
|
|
.Fn des_setkey |
|
|
.Fn des_setkey |
|
|
functions all manipulate the same key space. |
|
|
functions all manipulate the same key space. |
|
@ -265,12 +281,8 @@ functions all manipulate the same key space. |
|
|
.Xr getpass 3 , |
|
|
.Xr getpass 3 , |
|
|
.Xr md5 3 , |
|
|
.Xr md5 3 , |
|
|
.Xr passwd 5 |
|
|
.Xr passwd 5 |
|
|
.Sh BUGS |
|
|
|
|
|
The |
|
|
|
|
|
.Fn crypt |
|
|
|
|
|
function returns a pointer to static data, and subsequent calls to |
|
|
|
|
|
.Fn crypt |
|
|
|
|
|
will modify the same object. |
|
|
|
|
|
|
|
|
.Sh AUTHOR |
|
|
|
|
|
David Burren <davidb@werj.com.au> |
|
|
.Sh HISTORY |
|
|
.Sh HISTORY |
|
|
A rotor-based |
|
|
A rotor-based |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
@ -289,9 +301,14 @@ Programs linked against the |
|
|
interface may be exported from the U.S.A. only if they use |
|
|
interface may be exported from the U.S.A. only if they use |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
|
solely for authentication purposes and avoid use of |
|
|
solely for authentication purposes and avoid use of |
|
|
the other programmer interfaces listed above. Special care has been taken |
|
|
|
|
|
|
|
|
the other programmer interfaces listed above. |
|
|
|
|
|
Special care has been taken |
|
|
in the library so that programs which only use the |
|
|
in the library so that programs which only use the |
|
|
.Fn crypt |
|
|
.Fn crypt |
|
|
interface do not pull in the other components. |
|
|
interface do not pull in the other components. |
|
|
.Sh AUTHOR |
|
|
|
|
|
David Burren <davidb@werj.com.au> |
|
|
|
|
|
|
|
|
.Sh BUGS |
|
|
|
|
|
The |
|
|
|
|
|
.Fn crypt |
|
|
|
|
|
function returns a pointer to static data, and subsequent calls to |
|
|
|
|
|
.Fn crypt |
|
|
|
|
|
will modify the same object. |