source: trunk/minix/man/man3/crypt.3@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.8 KB
RevLine 
[9]1.TH CRYPT 3
2.SH NAME
3crypt \- one-way password encryption function
4.SH SYNOPSIS
5.ft B
6.nf
7#define _MINIX_SOURCE 1
8#include <unistd.h>
9
10char *crypt(const char *\fIkey\fP, const char *\fIsalt\fP)
11.fi
12.ft P
13.SH DESCRIPTION
14The first use of
15.B crypt()
16is to encrypt a password. Its second use is to authenticate a shadow
17password. In both cases
18.B crypt()
19calls
20.BR pwdauth (8)
21to do the real work.
22.PP
23.B Crypt()
24encrypts a password if called with a user typed key, and a salt
25whose first two characters are in the set [./0-9A-Za-z]. The result is a
26character string in the [./0-9A-Za-z] alphabet of which the first two
27characters are equal to the salt, and the rest is the result of encrypting
28the key and the salt.
29.PP
30If
31.B crypt()
32is called with a salt that has the form
33.BI "##" user
34then the key is encrypted and compared to the encrypted password of
35.I user
36in the shadow password file. If they are equal then
37.B crypt()
38returns the
39.BI "##" user
40argument, if not then some other string is returned. This trick assures
41that the normal way to authenticate a password still works:
42.PP
43.RS
44.nf
45if (strcmp(pw->pw_passwd, crypt(key, pw->pw_passwd))) ...
46.fi
47.RE
48.PP
49If
50.I key
51is a null string, and the shadow password is a null string or the salt is a
52null string then the result equals
53.IR salt .
54(This is because the caller can't tell if a password field is empty in the
55shadow password file.)
56.PP
57The key and salt are limited to 1024 bytes total including the null bytes.
58.SH FILES
59.TP 25
60/usr/lib/pwdauth
61The password authentication program
62.SH "SEE ALSO"
63.BR getpass (3),
64.BR getpwent (3),
65.BR passwd (5),
66.BR pwdauth (8).
67.SH NOTES
68The result of an encryption is returned in a static array that is
69overwritten by each call. The return value should not be modified.
70.SH AUTHOR
71Kees J. Bot (kjb@cs.vu.nl)
Note: See TracBrowser for help on using the repository browser.