diff options
| author | tedu <> | 2014-12-24 22:10:34 +0000 |
|---|---|---|
| committer | tedu <> | 2014-12-24 22:10:34 +0000 |
| commit | 2624c48e3a661801d934630f50049092517e4ebf (patch) | |
| tree | e49d6b4e0793bf0779ad4f155101db418f0324e8 /src/lib/libc | |
| parent | f1ee5eddb27c087d432e7e7c45e48fd91910b8d0 (diff) | |
| download | openbsd-2624c48e3a661801d934630f50049092517e4ebf.tar.gz openbsd-2624c48e3a661801d934630f50049092517e4ebf.tar.bz2 openbsd-2624c48e3a661801d934630f50049092517e4ebf.zip | |
simplify crypt_checkpass. The API promise is that this function doesn't
use global data. The simplest fix is to only check blowfish passwords,
and implicitly lock out DES passwords.
crypt_checkpass is currently only used in one place, passwd, to verify
the local user's password, so this is probably acceptable.
Gives people a little more time to migrate away from DES before introduing
checkpass into more places.
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/crypt/cryptutil.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/lib/libc/crypt/cryptutil.c b/src/lib/libc/crypt/cryptutil.c index ca8be8fa0f..f101240524 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.5 2014/11/24 21:36:35 tedu Exp $ */ | 1 | /* $OpenBSD: cryptutil.c,v 1.6 2014/12/24 22:10:34 tedu Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> | 3 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> |
| 4 | * | 4 | * |
| @@ -29,8 +29,7 @@ crypt_checkpass(const char *pass, const char *goodhash) | |||
| 29 | 29 | ||
| 30 | if (goodhash == NULL) { | 30 | if (goodhash == NULL) { |
| 31 | /* fake it */ | 31 | /* fake it */ |
| 32 | bcrypt_newhash(pass, 8, dummy, sizeof(dummy)); | 32 | goto fake; |
| 33 | goto fail; | ||
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | /* empty password */ | 35 | /* empty password */ |
| @@ -43,14 +42,9 @@ crypt_checkpass(const char *pass, const char *goodhash) | |||
| 43 | return 0; | 42 | return 0; |
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | /* have to do it the hard way */ | 45 | /* unsupported. fake it. */ |
| 47 | res = crypt(pass, goodhash); | 46 | fake: |
| 48 | if (res == NULL || strlen(res) != strlen(goodhash) || | 47 | bcrypt_newhash(pass, 8, dummy, sizeof(dummy)); |
| 49 | timingsafe_bcmp(res, goodhash, strlen(goodhash)) != 0) { | ||
| 50 | goto fail; | ||
| 51 | } | ||
| 52 | |||
| 53 | return 0; | ||
| 54 | fail: | 48 | fail: |
| 55 | errno = EACCES; | 49 | errno = EACCES; |
| 56 | return -1; | 50 | return -1; |
