1crypt_gensalt(3C)        Standard C Library Functions        crypt_gensalt(3C)
2
3
4

NAME

6       crypt_gensalt - generate salt string for string encoding
7

SYNOPSIS

9       #include <crypt.h>
10
11       char *crypt_gensalt(const char *oldsalt, const struct passwd *userinfo);
12
13

DESCRIPTION

15       The  crypt_gensalt()  function  generates  the  salt string required by
16       crypt(3C).
17
18
19       If oldsalt is NULL,  crypt_gensalt()  uses  the  algorithm  defined  by
20       CRYPT_DEFAULT in /etc/security/policy.conf. See policy.conf(4).
21
22
23       If  oldsalt  is  non-null,  crypt_gensalt() determines if the algorithm
24       specified  by  oldsalt  is  allowable  by  checking   the   CRYPT_ALGO‐
25       RITHMS_ALLOW  and  CRYPT_ALGORITHMS_DEPRECATE  variables  in /etc/secu‐
26       rity/policy.conf. If the algorithm is  allowed,  crypt_gensalt()  loads
27       the appropriate shared library and calls crypt_gensalt_impl(3C). If the
28       algorithm is not allowed or there is no entry  for  it  in  crypt.conf,
29       crypt_gensalt() uses the default algorithm.
30
31
32       The  mechanism  just described provides a means to migrate users to new
33       password hashing algorithms when the password is changed.
34

RETURN VALUES

36       Upon successful completion, crypt_gensalt() returns a  pointer  to  the
37       new  salt.  Otherwise  a  null  pointer is returned and errno is set to
38       indicate the error.
39

ERRORS

41       The crypt_gensalt() function will fail if:
42
43       EINVAL     The configuration file crypt.conf contains an invalid entry.
44
45
46       ELIBACC    The required shared library was not found.
47
48
49       ENOMEM     There is insufficient memory to perform hashing.
50
51

USAGE

53       The value returned  by  crypt_gensalt()  points  to  a  null-terminated
54       string.  The  caller  of  crypt_gensalt()  is  responsible  for calling
55       free(3C).
56
57
58       Applications dealing with user  authentication  and  password  changing
59       should  not  call  crypt_gensalt() directly but should instead call the
60       appropriate pam(3PAM) functions.
61

ATTRIBUTES

63       See attributes(5) for descriptions of the following attributes:
64
65
66
67
68       ┌─────────────────────────────┬─────────────────────────────┐
69       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
70       ├─────────────────────────────┼─────────────────────────────┤
71       │Interface Stability          │Evolving                     │
72       ├─────────────────────────────┼─────────────────────────────┤
73       │MT-Level                     │MT-Safe                      │
74       └─────────────────────────────┴─────────────────────────────┘
75

SEE ALSO

77       passwd(1), crypt(3C),  crypt_genhash_impl(3C),  crypt_gensalt_impl(3C),
78       getpassphrase(3C),  malloc(3C),  pam(3PAM),  crypt.conf(4),  passwd(4),
79       policy.conf(4), attributes(5)
80
81
82
83SunOS 5.11                        10 Jun 2002                crypt_gensalt(3C)
Impressum