diff options
Diffstat (limited to 'src/lib/libc/crypt/cryptutil.c')
| -rw-r--r-- | src/lib/libc/crypt/cryptutil.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libc/crypt/cryptutil.c b/src/lib/libc/crypt/cryptutil.c index f101240524..7e93dad3c8 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.6 2014/12/24 22:10:34 tedu Exp $ */ | 1 | /* $OpenBSD: cryptutil.c,v 1.7 2014/12/30 10:27:24 tedu Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> | 3 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> |
| 4 | * | 4 | * |
| @@ -21,6 +21,8 @@ | |||
| 21 | #include <login_cap.h> | 21 | #include <login_cap.h> |
| 22 | #include <errno.h> | 22 | #include <errno.h> |
| 23 | 23 | ||
| 24 | int bcrypt_autorounds(void); | ||
| 25 | |||
| 24 | int | 26 | int |
| 25 | crypt_checkpass(const char *pass, const char *goodhash) | 27 | crypt_checkpass(const char *pass, const char *goodhash) |
| 26 | { | 28 | { |
| @@ -64,9 +66,13 @@ crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen) | |||
| 64 | errno = EINVAL; | 66 | errno = EINVAL; |
| 65 | goto err; | 67 | goto err; |
| 66 | } | 68 | } |
| 67 | rounds = strtonum(pref + 9, 4, 31, &errstr); | 69 | if (strcmp(pref + 9, "a") == 0) { |
| 68 | if (errstr) | 70 | rounds = bcrypt_autorounds(); |
| 69 | goto err; | 71 | } else { |
| 72 | rounds = strtonum(pref + 9, 4, 31, &errstr); | ||
| 73 | if (errstr) | ||
| 74 | goto err; | ||
| 75 | } | ||
| 70 | rv = bcrypt_newhash(pass, rounds, hash, hashlen); | 76 | rv = bcrypt_newhash(pass, rounds, hash, hashlen); |
| 71 | 77 | ||
| 72 | err: | 78 | err: |
