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/lib/libc/crypt/cryptutil.c | |
| 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 'src/lib/libc/crypt/cryptutil.c')
| -rw-r--r-- | src/lib/libc/crypt/cryptutil.c | 12 | 
1 files changed, 4 insertions, 8 deletions
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 | } | 
