|
|
|
@ -52,7 +52,7 @@ documentation and/or software.
|
|
|
|
|
#define S43 15
|
|
|
|
|
#define S44 21
|
|
|
|
|
|
|
|
|
|
static void MD5Transform (UINT4 [4], const unsigned char [64]);
|
|
|
|
|
static void li_MD5Transform (UINT4 [4], const unsigned char [64]);
|
|
|
|
|
static void Encode (unsigned char *, UINT4 *, unsigned int);
|
|
|
|
|
static void Decode (UINT4 *, const unsigned char *, unsigned int);
|
|
|
|
|
|
|
|
|
@ -110,8 +110,8 @@ Rotation is separate from addition to prevent recomputation.
|
|
|
|
|
|
|
|
|
|
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
|
|
|
|
*/
|
|
|
|
|
void MD5_Init (context)
|
|
|
|
|
MD5_CTX *context; /* context */
|
|
|
|
|
void li_MD5_Init (context)
|
|
|
|
|
li_MD5_CTX *context; /* context */
|
|
|
|
|
{
|
|
|
|
|
context->count[0] = context->count[1] = 0;
|
|
|
|
|
/* Load magic initialization constants.
|
|
|
|
@ -126,8 +126,8 @@ MD5_CTX *context; /* context */
|
|
|
|
|
operation, processing another message block, and updating the
|
|
|
|
|
context.
|
|
|
|
|
*/
|
|
|
|
|
void MD5_Update (context, _input, inputLen)
|
|
|
|
|
MD5_CTX *context; /* context */
|
|
|
|
|
void li_MD5_Update (context, _input, inputLen)
|
|
|
|
|
li_MD5_CTX *context; /* context */
|
|
|
|
|
const void *_input; /* input block */
|
|
|
|
|
unsigned int inputLen; /* length of input block */
|
|
|
|
|
{
|
|
|
|
@ -151,10 +151,10 @@ unsigned int inputLen; /* length of input block */
|
|
|
|
|
if (inputLen >= partLen) {
|
|
|
|
|
MD5_memcpy
|
|
|
|
|
((POINTER)&context->buffer[ndx], (POINTER)input, partLen);
|
|
|
|
|
MD5Transform (context->state, context->buffer);
|
|
|
|
|
li_MD5Transform (context->state, context->buffer);
|
|
|
|
|
|
|
|
|
|
for (i = partLen; i + 63 < inputLen; i += 64)
|
|
|
|
|
MD5Transform (context->state, &input[i]);
|
|
|
|
|
li_MD5Transform (context->state, &input[i]);
|
|
|
|
|
|
|
|
|
|
ndx = 0;
|
|
|
|
|
}
|
|
|
|
@ -170,9 +170,9 @@ unsigned int inputLen; /* length of input block */
|
|
|
|
|
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
|
|
|
|
the message digest and zeroizing the context.
|
|
|
|
|
*/
|
|
|
|
|
void MD5_Final (digest, context)
|
|
|
|
|
void li_MD5_Final (digest, context)
|
|
|
|
|
unsigned char digest[16]; /* message digest */
|
|
|
|
|
MD5_CTX *context; /* context */
|
|
|
|
|
li_MD5_CTX *context; /* context */
|
|
|
|
|
{
|
|
|
|
|
unsigned char bits[8];
|
|
|
|
|
unsigned int ndx, padLen;
|
|
|
|
@ -184,10 +184,10 @@ MD5_CTX *context; /* context */
|
|
|
|
|
*/
|
|
|
|
|
ndx = (unsigned int)((context->count[0] >> 3) & 0x3f);
|
|
|
|
|
padLen = (ndx < 56) ? (56 - ndx) : (120 - ndx);
|
|
|
|
|
MD5_Update (context, PADDING, padLen);
|
|
|
|
|
li_MD5_Update (context, PADDING, padLen);
|
|
|
|
|
|
|
|
|
|
/* Append length (before padding) */
|
|
|
|
|
MD5_Update (context, bits, 8);
|
|
|
|
|
li_MD5_Update (context, bits, 8);
|
|
|
|
|
|
|
|
|
|
/* Store state in digest */
|
|
|
|
|
Encode (digest, context->state, 16);
|
|
|
|
@ -199,7 +199,7 @@ MD5_CTX *context; /* context */
|
|
|
|
|
|
|
|
|
|
/* MD5 basic transformation. Transforms state based on block.
|
|
|
|
|
*/
|
|
|
|
|
static void MD5Transform (state, block)
|
|
|
|
|
static void li_MD5Transform (state, block)
|
|
|
|
|
UINT4 state[4];
|
|
|
|
|
const unsigned char block[64];
|
|
|
|
|
{
|
|
|
|
|