From 3e87ecb2f6d97f0a12ba76a32f46bd0f27b72c1b Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 25 Apr 2002 01:39:08 +0000 Subject: Rework libcrypt based on the openbsd crypt implementation so that it passes the DES validation suite. setkey_r, encrypt_r, and __des_crypt_r are not really reentrant now, and that should be fixed (or we should drop crypt_r and friends which are not supported by SuSv3). -Erik --- libcrypt/crypt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libcrypt/crypt.c') diff --git a/libcrypt/crypt.c b/libcrypt/crypt.c index 84c7678c2..027aa5a4d 100644 --- a/libcrypt/crypt.c +++ b/libcrypt/crypt.c @@ -21,11 +21,14 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define __FORCE_GLIBC #include #include /* For use by the old, non-reentrant routines (crypt/encrypt/setkey) */ static struct crypt_data __crypt_data; +extern char * __md5_crypt_r( const char *pw, const char *salt, struct crypt_data * data); +extern char * __des_crypt_r( const char *pw, const char *salt, struct crypt_data * data); extern char * crypt(const char *key, const char *salt) { @@ -42,3 +45,12 @@ extern void encrypt(char *block, int edflag) encrypt_r(block, edflag, &__crypt_data); } +extern char *crypt_r(const char *pw, const char *salt, struct crypt_data *data) +{ + /* First, check if we are supposed to be using the MD5 replacement + * instead of DES... */ + if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$') + return __md5_crypt_r(pw, salt, data); + else + return __des_crypt_r(pw, salt, data); +} -- cgit v1.2.3