From a72e4a406f12b22e93bad19ec24c86c93bfd7049 Mon Sep 17 00:00:00 2001 From: fbernon Date: Sun, 2 Dec 2007 23:58:11 +0000 Subject: [PATCH] Minor changes: coding style (tabs, ident, etc...). --- src/netif/ppp/md5.c | 40 +++++++++++++++++++++++----------------- src/netif/ppp/md5.h | 14 +++++++------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/netif/ppp/md5.c b/src/netif/ppp/md5.c index c582faf9..d65ecedb 100644 --- a/src/netif/ppp/md5.c +++ b/src/netif/ppp/md5.c @@ -100,24 +100,24 @@ static unsigned char PADDING[64] = { } #ifdef __STDC__ -#define UL(x) x##UL +#define UL(x) x##UL #else #ifdef WIN32 -#define UL(x) x##UL +#define UL(x) x##UL #else -#define UL(x) x +#define UL(x) x #endif #endif /* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void MD5Init (MD5_CTX *mdContext) +void +MD5Init (MD5_CTX *mdContext) { mdContext->i[0] = mdContext->i[1] = (u32_t)0; - /* Load magic initialization constants. - */ + /* Load magic initialization constants. */ mdContext->buf[0] = (u32_t)0x67452301UL; mdContext->buf[1] = (u32_t)0xefcdab89UL; mdContext->buf[2] = (u32_t)0x98badcfeUL; @@ -128,7 +128,8 @@ void MD5Init (MD5_CTX *mdContext) account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ -void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) +void +MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) { u32_t in[16]; int mdi; @@ -143,8 +144,9 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) mdi = (int)((mdContext->i[0] >> 3) & 0x3F); /* update number of bits */ - if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) + if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) { mdContext->i[1]++; + } mdContext->i[0] += ((u32_t)inLen << 3); mdContext->i[1] += ((u32_t)inLen >> 29); @@ -154,11 +156,12 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) /* transform if necessary */ if (mdi == 0x40) { - for (i = 0, ii = 0; i < 16; i++, ii += 4) + for (i = 0, ii = 0; i < 16; i++, ii += 4) { in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | (((u32_t)mdContext->in[ii+2]) << 16) | - (((u32_t)mdContext->in[ii+1]) << 8) | + (((u32_t)mdContext->in[ii+1]) << 8) | ((u32_t)mdContext->in[ii]); + } Transform (mdContext->buf, in); mdi = 0; } @@ -168,7 +171,8 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) /* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ -void MD5Final (unsigned char hash[], MD5_CTX *mdContext) +void +MD5Final (unsigned char hash[], MD5_CTX *mdContext) { u32_t in[16]; int mdi; @@ -187,18 +191,19 @@ void MD5Final (unsigned char hash[], MD5_CTX *mdContext) MD5Update (mdContext, PADDING, padLen); /* append length in bits and transform */ - for (i = 0, ii = 0; i < 14; i++, ii += 4) + for (i = 0, ii = 0; i < 14; i++, ii += 4) { in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | (((u32_t)mdContext->in[ii+2]) << 16) | - (((u32_t)mdContext->in[ii+1]) << 8) | + (((u32_t)mdContext->in[ii+1]) << 8) | ((u32_t)mdContext->in[ii]); + } Transform (mdContext->buf, in); /* store buffer in digest */ for (i = 0, ii = 0; i < 4; i++, ii += 4) { - mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); - mdContext->digest[ii+1] = - (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); + mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); + mdContext->digest[ii+1] = + (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); mdContext->digest[ii+2] = (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); mdContext->digest[ii+3] = @@ -209,7 +214,8 @@ void MD5Final (unsigned char hash[], MD5_CTX *mdContext) /* Basic MD5 step. Transforms buf based on in. */ -static void Transform (u32_t *buf, u32_t *in) +static void +Transform (u32_t *buf, u32_t *in) { u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; diff --git a/src/netif/ppp/md5.h b/src/netif/ppp/md5.h index 0e81cdc3..e129533f 100644 --- a/src/netif/ppp/md5.h +++ b/src/netif/ppp/md5.h @@ -42,14 +42,14 @@ /* Data structure for MD5 (Message-Digest) computation */ typedef struct { - u32_t i[2]; /* number of _bits_ handled mod 2^64 */ - u32_t buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after MD5Final call */ + u32_t i[2]; /* number of _bits_ handled mod 2^64 */ + u32_t buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ } MD5_CTX; -void MD5Init (MD5_CTX *mdContext); -void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); -void MD5Final (unsigned char hash[], MD5_CTX *mdContext); +void MD5Init ( MD5_CTX *mdContext); +void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); +void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); #endif /* MD5_H */