mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
Minor changes: coding style (tabs, ident, etc...).
This commit is contained in:
parent
2fe1254aae
commit
a72e4a406f
@ -100,24 +100,24 @@ static unsigned char PADDING[64] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
#define UL(x) x##UL
|
#define UL(x) x##UL
|
||||||
#else
|
#else
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define UL(x) x##UL
|
#define UL(x) x##UL
|
||||||
#else
|
#else
|
||||||
#define UL(x) x
|
#define UL(x) x
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The routine MD5Init initializes the message-digest context
|
/* The routine MD5Init initializes the message-digest context
|
||||||
mdContext. All fields are set to zero.
|
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;
|
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[0] = (u32_t)0x67452301UL;
|
||||||
mdContext->buf[1] = (u32_t)0xefcdab89UL;
|
mdContext->buf[1] = (u32_t)0xefcdab89UL;
|
||||||
mdContext->buf[2] = (u32_t)0x98badcfeUL;
|
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]
|
account for the presence of each of the characters inBuf[0..inLen-1]
|
||||||
in the message whose digest is being computed.
|
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];
|
u32_t in[16];
|
||||||
int mdi;
|
int mdi;
|
||||||
@ -143,8 +144,9 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
|
|||||||
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
|
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
|
||||||
|
|
||||||
/* update number of bits */
|
/* 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[1]++;
|
||||||
|
}
|
||||||
mdContext->i[0] += ((u32_t)inLen << 3);
|
mdContext->i[0] += ((u32_t)inLen << 3);
|
||||||
mdContext->i[1] += ((u32_t)inLen >> 29);
|
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 */
|
/* transform if necessary */
|
||||||
if (mdi == 0x40) {
|
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) |
|
in[i] = (((u32_t)mdContext->in[ii+3]) << 24) |
|
||||||
(((u32_t)mdContext->in[ii+2]) << 16) |
|
(((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]);
|
((u32_t)mdContext->in[ii]);
|
||||||
|
}
|
||||||
Transform (mdContext->buf, in);
|
Transform (mdContext->buf, in);
|
||||||
mdi = 0;
|
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
|
/* The routine MD5Final terminates the message-digest computation and
|
||||||
ends with the desired message digest in mdContext->digest[0...15].
|
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];
|
u32_t in[16];
|
||||||
int mdi;
|
int mdi;
|
||||||
@ -187,18 +191,19 @@ void MD5Final (unsigned char hash[], MD5_CTX *mdContext)
|
|||||||
MD5Update (mdContext, PADDING, padLen);
|
MD5Update (mdContext, PADDING, padLen);
|
||||||
|
|
||||||
/* append length in bits and transform */
|
/* 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) |
|
in[i] = (((u32_t)mdContext->in[ii+3]) << 24) |
|
||||||
(((u32_t)mdContext->in[ii+2]) << 16) |
|
(((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]);
|
((u32_t)mdContext->in[ii]);
|
||||||
|
}
|
||||||
Transform (mdContext->buf, in);
|
Transform (mdContext->buf, in);
|
||||||
|
|
||||||
/* store buffer in digest */
|
/* store buffer in digest */
|
||||||
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
|
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
|
||||||
mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
|
mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
|
||||||
mdContext->digest[ii+1] =
|
mdContext->digest[ii+1] =
|
||||||
(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
|
(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
|
||||||
mdContext->digest[ii+2] =
|
mdContext->digest[ii+2] =
|
||||||
(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
|
(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
|
||||||
mdContext->digest[ii+3] =
|
mdContext->digest[ii+3] =
|
||||||
@ -209,7 +214,8 @@ void MD5Final (unsigned char hash[], MD5_CTX *mdContext)
|
|||||||
|
|
||||||
/* Basic MD5 step. Transforms buf based on in.
|
/* 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];
|
u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
||||||
|
|
||||||
|
@ -42,14 +42,14 @@
|
|||||||
|
|
||||||
/* Data structure for MD5 (Message-Digest) computation */
|
/* Data structure for MD5 (Message-Digest) computation */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32_t i[2]; /* number of _bits_ handled mod 2^64 */
|
u32_t i[2]; /* number of _bits_ handled mod 2^64 */
|
||||||
u32_t buf[4]; /* scratch buffer */
|
u32_t buf[4]; /* scratch buffer */
|
||||||
unsigned char in[64]; /* input buffer */
|
unsigned char in[64]; /* input buffer */
|
||||||
unsigned char digest[16]; /* actual digest after MD5Final call */
|
unsigned char digest[16]; /* actual digest after MD5Final call */
|
||||||
} MD5_CTX;
|
} MD5_CTX;
|
||||||
|
|
||||||
void MD5Init (MD5_CTX *mdContext);
|
void MD5Init ( MD5_CTX *mdContext);
|
||||||
void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
|
void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
|
||||||
void MD5Final (unsigned char hash[], MD5_CTX *mdContext);
|
void MD5Final ( unsigned char hash[], MD5_CTX *mdContext);
|
||||||
|
|
||||||
#endif /* MD5_H */
|
#endif /* MD5_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user