summaryrefslogtreecommitdiffstats
path: root/cpukit/pppd/chap_ms.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-08-16 20:42:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-08-16 20:42:09 +0000
commit2f1b9304ac4ba89a2dcb6047cb584a5603a33987 (patch)
treef2339e3f2230b73ee4818d55d4154795e712d803 /cpukit/pppd/chap_ms.c
parent2001-08-16 Mike Siers <mikes@poliac.com> (diff)
downloadrtems-2f1b9304ac4ba89a2dcb6047cb584a5603a33987.tar.bz2
2001-08-16 Mike Siers <mikes@poliac.com>
* Update of PPPD to 2.3.11 from 2.3.5 and addition of an example application. Mike's notes on the modifications: - renamed error() function because of namespace problems - removed calls to the exit() funciton - removed extra files from the pppd source directory - defined pppd task constant values in rtemspppd.h - modifyied example code to get actual tick per second value - placed the pppd 2.3.11 man page file (pppd.8) into the pppd directory * pppd/cbcp.c, pppd/cbcp.h, pppd/main.c, pppd/ppp_tty.c, pppd/pppmain.c, pppd/rtems-ppp.c, pppd/rtems-ppp.c: Deleted. * pppd/pppd.8, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/utils.c, pppd/example/Makefile, pppd/example/README, pppd/example/init.c, pppd/example/netconfig.h, pppd/example/ppp.conf, pppd/example/pppdapp.c, pppd/example/system.h: New files. * modem/ppp_tty.c, net/if_ppp.h, pppd/Makefile.am, pppd/README, pppd/STATUS, pppd/auth.c, pppd/ccp.c, pppd/ccp.h, pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c, pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h, pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h, pppd/pathnames.h, pppd/pppd.h, pppd/upap.c, pppd/upap.h: Modified.
Diffstat (limited to 'cpukit/pppd/chap_ms.c')
-rw-r--r--cpukit/pppd/chap_ms.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/cpukit/pppd/chap_ms.c b/cpukit/pppd/chap_ms.c
index 2de98dbb66..81a57bb5aa 100644
--- a/cpukit/pppd/chap_ms.c
+++ b/cpukit/pppd/chap_ms.c
@@ -31,18 +31,16 @@
* You should also use DOMAIN\\USERNAME as described in README.MSCHAP80
*/
-#ifndef lint
-/* static char rcsid[] = "$Id$"; */
-#endif
+#define RCSID "$Id$"
#ifdef CHAPMS
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <syslog.h>
#include <unistd.h>
#ifdef HAVE_CRYPT_H
#include <crypt.h>
@@ -57,6 +55,8 @@
#include <des.h>
#endif
+static const char rcsid[] = RCSID;
+
typedef struct {
u_char LANManResp[24];
u_char NTResp[24];
@@ -80,6 +80,11 @@ static void Expand __P((u_char *, u_char *));
static void Collapse __P((u_char *, u_char *));
#endif
+#ifdef MSLANMAN
+bool ms_lanman = 0; /* Use LanMan password instead of NT */
+ /* Has meaning only with MS-CHAP challenges */
+#endif
+
static void
ChallengeResponse(challenge, pwHash, response)
u_char *challenge; /* IN 8 octets */
@@ -92,7 +97,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);
@@ -100,7 +106,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
}
@@ -122,8 +128,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);
@@ -131,8 +136,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
}
@@ -152,15 +156,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
}
@@ -239,10 +241,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
}
@@ -255,6 +255,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];
@@ -266,7 +272,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 * 8); /* Unicode is 2 bytes/char, *8 for bit count */
+ MD4Update(&md4Context, unicodePassword, mdlen);
MD4Final(hash, &md4Context); /* Tell MD4 we're done */
@@ -307,9 +313,6 @@ ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len)
int secret_len;
{
MS_ChapResponse response;
-#ifdef MSLANMAN
- extern int ms_lanman;
-#endif
#if 0
CHAPDEBUG((LOG_INFO, "ChapMS: secret is '%.*s'", secret_len, secret));