X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fchap_ms.c;h=7ae8e4229e1d8747beabbd9ee9abb32a927ffd96;hp=89f95b516c84d0744f7744d8167f6669a0cf2185;hb=d1d45379358dd274c95f6514aa454afd85bacdd1;hpb=3fc12c3580ef4a3f28847e86b8f1a5b2e9c00038 diff --git a/pppd/chap_ms.c b/pppd/chap_ms.c index 89f95b5..7ae8e42 100644 --- a/pppd/chap_ms.c +++ b/pppd/chap_ms.c @@ -32,15 +32,21 @@ */ #ifndef lint -static char rcsid[] = "$Id: chap_ms.c,v 1.4 1997/05/22 06:46:19 paulus Exp $"; +static char rcsid[] = "$Id: chap_ms.c,v 1.8 1998/04/01 00:15:43 paulus Exp $"; #endif #ifdef CHAPMS #include +#include +#include #include #include #include +#include +#ifdef HAVE_CRYPT_H +#include +#endif #include "pppd.h" #include "chap.h" @@ -60,8 +66,14 @@ typedef struct { in case this struct gets padded. */ +static void ChallengeResponse __P((u_char *, u_char *, u_char *)); static void DesEncrypt __P((u_char *, u_char *, u_char *)); static void MakeKey __P((u_char *, u_char *)); +static u_char Get7Bits __P((u_char *, int)); +static void ChapMS_NT __P((char *, int, char *, int, MS_ChapResponse *)); +#ifdef MSLANMAN +static void ChapMS_LANMan __P((char *, int, char *, int, MS_ChapResponse *)); +#endif #ifdef USE_CRYPT static void Expand __P((u_char *, u_char *)); @@ -77,7 +89,7 @@ ChallengeResponse(challenge, pwHash, response) char ZPasswordHash[21]; BZERO(ZPasswordHash, sizeof(ZPasswordHash)); - BCOPY(pwHash, ZPasswordHash, 16); + BCOPY(pwHash, ZPasswordHash, MD4_SIGNATURE_SIZE); #if 0 log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); @@ -243,9 +255,9 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) MS_ChapResponse *response; { int i; - MDstruct md4Context; + MD4_CTX md4Context; + u_char hash[MD4_SIGNATURE_SIZE]; u_char unicodePassword[MAX_NT_PASSWORD * 2]; - static int low_byte_first = -1; /* Initialize the Unicode version of the secret (== password). */ /* This implicitly supports 8-bit ISO8859/1 characters. */ @@ -253,23 +265,19 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) for (i = 0; i < secret_len; i++) unicodePassword[i * 2] = (u_char)secret[i]; - MDbegin(&md4Context); - MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ + MD4Init(&md4Context); + MD4Update(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ - if (low_byte_first == -1) - low_byte_first = (htons((unsigned short int)1) != 1); - if (low_byte_first == 0) - MDreverse(&md4Context); /* sfb 961105 */ + MD4Final(hash, &md4Context); /* Tell MD4 we're done */ - MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */ - - ChallengeResponse(rchallenge, (char *)md4Context.buffer, response->NTResp); + ChallengeResponse(rchallenge, hash, response->NTResp); } #ifdef MSLANMAN static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ -static ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) +static void +ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) char *rchallenge; int rchallenge_len; char *secret; @@ -278,7 +286,7 @@ static ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) { int i; u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ - u_char PasswordHash[16]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; /* LANMan password is case insensitive */ BZERO(UcasePassword, sizeof(UcasePassword));