From 319a75ef39b330c1a338b20a3763e1d58f8fa151 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 18 Jan 2001 00:35:09 +0000 Subject: [PATCH] Fix LMPASSWD code Move and behind SLAPD_CRYPT --- libraries/liblutil/passwd.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index bf78b247a8..3fcfc3c271 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -37,8 +37,10 @@ #include +#ifdef SLAPD_CRYPT #include #include +#endif #ifdef HAVE_SHADOW_H # include @@ -1104,24 +1106,27 @@ static struct berval *hash_md5( * } */ +static void lmPasswd_to_key( + const unsigned char *lmPasswd, + des_cblock *key) +{ + /* make room for parity bits */ + ((char *)key)[0] = lmPasswd[0]; + ((char *)key)[1] = ((lmPasswd[0]&0x01)<<7) | (lmPasswd[1]>>1); + ((char *)key)[2] = ((lmPasswd[1]&0x03)<<6) | (lmPasswd[2]>>2); + ((char *)key)[3] = ((lmPasswd[2]&0x07)<<5) | (lmPasswd[3]>>3); + ((char *)key)[4] = ((lmPasswd[3]&0x0F)<<4) | (lmPasswd[4]>>4); + ((char *)key)[5] = ((lmPasswd[4]&0x1F)<<3) | (lmPasswd[5]>>5); + ((char *)key)[6] = ((lmPasswd[5]&0x3F)<<2) | (lmPasswd[6]>>6); + ((char *)key)[7] = ((lmPasswd[6]&0x7F)<<1); + + des_set_odd_parity( key ); +} + static struct berval *hash_lanman( const struct pw_scheme *scheme, const struct berval *passwd ) { - static void lmPasswd_to_key(const unsigned char *lmPasswd, des_cblock *key) - { - /* make room for parity bits */ - ((char *)key)[0] = lmPasswd[0]; - ((char *)key)[1] = ((lmPasswd[0]&0x01)<<7) | (lmPasswd[1]>>1); - ((char *)key)[2] = ((lmPasswd[1]&0x03)<<6) | (lmPasswd[2]>>2); - ((char *)key)[3] = ((lmPasswd[2]&0x07)<<5) | (lmPasswd[3]>>3); - ((char *)key)[4] = ((lmPasswd[3]&0x0F)<<4) | (lmPasswd[4]>>4); - ((char *)key)[5] = ((lmPasswd[4]&0x1F)<<3) | (lmPasswd[5]>>5); - ((char *)key)[6] = ((lmPasswd[5]&0x3F)<<2) | (lmPasswd[6]>>6); - ((char *)key)[7] = ((lmPasswd[6]&0x7F)<<1); - - des_set_odd_parity( key ); - } int i; char UcasePassword[15]; -- 2.39.5