BSD 4_2 development
[unix-history] / usr / man / man3 / crypt.3
CommitLineData
05dda90f
C
1.TH CRYPT 3 "25 February 1983"
2.SH NAME
3crypt, setkey, encrypt \- DES encryption
4.SH SYNOPSIS
5.nf
6.B char *crypt(key, salt)
7.B char *key, *salt;
8.PP
9.B setkey(key)
10.B char *key;
11.PP
12.B encrypt(block, edflag)
13.B char *block;
14.fi
15.SH DESCRIPTION
16.I Crypt
17is the password encryption routine.
18It is based on the NBS Data Encryption Standard, with
19variations intended (among other things) to frustrate use of hardware
20implementations of the DES for key search.
21.PP
22The first argument to
23.I crypt
24is normally a user's typed password.
25The second is a 2-character string chosen from the
26set [a-zA-Z0-9./].
27The
28.I salt
29string is used to perturb the DES algorithm in one of 4096
30different ways, after which the password
31is used as the key to encrypt repeatedly a constant string.
32The returned value points to the encrypted password,
33in the same alphabet as the salt.
34The first two characters are the salt itself.
35.PP
36The other entries provide (rather primitive)
37access to the actual DES algorithm.
38The argument of
39.I setkey
40is a character array of length 64 containing only the characters
41with numerical value 0 and 1.
42If this string is divided into groups of 8,
43the low-order bit in each group is ignored,
44leading to a 56-bit key which is set into the machine.
45.PP
46The argument to the
47.I encrypt
48entry is likewise a character array of length 64
49containing 0's and 1's.
50The argument array is modified in place
51to a similar array
52representing the bits of the argument after having been
53subjected to the DES algorithm using the key set by
54.I setkey.
55If
56.I edflag
57is 0, the argument is encrypted;
58if non-zero,
59it is decrypted.
60.SH "SEE ALSO"
61passwd(1), passwd(5), login(1), getpass(3)
62.SH BUGS
63The return value
64points to static data whose content is overwritten
65by each call.