feat(handoff): add basic firmware handoff tests

Add tests to sanity check information shared between BL31 and NS world
using the firmware handoff framework.

Change-Id: I9d00292db7732157d0815e6159438c0db08551ad
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
diff --git a/lib/transfer_list/transfer_list.c b/lib/transfer_list/transfer_list.c
new file mode 100644
index 0000000..c83b0b3
--- /dev/null
+++ b/lib/transfer_list/transfer_list.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+
+#include <transfer_list.h>
+
+struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
+					       uint16_t tag_id)
+{
+	struct transfer_list_entry *te = (void *)tl + tl->hdr_size;
+
+	while (te->tag_id != tag_id) {
+		te += round_up(te->hdr_size + te->data_size, tl->alignment);
+	}
+
+	return te;
+}
+
+void *transfer_list_entry_data(struct transfer_list_entry *entry)
+{
+	return (uint8_t *)entry + entry->hdr_size;
+}
+
+/*******************************************************************************
+ * Verifying the header of a transfer list
+ * Compliant to 2.4.1 of Firmware handoff specification (v0.9)
+ * Return transfer list operation status code
+ ******************************************************************************/
+enum transfer_list_ops
+transfer_list_check_header(const struct transfer_list_header *tl)
+{
+	uint8_t byte_sum = 0U;
+	uint8_t *b = (uint8_t *)tl;
+
+	if (tl == NULL) {
+		return TL_OPS_NON;
+	}
+
+	if (tl->signature != TRANSFER_LIST_SIGNATURE ||
+	    tl->size > tl->max_size) {
+		return TL_OPS_NON;
+	}
+
+	for (size_t i = 0; i < tl->size; i++) {
+		byte_sum += b[i];
+	}
+
+	if (byte_sum - tl->checksum == tl->checksum) {
+		return TL_OPS_NON;
+	}
+
+	return TL_OPS_ALL;
+}