diff options
| author | tedu <> | 2015-01-28 23:33:52 +0000 |
|---|---|---|
| committer | tedu <> | 2015-01-28 23:33:52 +0000 |
| commit | a4e5c13d2841ff2068bd14c20cd2c1e3eaa4f13c (patch) | |
| tree | d618576f3065be0878ffb57657182319ed974673 /src | |
| parent | 7a956248ef874c38eeabdfa3912c758dbe16c625 (diff) | |
| download | openbsd-a4e5c13d2841ff2068bd14c20cd2c1e3eaa4f13c.tar.gz openbsd-a4e5c13d2841ff2068bd14c20cd2c1e3eaa4f13c.tar.bz2 openbsd-a4e5c13d2841ff2068bd14c20cd2c1e3eaa4f13c.zip | |
dial the time back to about 0.1s, closer to the original targets and
friendlier for users. requested by deraadt
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/crypt/bcrypt.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c index 8bf0995043..bc9441ccdf 100644 --- a/src/lib/libc/crypt/bcrypt.c +++ b/src/lib/libc/crypt/bcrypt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bcrypt.c,v 1.51 2015/01/12 03:20:04 tedu Exp $ */ | 1 | /* $OpenBSD: bcrypt.c,v 1.52 2015/01/28 23:33:52 tedu Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> | 4 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> |
| @@ -235,7 +235,7 @@ bcrypt_checkpass(const char *pass, const char *goodhash) | |||
| 235 | 235 | ||
| 236 | /* | 236 | /* |
| 237 | * Measure this system's performance by measuring the time for 8 rounds. | 237 | * Measure this system's performance by measuring the time for 8 rounds. |
| 238 | * We are aiming for something that takes between 0.25 and 0.5 seconds. | 238 | * We are aiming for something that takes around 0.1s, but not too much over. |
| 239 | */ | 239 | */ |
| 240 | int | 240 | int |
| 241 | bcrypt_autorounds(void) | 241 | bcrypt_autorounds(void) |
| @@ -254,12 +254,12 @@ bcrypt_autorounds(void) | |||
| 254 | duration += (after.tv_nsec - before.tv_nsec) / 1000; | 254 | duration += (after.tv_nsec - before.tv_nsec) / 1000; |
| 255 | 255 | ||
| 256 | /* too quick? slow it down. */ | 256 | /* too quick? slow it down. */ |
| 257 | while (r < 16 && duration <= 1000000 / 4) { | 257 | while (r < 16 && duration <= 60000) { |
| 258 | r += 1; | 258 | r += 1; |
| 259 | duration *= 2; | 259 | duration *= 2; |
| 260 | } | 260 | } |
| 261 | /* too slow? speed it up. */ | 261 | /* too slow? speed it up. */ |
| 262 | while (r > 4 && duration > 1000000 / 2) { | 262 | while (r > 4 && duration > 120000) { |
| 263 | r -= 1; | 263 | r -= 1; |
| 264 | duration /= 2; | 264 | duration /= 2; |
| 265 | } | 265 | } |
