utils: Add API for CRC validation

- Added the validation functions for `pldm_edac_crc32_validate`.

Motivation:
Checksum validation is a hazard for fuzzing. Provide an API that
allows us to adjust the implementation of the test depending on
whether we are building to fuzz the library implementation.

Change-Id: Iffd245fe5cbcadb1037cd1f5065ccc1da6502562
Signed-off-by: Carter Chen <carter.chen.wiwynn@gmail.com>
diff --git a/src/utils.c b/src/utils.c
index ca0b848..53ed4f7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
 #include <libpldm/base.h>
 #include <libpldm/utils.h>
+#include "utils.h"
 
 #include <limits.h>
 #include <stdio.h>
@@ -96,6 +97,15 @@
 	return crc ^ ~0U;
 }
 
+int pldm_edac_crc32_validate(uint32_t expected, const void *data, size_t size)
+{
+	if (!data && size) { /* data is NULL but size is not zero */
+		return -EINVAL;
+	}
+	uint32_t actual = pldm_edac_crc32(data, size);
+	return (expected == actual) ? 0 : -EUCLEAN;
+}
+
 LIBPLDM_ABI_STABLE
 uint8_t pldm_edac_crc8(const void *data, size_t size)
 {