From 4a26b4d029d3dfc51b5fc3926060ce7a67ee72f0 Mon Sep 17 00:00:00 2001 From: James Carlson Date: Wed, 14 Apr 2004 02:39:39 +0000 Subject: [PATCH] Tested with MS-CHAP and CBCP options on Solaris and added options to makefile. Repaired support for use of gcc on Solaris x86 -- 32 bit modules also need -fno-builtin. MPPE changes broke plain MS-CHAP; repaired errors and cleaned up compilation warnings due to char/unsigned char differences with non-gcc compilers. --- pppd/Makefile.sol2 | 10 ++++++++- pppd/chap_ms.c | 46 +++++++++++++++++++++++++--------------- solaris/Makefile.sol2gcc | 4 +++- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/pppd/Makefile.sol2 b/pppd/Makefile.sol2 index 902f3d3..75c2922 100644 --- a/pppd/Makefile.sol2 +++ b/pppd/Makefile.sol2 @@ -1,6 +1,6 @@ # # Makefile for pppd under Solaris 2. -# $Id: Makefile.sol2,v 1.25 2004/01/17 05:47:55 carlsonj Exp $ +# $Id: Makefile.sol2,v 1.26 2004/04/14 02:39:39 carlsonj Exp $ # include ../Makedefs.com @@ -32,6 +32,14 @@ LIBS += -ldl #CFLAGS += -DINET6 #OBJS += ipv6cp.o eui64.o +# Uncomment to enable MS-CHAP +#CFLAGS += -DUSE_CRYPT -DCHAPMS -DHAVE_CRYPT_H +#OBJS += chap_ms.o pppcrypt.o md4.o sha1.o + +# Uncomment for CBCP +#CFLAGS += -DCBCP_SUPPORT +#OBJS += cbcp.o + # # Make targets # diff --git a/pppd/chap_ms.c b/pppd/chap_ms.c index 2dde5ba..16fb3a8 100644 --- a/pppd/chap_ms.c +++ b/pppd/chap_ms.c @@ -74,7 +74,7 @@ * */ -#define RCSID "$Id: chap_ms.c,v 1.30 2003/07/10 17:59:33 fcusack Exp $" +#define RCSID "$Id: chap_ms.c,v 1.31 2004/04/14 02:39:39 carlsonj Exp $" #ifdef CHAPMS @@ -164,9 +164,11 @@ static void chapms_generate_challenge(unsigned char *challenge) { *challenge++ = 8; +#ifdef DEBUGMPPEKEY if (mschap_challenge && strlen(mschap_challenge) == 8) memcpy(challenge, mschap_challenge, 8); else +#endif random_bytes(challenge, 8); } @@ -174,9 +176,11 @@ static void chapms2_generate_challenge(unsigned char *challenge) { *challenge++ = 16; +#ifdef DEBUGMPPEKEY if (mschap_challenge && strlen(mschap_challenge) == 16) memcpy(challenge, mschap_challenge, 16); else +#endif random_bytes(challenge, 16); } @@ -207,7 +211,7 @@ chapms_verify_response(int id, char *name, #endif /* Generate the expected response. */ - ChapMS(challenge, secret, secret_len, &md); + ChapMS(challenge, (char *)secret, secret_len, &md); #ifdef MSLANMAN /* Determine which part of response to verify against */ @@ -250,8 +254,8 @@ chapms2_verify_response(int id, char *name, /* Generate the expected response and our mutual auth. */ ChapMS2(challenge, rmd->PeerChallenge, name, - secret, secret_len, &md, - saresponse, MS_CHAP2_AUTHENTICATOR); + (char *)secret, secret_len, &md, + (unsigned char *)saresponse, MS_CHAP2_AUTHENTICATOR); /* compare MDs and send the appropriate status */ /* @@ -326,8 +330,13 @@ chapms2_make_response(unsigned char *response, int id, char *our_name, { challenge++; /* skip length, should be 16 */ *response++ = MS_CHAP2_RESPONSE_LEN; - ChapMS2(challenge, mschap2_peer_challenge, our_name, - secret, secret_len, + ChapMS2(challenge, +#ifdef DEBUGMPPEKEY + mschap2_peer_challenge, +#else + NULL, +#endif + our_name, secret, secret_len, (MS_Chap2Response *) response, private, MS_CHAP2_AUTHENTICATEE); } @@ -335,7 +344,8 @@ chapms2_make_response(unsigned char *response, int id, char *our_name, static int chapms2_check_success(unsigned char *msg, int len, unsigned char *private) { - if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || strncmp(msg, "S=", 2)) { + if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || + strncmp((char *)msg, "S=", 2) != 0) { /* Packet does not start with "S=" */ error("MS-CHAPv2 Success packet is badly formed."); return 0; @@ -351,7 +361,7 @@ chapms2_check_success(unsigned char *msg, int len, unsigned char *private) /* Authenticator Response matches. */ msg += MS_AUTH_RESPONSE_LENGTH; /* Eat it */ len -= MS_AUTH_RESPONSE_LENGTH; - if ((len >= 3) && !strncmp(msg, " M=", 3)) { + if ((len >= 3) && !strncmp((char *)msg, " M=", 3)) { msg += 3; /* Eat the delimiter */ } else if (len) { /* Packet has extra text which does not begin " M=" */ @@ -477,7 +487,7 @@ ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge, SHA1_Init(&sha1Context); SHA1_Update(&sha1Context, PeerChallenge, 16); SHA1_Update(&sha1Context, rchallenge, 16); - SHA1_Update(&sha1Context, user, strlen(user)); + SHA1_Update(&sha1Context, (unsigned char *)user, strlen(user)); SHA1_Final(sha1Hash, &sha1Context); BCOPY(sha1Hash, Challenge, 8); @@ -512,7 +522,7 @@ NTPasswordHash(char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE]) MD4_CTX md4Context; MD4Init(&md4Context); - MD4Update(&md4Context, secret, mdlen); + MD4Update(&md4Context, (unsigned char *)secret, mdlen); MD4Final(hash, &md4Context); } @@ -526,7 +536,7 @@ ChapMS_NT(u_char *rchallenge, char *secret, int secret_len, /* Hash the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); - NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash); + NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash); ChallengeResponse(rchallenge, PasswordHash, NTResponse); } @@ -539,11 +549,12 @@ ChapMS2_NT(char *rchallenge, u_char PeerChallenge[16], char *username, u_char PasswordHash[MD4_SIGNATURE_SIZE]; u_char Challenge[8]; - ChallengeHash(PeerChallenge, rchallenge, username, Challenge); + ChallengeHash(PeerChallenge, (unsigned char *)rchallenge, username, + Challenge); /* Hash the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); - NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash); + NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash); ChallengeResponse(Challenge, PasswordHash, NTResponse); } @@ -603,8 +614,9 @@ GenerateAuthenticatorResponse(char *secret, int secret_len, /* Hash (x2) the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); - NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash); - NTPasswordHash(PasswordHash, sizeof(PasswordHash), PasswordHashHash); + NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash); + NTPasswordHash((char *)PasswordHash, sizeof(PasswordHash), + PasswordHashHash); SHA1_Init(&sha1Context); SHA1_Update(&sha1Context, PasswordHashHash, sizeof(PasswordHashHash)); @@ -622,7 +634,7 @@ GenerateAuthenticatorResponse(char *secret, int secret_len, /* Convert to ASCII hex string. */ for (i = 0; i < MAX((MS_AUTH_RESPONSE_LENGTH / 2), sizeof(Digest)); i++) - sprintf(&authResponse[i * 2], "%02X", Digest[i]); + sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]); } @@ -825,7 +837,7 @@ ChapMS2(u_char *rchallenge, u_char *PeerChallenge, sizeof(response->PeerChallenge)); /* Generate the NT-Response */ - ChapMS2_NT(rchallenge, response->PeerChallenge, user, + ChapMS2_NT((char *)rchallenge, response->PeerChallenge, user, secret, secret_len, response->NTResp); /* Generate the Authenticator Response. */ diff --git a/solaris/Makefile.sol2gcc b/solaris/Makefile.sol2gcc index 04a24c5..59f1869 100644 --- a/solaris/Makefile.sol2gcc +++ b/solaris/Makefile.sol2gcc @@ -1,11 +1,13 @@ # # Makefile for STREAMS modules for Solaris 2. # -# $Id: Makefile.sol2gcc,v 1.2 2003/03/31 12:07:28 carlsonj Exp $ +# $Id: Makefile.sol2gcc,v 1.3 2004/04/14 02:39:39 carlsonj Exp $ # include Makedefs.sol2 +COPTS += -fno-builtin + COMP_OBJS = ppp_comp.o bsd-comp.o deflate.o zlib.o vjcompress.o \ ppp_comp_mod.o -- 2.39.2