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

This commit is contained in:
fbernon 2007-12-02 23:58:11 +00:00
parent 2fe1254aae
commit a72e4a406f
2 changed files with 30 additions and 24 deletions

View File

@ -112,12 +112,12 @@ static unsigned char PADDING[64] = {
/* 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,11 +191,12 @@ 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 */
@ -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];