Example #1
0
static BOOL test_crypto_hash_md4(void)
{
	BYTE hash[WINPR_MD4_DIGEST_LENGTH];
	WINPR_MD4_CTX ctx;

	if (!winpr_MD4_Init(&ctx))
		return FALSE;
	if (!winpr_MD4_Update(&ctx, (BYTE*) TEST_MD4_DATA, strlen(TEST_MD4_DATA)))
		return FALSE;
	if (!winpr_MD4_Final(&ctx, hash, sizeof(hash)))
		return FALSE;

	if (memcmp(hash, TEST_MD4_HASH, WINPR_MD4_DIGEST_LENGTH) != 0)
	{
		char* actual;
		char* expected;

		actual = winpr_BinToHexString(hash, WINPR_MD4_DIGEST_LENGTH, FALSE);
		expected = winpr_BinToHexString(TEST_MD4_HASH, WINPR_MD4_DIGEST_LENGTH, FALSE);

		fprintf(stderr, "unexpected MD4 hash: Actual: %s Expected: %s\n", actual, expected);

		free(actual);
		free(expected);

		return FALSE;
	}

	return TRUE;
}
Example #2
0
void winpr_MD4(const BYTE* input, size_t ilen, BYTE* output)
{
	WINPR_MD4_CTX ctx;
	winpr_MD4_Init(&ctx);
	winpr_MD4_Update(&ctx, input, ilen);
	winpr_MD4_Final(&ctx, output);
}