/* 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); }
static int partial_hash_md5(uint8_t *data_in, uint8_t *data_out) { MD5_CTX ctx; if (!MD5_Init(&ctx)) return -EFAULT; MD5_Transform(&ctx, data_in); rte_memcpy(data_out, &ctx, MD5_DIGEST_LENGTH); return 0; }