summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortedu <>2014-11-21 05:13:44 +0000
committertedu <>2014-11-21 05:13:44 +0000
commitf979161646cbb0dcb7a394df1cd4fbd92f440880 (patch)
treeaab55e1916150db511e8641b6da28da0485d6bd9
parent8227fbbb66c1dad3ea32f886ed7cb6d19fe4de31 (diff)
downloadopenbsd-f979161646cbb0dcb7a394df1cd4fbd92f440880.tar.gz
openbsd-f979161646cbb0dcb7a394df1cd4fbd92f440880.tar.bz2
openbsd-f979161646cbb0dcb7a394df1cd4fbd92f440880.zip
change prototype for crypt_newhash. the login_cap_t is a holdover from its
pwd_gensalt origins, but a string argument works equally work and is more friendly to consumers beyond local user accounts. ok deraadt
-rw-r--r--src/lib/libc/crypt/crypt_checkpass.313
-rw-r--r--src/lib/libc/crypt/cryptutil.c12
2 files changed, 10 insertions, 15 deletions
diff --git a/src/lib/libc/crypt/crypt_checkpass.3 b/src/lib/libc/crypt/crypt_checkpass.3
index 3a360fb899..479a78647b 100644
--- a/src/lib/libc/crypt/crypt_checkpass.3
+++ b/src/lib/libc/crypt/crypt_checkpass.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: crypt_checkpass.3,v 1.1 2014/11/20 19:18:25 tedu Exp $ 1.\" $OpenBSD: crypt_checkpass.3,v 1.2 2014/11/21 05:13:44 tedu Exp $
2.\" 2.\"
3.\" Copyright (c) Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 20 2014 $ 17.Dd $Mdocdate: November 21 2014 $
18.Dt CRYPT_CHECKPASS 3 18.Dt CRYPT_CHECKPASS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,9 +25,8 @@
25.In unistd.h 25.In unistd.h
26.Ft int 26.Ft int
27.Fn crypt_checkpass "const char *password" "const char *hash" 27.Fn crypt_checkpass "const char *password" "const char *hash"
28.In login_cap.h
29.Ft int 28.Ft int
30.Fn crypt_newhash "const char *password" "login_cap_t *lc" "char *hash" "size_t hashsize" 29.Fn crypt_newhash "const char *password" "const char *pref" "char *hash" "size_t hashsize"
31.Sh DESCRIPTION 30.Sh DESCRIPTION
32The 31The
33.Fn crypt_checkpass 32.Fn crypt_checkpass
@@ -47,9 +46,9 @@ The provided
47.Fa password 46.Fa password
48is randomly salted and hashed and stored in 47is randomly salted and hashed and stored in
49.Fa hash . 48.Fa hash .
50The login class argument 49The
51.Fa lc 50.Fa pref
52is used to identify the preferred hashing algorithm and parameters. 51argument identifies the preferred hashing algorithm and parameters.
53Refer to 52Refer to
54.Xr login.conf 5 . 53.Xr login.conf 5 .
55.Sh RETURN VALUES 54.Sh RETURN VALUES
diff --git a/src/lib/libc/crypt/cryptutil.c b/src/lib/libc/crypt/cryptutil.c
index 4a8c46be49..f9045ed601 100644
--- a/src/lib/libc/crypt/cryptutil.c
+++ b/src/lib/libc/crypt/cryptutil.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cryptutil.c,v 1.2 2014/11/17 16:47:28 tedu Exp $ */ 1/* $OpenBSD: cryptutil.c,v 1.3 2014/11/21 05:13:44 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4 * 4 *
@@ -55,16 +55,14 @@ fail:
55} 55}
56 56
57int 57int
58crypt_newhash(const char *pass, login_cap_t *lc, char *hash, size_t hashlen) 58crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen)
59{ 59{
60 int rv = -1; 60 int rv = -1;
61 char *pref; 61 const char *defaultpref = "blowfish,8";
62 char *defaultpref = "blowfish,8";
63 const char *errstr; 62 const char *errstr;
64 int rounds; 63 int rounds;
65 64
66 if (lc == NULL || 65 if (pref == NULL)
67 (pref = login_getcapstr(lc, "localcipher", NULL, NULL)) == NULL)
68 pref = defaultpref; 66 pref = defaultpref;
69 if (strncmp(pref, "blowfish,", 9) != 0) { 67 if (strncmp(pref, "blowfish,", 9) != 0) {
70 errno = EINVAL; 68 errno = EINVAL;
@@ -76,7 +74,5 @@ crypt_newhash(const char *pass, login_cap_t *lc, char *hash, size_t hashlen)
76 rv = bcrypt_newhash(pass, rounds, hash, hashlen); 74 rv = bcrypt_newhash(pass, rounds, hash, hashlen);
77 75
78err: 76err:
79 if (pref != defaultpref)
80 free(pref);
81 return rv; 77 return rv;
82} 78}