X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fchap_ms.c;h=9a7002ced4201e572762951ec376371bedcd4c56;hp=114b951a40d936161cacde8904fcc0392a6db961;hb=c062322f9e8757b85a3c2281a3190d8af14bcd9b;hpb=4e3c66a04c0b86108858081d434bc45983471990;ds=sidebyside diff --git a/pppd/chap_ms.c b/pppd/chap_ms.c index 114b951..9a7002c 100644 --- a/pppd/chap_ms.c +++ b/pppd/chap_ms.c @@ -31,9 +31,7 @@ * You should also use DOMAIN\\USERNAME as described in README.MSCHAP80 */ -#ifndef lint -static char rcsid[] = "$Id: chap_ms.c,v 1.11 1998/11/24 19:30:38 christos Exp $"; -#endif +#define RCSID "$Id: chap_ms.c,v 1.16 2002/03/01 14:39:18 dfs Exp $" #ifdef CHAPMS @@ -43,7 +41,6 @@ static char rcsid[] = "$Id: chap_ms.c,v 1.11 1998/11/24 19:30:38 christos Exp $" #include #include #include -#include #include #ifdef HAVE_CRYPT_H #include @@ -58,13 +55,7 @@ static char rcsid[] = "$Id: chap_ms.c,v 1.11 1998/11/24 19:30:38 christos Exp $" #include #endif -typedef struct { - u_char LANManResp[24]; - u_char NTResp[24]; - u_char UseNT; /* If 1, ignore the LANMan response field */ -} MS_ChapResponse; -/* We use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse), - in case this struct gets padded. */ +static const char rcsid[] = RCSID; static void ChallengeResponse __P((u_char *, u_char *, u_char *)); @@ -98,7 +89,8 @@ ChallengeResponse(challenge, pwHash, response) BCOPY(pwHash, ZPasswordHash, MD4_SIGNATURE_SIZE); #if 0 - log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); + dbglog("ChallengeResponse - ZPasswordHash %.*B", + sizeof(ZPasswordHash), ZPasswordHash); #endif DesEncrypt(challenge, ZPasswordHash + 0, response + 0); @@ -106,7 +98,7 @@ ChallengeResponse(challenge, pwHash, response) DesEncrypt(challenge, ZPasswordHash + 14, response + 16); #if 0 - log_packet(response, 24, "ChallengeResponse - response", LOG_DEBUG); + dbglog("ChallengeResponse - response %.24B", response); #endif } @@ -128,8 +120,7 @@ DesEncrypt(clear, key, cipher) setkey(crypt_key); #if 0 - CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X", - clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); + CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %.8B", clear)); #endif Expand(clear, des_input); @@ -137,8 +128,7 @@ DesEncrypt(clear, key, cipher) Collapse(des_input, cipher); #if 0 - CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X", - cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); + CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %.8B", cipher)); #endif } @@ -158,15 +148,13 @@ DesEncrypt(clear, key, cipher) des_set_key(&des_key, key_schedule); #if 0 - CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X", - clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); + CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %.8B", clear)); #endif des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, key_schedule, 1); #if 0 - CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X", - cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); + CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %.8B", cipher)); #endif } @@ -245,10 +233,8 @@ static void MakeKey(key, des_key) #endif #if 0 - CHAPDEBUG((LOG_INFO, "MakeKey: 56-bit input : %02X%02X%02X%02X%02X%02X%02X", - key[0], key[1], key[2], key[3], key[4], key[5], key[6])); - CHAPDEBUG((LOG_INFO, "MakeKey: 64-bit output: %02X%02X%02X%02X%02X%02X%02X%02X", - des_key[0], des_key[1], des_key[2], des_key[3], des_key[4], des_key[5], des_key[6], des_key[7])); + CHAPDEBUG((LOG_INFO, "MakeKey: 56-bit input : %.7B", key)); + CHAPDEBUG((LOG_INFO, "MakeKey: 64-bit output: %.8B", des_key)); #endif } @@ -261,6 +247,12 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) MS_ChapResponse *response; { int i; +#ifdef __NetBSD__ + /* NetBSD uses the libc md4 routines which take bytes instead of bits */ + int mdlen = secret_len * 2; +#else + int mdlen = secret_len * 2 * 8; +#endif MD4_CTX md4Context; u_char hash[MD4_SIGNATURE_SIZE]; u_char unicodePassword[MAX_NT_PASSWORD * 2]; @@ -272,7 +264,7 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) unicodePassword[i * 2] = (u_char)secret[i]; MD4Init(&md4Context); - MD4Update(&md4Context, unicodePassword, secret_len * 2); + MD4Update(&md4Context, unicodePassword, mdlen); MD4Final(hash, &md4Context); /* Tell MD4 we're done */