Unleashed v1.4
[unleashed.git] / share / man / man3c / crypt_gensalt.3c
blobe310aec43c394e286469c96234e3c055880fa25c
1 '\" te
2 .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH CRYPT_GENSALT 3C "Jun 10, 2002"
7 .SH NAME
8 crypt_gensalt \- generate salt string for string encoding
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <crypt.h>
14 \fBchar *\fR\fBcrypt_gensalt\fR(\fBconst char *\fR\fIoldsalt\fR, \fBconst struct passwd *\fR\fIuserinfo\fR);
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
20 The \fBcrypt_gensalt()\fR function generates the salt string required by
21 \fBcrypt\fR(3C).
22 .sp
23 .LP
24 If \fIoldsalt\fR is \fINULL\fR, \fBcrypt_gensalt()\fR uses the algorithm
25 defined by \fBCRYPT_DEFAULT\fR in \fB/etc/security/policy.conf\fR. See
26 \fBpolicy.conf\fR(4).
27 .sp
28 .LP
29 If \fIoldsalt\fR is non-null, \fBcrypt_gensalt()\fR determines if the algorithm
30 specified by \fIoldsalt\fR is allowable by checking the
31 \fBCRYPT_ALGORITHMS_ALLOW\fR and \fBCRYPT_ALGORITHMS_DEPRECATE\fR variables in
32 \fB/etc/security/policy.conf\fR. If the algorithm is allowed,
33 \fBcrypt_gensalt()\fR loads the appropriate shared library and calls
34 \fBcrypt_gensalt_impl\fR(3C). If the algorithm is not allowed or there is no
35 entry for it in \fBcrypt.conf\fR, \fBcrypt_gensalt()\fR uses the default
36 algorithm.
37 .sp
38 .LP
39 The mechanism just described provides a means to migrate users to new password
40 hashing algorithms when the password is changed.
41 .SH RETURN VALUES
42 .sp
43 .LP
44 Upon successful completion, \fBcrypt_gensalt()\fR returns a pointer to the new
45 salt. Otherwise a null pointer is returned and \fBerrno\fR is set to indicate
46 the error.
47 .SH ERRORS
48 .sp
49 .LP
50 The \fBcrypt_gensalt()\fR function will fail if:
51 .sp
52 .ne 2
53 .na
54 \fB\fBEINVAL\fR\fR
55 .ad
56 .RS 11n
57 The configuration file \fBcrypt.conf\fR contains an invalid entry.
58 .RE
60 .sp
61 .ne 2
62 .na
63 \fB\fBELIBACC\fR\fR
64 .ad
65 .RS 11n
66 The required shared library was not found.
67 .RE
69 .sp
70 .ne 2
71 .na
72 \fB\fBENOMEM\fR\fR
73 .ad
74 .RS 11n
75 There is insufficient memory to perform hashing.
76 .RE
78 .SH USAGE
79 .sp
80 .LP
81 The value returned by \fBcrypt_gensalt()\fR points to a null-terminated string.
82 The caller of \fBcrypt_gensalt()\fR is responsible for calling \fBfree\fR(3C).
83 .sp
84 .LP
85 Applications dealing with user authentication and password changing should not
86 call \fBcrypt_gensalt()\fR directly but should instead call the appropriate
87 \fBpam\fR(3PAM) functions.
88 .SH ATTRIBUTES
89 .sp
90 .LP
91 See \fBattributes\fR(5) for descriptions of the following attributes:
92 .sp
94 .sp
95 .TS
96 box;
97 c | c
98 l | l .
99 ATTRIBUTE TYPE  ATTRIBUTE VALUE
101 Interface Stability     Evolving
103 MT-Level        MT-Safe
106 .SH SEE ALSO
109 \fBpasswd\fR(1), \fBcrypt\fR(3C), \fBcrypt_genhash_impl\fR(3C),
110 \fBcrypt_gensalt_impl\fR(3C), \fBgetpassphrase\fR(3C), \fBmalloc\fR(3C),
111 \fBpam\fR(3PAM), \fBcrypt.conf\fR(4), \fBpasswd\fR(4), \fBpolicy.conf\fR(4),
112 \fBattributes\fR(5)