


CRYPT(3)               C LIBRARY FUNCTIONS               CRYPT(3)



NAME
     crypt, _crypt, setkey, encrypt - password and  data  encryp-
     tion

SYNOPSIS
     char *crypt(key, salt)
     char *key, *salt;

     char *_crypt(key, salt)
     char *key, *salt;

     setkey(key)
     char *key;

     encrypt(block, edflag)
     char *block;

DESCRIPTION
     crypt() is the password encryption routine, based on the NBS
     Data  Encryption  Standard,  with variations intended (among
     other things) to frustrate use of  hardware  implementations
     of the DES for key search.

     The first argument to crypt() is  normally  a  user's  typed
     password.   The  second  is a 2-character string chosen from
     the set [a-zA-Z0-9./].  Unless it starts with `##' or  `#$',
     the  _s_a_l_t string is used to perturb the DES algorithm in one
     of 4096 different ways, after which the password is used  as
     the  key  to  encrypt  repeatedly  a  constant  string.  The
     returned value points to the encrypted password, in the same
     alphabet as the salt.  The first two characters are the salt
     itself.

     If the _s_a_l_t string starts with `##', pwdauth(3)  is  called.
     If  _p_w_d_a_u_t_h  returns  TRUE, the salt is returned from crypt.
     Otherwise, NULL is returned.  If the _s_a_l_t string starts with
     `#$',  grpauth  (see  pwdauth(3))  is  called.   If  grpauth
     returns TRUE, the salt is returned from  crypt.   Otherwise,
     NULL  is  returned.   If there is a valid reason not to have
     this authentication happen, calling __c_r_y_p_t avoids  authenti-
     cation.

     The _s_e_t_k_e_y and _e_n_c_r_y_p_t entries  provide  (rather  primitive)
     access  to  the  DES algorithm.  The argument of _s_e_t_k_e_y is a
     character array of length 64 containing only the  characters
     with  numerical  value  0  and 1.  If this string is divided
     into groups of  8,  the  low-order  bit  in  each  group  is
     ignored;  this  gives  a  56-bit  key  which is set into the
     machine.  This is the key that will be used with  the  above
     mentioned  algorithm  to encrypt or decrypt the string _b_l_o_c_k
     with the function _e_n_c_r_y_p_t.




Sun Release 4.1    Last change: 6 October 1987                  1






CRYPT(3)               C LIBRARY FUNCTIONS               CRYPT(3)



     The argument to the _e_n_c_r_y_p_t entry is a  character  array  of
     length  64  containing  only  the  characters with numerical
     value 0 and 1.  The argument array is modified in place to a
     similar  array  representing  the bits of the argument after
     having been subjected to the DES algorithm using the key set
     by  _s_e_t_k_e_y. If _e_d_f_l_a_g is zero, the argument is encrypted; if
     non-zero, it is decrypted.

SEE ALSO
     login(1), passwd(1), getpass(3V), pwdauth(3), passwd(5)

BUGS
     The return value points to  static  data  whose  content  is
     overwritten by each call.









































Sun Release 4.1    Last change: 6 October 1987                  2



