Example #1
0
/* MD2 block update operation. Continues an MD2 message-digest
     operation, processing another message block, and updating the
     context.
 */
void
MD2Update (MD2_CTX *context, const void *in, unsigned int inputLen)
{
  unsigned int i, idx, partLen;
  const unsigned char *input = in;

  /* Update number of bytes mod 16 */
  idx = context->count;
  context->count = (idx + inputLen) & 0xf;

  partLen = 16 - idx;

  /* Transform as many times as possible.
    */
  if (inputLen >= partLen) {
    memcpy
      ((POINTER)&context->buffer[idx], (POINTER)input, partLen);
    MD2Transform (context->state, context->checksum, context->buffer);

    for (i = partLen; i + 15 < inputLen; i += 16)
      MD2Transform (context->state, context->checksum, &input[i]);

    idx = 0;
  }
  else
    i = 0;

  /* Buffer remaining input */
  memcpy
    ((POINTER)&context->buffer[idx], (POINTER)&input[i],
     inputLen-i);
}
Example #2
0
/* MD2 block update operation. Continues an MD2 message-digest
operation, processing another message block, and updating the
context.
*/
void MD2Update (MD2_CTX *context,                                        /* context */
				unsigned char *input,                                /* input block */
				unsigned int inputLen)                     /* length of input block */
{
	unsigned int i, index, partLen;

	/* Update number of bytes mod 16 */
	index = context->count;
	context->count = (index + inputLen) & 0xf;

	partLen = 16 - index;

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

		for (i = partLen; i + 15 < inputLen; i += 16)
			MD2Transform (context->state, context->checksum, &input[i]);

		index = 0;
	}
	else
		i = 0;

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