示例#1
0
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.*/
VOID MD5_Update (MD5_CTX * context, BYTE * input, UINT inputLen)
{
	UINT i, index, partLen;

	// Compute number of bytes (that we already had) mod 64
	index = (UINT)((context->count[0] >> 3) & 0x3F);

	// Update number of bits
	if ((context->count[0] += ((DWORD)inputLen << 3))   < ((DWORD)inputLen << 3))
		context->count[1]++;
	context->count[1] += ((DWORD)inputLen >> 29);

	// partLen is the number of bytes we need to fill the buffer. It is possible that
	// there are bytes left to process
	partLen = 64 - index;

	// Transform as many times as possible
	if (inputLen >= partLen) {
		MD5_memcpy((BYTE *)&context->buffer[index], (BYTE *)input, partLen);
		MD5_Transform (context->state, context->buffer);

		for (i = partLen; i + 63 < inputLen; i += 64)
			MD5_Transform (context->state, &input[i]);

		index = 0;
	}
	else
		i = 0;

	// Buffer remaining input that we could not process
	MD5_memcpy((BYTE *)&context->buffer[index], (BYTE *)&input[i], inputLen-i);
}
示例#2
0
/* MD5 block update operation. Continues an MD5 message-digest
   operation, processing another message block, and updating the
   context.
   */
static kvoid MD5Update (MD5_CTX *context, const kuchar *input, kuint inputLen)
{
    kuint i, index, partLen;

    /* Compute number of bytes mod 64 */
    index = (kuint)((context->count[0] >> 3) & 0x3F);

    /* Update number of bits */
    if ((context->count[0] += ((UINT4)inputLen << 3))
            < ((UINT4)inputLen << 3))
        context->count[1]++;
    context->count[1] += ((UINT4)inputLen >> 29);

    partLen = 64 - index;

    /* Transform as many times as possible.
    */
    if (inputLen >= partLen) {
        MD5_memcpy
            ((POINTER)&context->buffer[index], (POINTER)input, partLen);
        MD5Transform (context->state, context->buffer);

        for (i = partLen; i + 63 < inputLen; i += 64)
            MD5Transform (context->state, &input[i]);

        index = 0;
    }
    else
        i = 0;

    /* Buffer remaining input */
    MD5_memcpy
        ((POINTER)&context->buffer[index], (POINTER)&input[i],
         inputLen-i);
}
示例#3
0
//更新函数
void CMD5::MD5Update (unsigned char * input, unsigned int inputLen)
{
	unsigned int i,index,partLen;
	index=(unsigned int)((this->count[0]>>3)&0x3F);
	if ((count[0]+=((unsigned long int)inputLen<<3))<((unsigned long int)inputLen<<3)) count[1]++;
	count[1]+=((unsigned long int)inputLen>>29);
	partLen=64-index;
	if (inputLen>=partLen) 
	{
		MD5_memcpy((unsigned char*)&buffer[index],(unsigned char *)input,partLen);
		MD5Transform(state,buffer);
		for (i=partLen;i+63<inputLen;i+=64) MD5Transform(state,&input[i]);
		index=0;
	}
	else i=0;
	MD5_memcpy((unsigned char*)&buffer[index],(unsigned char *)&input[i],inputLen-i);
	return;
}
示例#4
0
文件: md5.cpp 项目: Rhobota/librho
/* MD5 block update operation. Continues an MD5 message-digest
  operation, processing another message block, and updating the
  context.
 */
void MD5Update (MD5_CTX *context, const rho::u8 *input, rho::u32 inputLen)
//context;                              /* context */
//input;                                /* input block */
//inputLen;                             /* length of input block */
{
    rho::u32 i, index, partLen;

  /* Compute number of bytes mod 64 */
  index = (rho::u32)((context->count[0] >> 3) & 0x3F);

  /* Update number of bits */
  if ((context->count[0] += ((UINT4)inputLen << 3))
   < ((UINT4)inputLen << 3))
 context->count[1]++;
  context->count[1] += ((UINT4)inputLen >> 29);

  partLen = 64 - index;

  /* Transform as many times as possible.
*/
  if (inputLen >= partLen) {
 MD5_memcpy
   ((POINTER)&context->buffer[index], input, partLen);
 MD5Transform (context->state, context->buffer);

 for (i = partLen; i + 63 < inputLen; i += 64)
   MD5Transform (context->state, &input[i]);

 index = 0;
  }
  else
 i = 0;

  /* Buffer remaining input */
  MD5_memcpy
 ((POINTER)&context->buffer[index], &input[i],
  inputLen-i);
}