diff options
author | tedu <> | 2014-12-30 10:27:24 +0000 |
---|---|---|
committer | tedu <> | 2014-12-30 10:27:24 +0000 |
commit | 5be433bdbc930377f480e51c67406a3841179339 (patch) | |
tree | 047c9686f0cf60d1911a2a37db719790a8cbcb49 /src/lib/libc/crypt/cryptutil.c | |
parent | 91106b4c90b48b9064630173be7bc0822d7c8043 (diff) | |
download | openbsd-5be433bdbc930377f480e51c67406a3841179339.tar.gz openbsd-5be433bdbc930377f480e51c67406a3841179339.tar.bz2 openbsd-5be433bdbc930377f480e51c67406a3841179339.zip |
copy bcrypt autotune from encrypt(1) and expose via crypt_newhash
ok deraadt miod
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: |