Minor changes: coding style (tabs, ident, etc...).

This commit is contained in:
fbernon 2007-12-02 22:56:19 +00:00
parent 37a5a87057
commit 6bce832060
3 changed files with 241 additions and 247 deletions

View File

@ -62,7 +62,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Id: chap.h,v 1.2 2007/11/29 22:19:57 fbernon Exp $ * $Id: chap.h,v 1.3 2007/12/02 22:56:19 fbernon Exp $
*/ */
#ifndef CHAP_H #ifndef CHAP_H

View File

@ -138,13 +138,8 @@ static u_char Get7Bits(
/***********************************/ /***********************************/
/*** PUBLIC FUNCTION DEFINITIONS ***/ /*** PUBLIC FUNCTION DEFINITIONS ***/
/***********************************/ /***********************************/
void ChapMS( void
chap_state *cstate, ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len)
char *rchallenge,
int rchallenge_len,
char *secret,
int secret_len
)
{ {
MS_ChapResponse response; MS_ChapResponse response;
#ifdef MSLANMAN #ifdef MSLANMAN
@ -176,11 +171,10 @@ void ChapMS(
/**********************************/ /**********************************/
/*** LOCAL FUNCTION DEFINITIONS ***/ /*** LOCAL FUNCTION DEFINITIONS ***/
/**********************************/ /**********************************/
static void ChallengeResponse( static void
u_char *challenge, /* IN 8 octets */ ChallengeResponse( u_char *challenge, /* IN 8 octets */
u_char *pwHash, /* IN 16 octets */ u_char *pwHash, /* IN 16 octets */
u_char *response /* OUT 24 octets */ u_char *response /* OUT 24 octets */)
)
{ {
char ZPasswordHash[21]; char ZPasswordHash[21];
@ -202,11 +196,10 @@ static void ChallengeResponse(
#ifdef USE_CRYPT #ifdef USE_CRYPT
static void DesEncrypt( static void
u_char *clear, /* IN 8 octets */ DesEncrypt( u_char *clear, /* IN 8 octets */
u_char *key, /* IN 7 octets */ u_char *key, /* IN 7 octets */
u_char *cipher /* OUT 8 octets */ u_char *cipher /* OUT 8 octets */)
)
{ {
u_char des_key[8]; u_char des_key[8];
u_char crypt_key[66]; u_char crypt_key[66];
@ -234,11 +227,10 @@ static void DesEncrypt(
#else /* USE_CRYPT */ #else /* USE_CRYPT */
static void DesEncrypt( static void
u_char *clear, /* IN 8 octets */ DesEncrypt( u_char *clear, /* IN 8 octets */
u_char *key, /* IN 7 octets */ u_char *key, /* IN 7 octets */
u_char *cipher /* OUT 8 octets */ u_char *cipher /* OUT 8 octets */)
)
{ {
des_cblock des_key; des_cblock des_key;
des_key_schedule key_schedule; des_key_schedule key_schedule;
@ -263,10 +255,8 @@ static void DesEncrypt(
#endif /* USE_CRYPT */ #endif /* USE_CRYPT */
static u_char Get7Bits( static u_char
u_char *input, Get7Bits( u_char *input, int startBit)
int startBit
)
{ {
register unsigned int word; register unsigned int word;
@ -284,22 +274,25 @@ static u_char Get7Bits(
* out == 64-byte string where each byte is either 1 or 0 * out == 64-byte string where each byte is either 1 or 0
* Note that the low-order "bit" is always ignored by by setkey() * Note that the low-order "bit" is always ignored by by setkey()
*/ */
static void Expand(u_char *in, u_char *out) static void
Expand(u_char *in, u_char *out)
{ {
int j, c; int j, c;
int i; int i;
for(i = 0; i < 64; in++){ for(i = 0; i < 64; in++){
c = *in; c = *in;
for(j = 7; j >= 0; j--) for(j = 7; j >= 0; j--) {
*out++ = (c >> j) & 01; *out++ = (c >> j) & 01;
}
i += 8; i += 8;
} }
} }
/* The inverse of Expand /* The inverse of Expand
*/ */
static void Collapse(u_char *in, u_char *out) static void
Collapse(u_char *in, u_char *out)
{ {
int j; int j;
int i; int i;
@ -307,17 +300,17 @@ static void Collapse(u_char *in, u_char *out)
for (i = 0; i < 64; i += 8, out++) { for (i = 0; i < 64; i += 8, out++) {
c = 0; c = 0;
for (j = 7; j >= 0; j--, in++) for (j = 7; j >= 0; j--, in++) {
c |= *in << j; c |= *in << j;
}
*out = c & 0xff; *out = c & 0xff;
} }
} }
#endif #endif
static void MakeKey( static void
u_char *key, /* IN 56 bit DES key missing parity bits */ MakeKey( u_char *key, /* IN 56 bit DES key missing parity bits */
u_char *des_key /* OUT 64 bit DES key with parity bits added */ u_char *des_key /* OUT 64 bit DES key with parity bits added */)
)
{ {
des_key[0] = Get7Bits(key, 0); des_key[0] = Get7Bits(key, 0);
des_key[1] = Get7Bits(key, 7); des_key[1] = Get7Bits(key, 7);
@ -340,13 +333,12 @@ static void MakeKey(
#endif #endif
} }
static void ChapMS_NT( static void
char *rchallenge, ChapMS_NT( char *rchallenge,
int rchallenge_len, int rchallenge_len,
char *secret, char *secret,
int secret_len, int secret_len,
MS_ChapResponse *response MS_ChapResponse *response)
)
{ {
int i; int i;
MDstruct md4Context; MDstruct md4Context;
@ -356,16 +348,18 @@ static void ChapMS_NT(
/* Initialize the Unicode version of the secret (== password). */ /* Initialize the Unicode version of the secret (== password). */
/* This implicitly supports 8-bit ISO8859/1 characters. */ /* This implicitly supports 8-bit ISO8859/1 characters. */
BZERO(unicodePassword, sizeof(unicodePassword)); BZERO(unicodePassword, sizeof(unicodePassword));
for (i = 0; i < secret_len; i++) for (i = 0; i < secret_len; i++) {
unicodePassword[i * 2] = (u_char)secret[i]; unicodePassword[i * 2] = (u_char)secret[i];
}
MDbegin(&md4Context); MDbegin(&md4Context);
MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */
if (low_byte_first == -1) if (low_byte_first == -1) {
low_byte_first = (htons((unsigned short int)1) != 1); low_byte_first = (htons((unsigned short int)1) != 1);
if (low_byte_first == 0) }
if (low_byte_first == 0) {
MDreverse((u_long *)&md4Context); /* sfb 961105 */ MDreverse((u_long *)&md4Context); /* sfb 961105 */
}
MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */ MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */
@ -375,13 +369,12 @@ static void ChapMS_NT(
#ifdef MSLANMAN #ifdef MSLANMAN
static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */
static ChapMS_LANMan( static void
char *rchallenge, ChapMS_LANMan( char *rchallenge,
int rchallenge_len, int rchallenge_len,
char *secret, char *secret,
int secret_len, int secret_len,
MS_ChapResponse *response MS_ChapResponse *response)
)
{ {
int i; int i;
u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */
@ -389,8 +382,9 @@ static ChapMS_LANMan(
/* LANMan password is case insensitive */ /* LANMan password is case insensitive */
BZERO(UcasePassword, sizeof(UcasePassword)); BZERO(UcasePassword, sizeof(UcasePassword));
for (i = 0; i < secret_len; i++) for (i = 0; i < secret_len; i++) {
UcasePassword[i] = (u_char)toupper(secret[i]); UcasePassword[i] = (u_char)toupper(secret[i]);
}
DesEncrypt( StdText, UcasePassword + 0, PasswordHash + 0 ); DesEncrypt( StdText, UcasePassword + 0, PasswordHash + 0 );
DesEncrypt( StdText, UcasePassword + 7, PasswordHash + 8 ); DesEncrypt( StdText, UcasePassword + 7, PasswordHash + 8 );
ChallengeResponse(rchallenge, PasswordHash, response->LANManResp); ChallengeResponse(rchallenge, PasswordHash, response->LANManResp);

View File

@ -51,7 +51,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* *
* $Id: chpms.h,v 1.3 2004/02/07 00:30:03 likewise Exp $ * $Id: chpms.h,v 1.4 2007/12/02 22:56:19 fbernon Exp $
*/ */
#ifndef CHPMS_H #ifndef CHPMS_H