3 crypt \- one-way password encryption function
7 #define _MINIX_SOURCE 1
10 char *crypt(const char *\fIkey\fP, const char *\fIsalt\fP)
16 is to encrypt a password. Its second use is to authenticate a shadow
17 password. In both cases
24 encrypts a password if called with a user typed key, and a salt
25 whose first two characters are in the set [./0-9A-Za-z]. The result is a
26 character string in the [./0-9A-Za-z] alphabet of which the first two
27 characters are equal to the salt, and the rest is the result of encrypting
32 is called with a salt that has the form
34 then the key is encrypted and compared to the encrypted password of
36 in the shadow password file. If they are equal then
40 argument, if not then some other string is returned. This trick assures
41 that the normal way to authenticate a password still works:
45 if (strcmp(pw->pw_passwd, crypt(key, pw->pw_passwd))) ...
51 is a null string, and the shadow password is a null string or the salt is a
52 null string then the result equals
54 (This is because the caller can't tell if a password field is empty in the
55 shadow password file.)
57 The key and salt are limited to 1024 bytes total including the null bytes.
61 The password authentication program
68 The result of an encryption is returned in a static array that is
69 overwritten by each call. The return value should not be modified.
71 Kees J. Bot (kjb@cs.vu.nl)