diff options
| author | tedu <> | 2014-11-21 05:13:44 +0000 | 
|---|---|---|
| committer | tedu <> | 2014-11-21 05:13:44 +0000 | 
| commit | f4ef194c46079c465388ccf27ddab3a53684f8ab (patch) | |
| tree | aab55e1916150db511e8641b6da28da0485d6bd9 /src | |
| parent | 0756f4d6600a6a1bc7ea507aea3d13f405a4a3af (diff) | |
| download | openbsd-f4ef194c46079c465388ccf27ddab3a53684f8ab.tar.gz openbsd-f4ef194c46079c465388ccf27ddab3a53684f8ab.tar.bz2 openbsd-f4ef194c46079c465388ccf27ddab3a53684f8ab.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
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/crypt/crypt_checkpass.3 | 13 | ||||
| -rw-r--r-- | src/lib/libc/crypt/cryptutil.c | 12 | 
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 | 
| 32 | The | 31 | The | 
| 33 | .Fn crypt_checkpass | 32 | .Fn crypt_checkpass | 
| @@ -47,9 +46,9 @@ The provided | |||
| 47 | .Fa password | 46 | .Fa password | 
| 48 | is randomly salted and hashed and stored in | 47 | is randomly salted and hashed and stored in | 
| 49 | .Fa hash . | 48 | .Fa hash . | 
| 50 | The login class argument | 49 | The | 
| 51 | .Fa lc | 50 | .Fa pref | 
| 52 | is used to identify the preferred hashing algorithm and parameters. | 51 | argument identifies the preferred hashing algorithm and parameters. | 
| 53 | Refer to | 52 | Refer 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 | ||
| 57 | int | 57 | int | 
| 58 | crypt_newhash(const char *pass, login_cap_t *lc, char *hash, size_t hashlen) | 58 | crypt_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 | ||
| 78 | err: | 76 | err: | 
| 79 | if (pref != defaultpref) | ||
| 80 | free(pref); | ||
| 81 | return rv; | 77 | return rv; | 
| 82 | } | 78 | } | 
