Attest: Remove LEGACY_TFM_TLV_HEADER support

The boot record is shared between bootloader and
runtime firmware in the structure of TLV data.
The header of the TLV fields are filled differently
by original MCUboot and its TF-M fork. The config
option LEGACY_TFM_TLV_HEADER was meant to make the
distinction. Since the forked version of MCUboot is
going to be removed therefore this differentiation
could also be deleted.

Signed-off-by: Balint Matyi <Balint.Matyi@arm.com>
Change-Id: Ie3904996eb0f1006eaa67c324dfbbb21a9e146ab
diff --git a/secure_fw/partitions/initial_attestation/CMakeLists.txt b/secure_fw/partitions/initial_attestation/CMakeLists.txt
index 509b3a9..2c8fde9 100644
--- a/secure_fw/partitions/initial_attestation/CMakeLists.txt
+++ b/secure_fw/partitions/initial_attestation/CMakeLists.txt
@@ -41,7 +41,6 @@
 
 target_compile_definitions(tfm_partition_attestation
     PRIVATE
-        $<$<BOOL:${TFM_INTERNAL_MCUBOOT}>:LEGACY_TFM_TLV_HEADER>
         $<$<CONFIG:Debug>:INCLUDE_TEST_CODE>
         $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION>
         $<$<BOOL:${ATTEST_INCLUDE_OPTIONAL_CLAIMS}>:INCLUDE_OPTIONAL_CLAIMS>
diff --git a/secure_fw/partitions/initial_attestation/attest_core.c b/secure_fw/partitions/initial_attestation/attest_core.c
index f19afe9..9cdbd70 100644
--- a/secure_fw/partitions/initial_attestation/attest_core.c
+++ b/secure_fw/partitions/initial_attestation/attest_core.c
@@ -209,12 +209,9 @@
     } else {
         /* Any subsequent call set to the next TLV entry */
         (void)tfm_memcpy(&tlv_entry, *tlv_ptr, SHARED_DATA_ENTRY_HEADER_SIZE);
-#ifdef LEGACY_TFM_TLV_HEADER
-        tlv_curr  = (*tlv_ptr) + tlv_entry.tlv_len;
-#else
+
         tlv_curr  = (*tlv_ptr) + SHARED_DATA_ENTRY_HEADER_SIZE
                     + tlv_entry.tlv_len;
-#endif
     }
 
     /* Iterates over the TLV section and returns the address and size of TLVs
@@ -229,11 +226,8 @@
             *tlv_len = tlv_entry.tlv_len;
             return 1;
         }
-#ifdef LEGACY_TFM_TLV_HEADER
-        tlv_curr += tlv_entry.tlv_len;
-#else
+
         tlv_curr += (SHARED_DATA_ENTRY_HEADER_SIZE + tlv_entry.tlv_len);
-#endif
     }
 
     return 0;
@@ -303,21 +297,7 @@
 
     cbor_encode_ctx = attest_token_encode_borrow_cbor_cntxt(token_ctx);
 
-    /* Starting from module 1, because module 0 contains general claims which
-     * are not related to SW module(i.e: boot_seed, etc.)
-     */
-    /* TODO: When TF-M's MCUboot fork is used as the bootloader
-     *       (LEGACY_TFM_TLV_HEADER is defined) it uses different SW module
-     *       identifiers in the shared data entry headers than the upstream
-     *       MCUboot. This is a workaround to be able to get all the claims
-     *       of every SW components, until this discrepancy is handled properly.
-     */
-#ifdef LEGACY_TFM_TLV_HEADER
-    module = 1;
-#else
-    module = 0;
-#endif
-    for ( ; module < SW_MAX; ++module) {
+    for (module = 0; module < SW_MAX; ++module) {
         /* Indicates to restart the look up from the beginning of the shared
          * data section
          */
@@ -340,9 +320,6 @@
 
             encoded.ptr = tlv_ptr + SHARED_DATA_ENTRY_HEADER_SIZE;
             encoded.len = tlv_len;
-#ifdef LEGACY_TFM_TLV_HEADER
-            encoded.len -= SHARED_DATA_ENTRY_HEADER_SIZE;
-#endif
             QCBOREncode_AddEncoded(cbor_encode_ctx, encoded);
         }
     }
@@ -384,9 +361,6 @@
     if (found == 1) {
         claim_value.ptr = tlv_ptr + SHARED_DATA_ENTRY_HEADER_SIZE;
         claim_value.len = tlv_len;
-#ifdef LEGACY_TFM_TLV_HEADER
-        claim_value.len -= SHARED_DATA_ENTRY_HEADER_SIZE;
-#endif
     } else {
         /* If not found in boot status then use callback function to get it
          * from runtime SW
@@ -514,9 +488,6 @@
     if (found == 1) {
         claim_value.ptr = tlv_ptr + SHARED_DATA_ENTRY_HEADER_SIZE;
         claim_value.len = tlv_len;
-#ifdef LEGACY_TFM_TLV_HEADER
-        claim_value.len -= SHARED_DATA_ENTRY_HEADER_SIZE;
-#endif
         res = get_uint(claim_value.ptr, claim_value.len, &slc_value);
         if (res) {
             return PSA_ATTEST_ERR_GENERAL;
@@ -637,9 +608,6 @@
     if (found == 1) {
         claim_value.ptr = tlv_ptr + SHARED_DATA_ENTRY_HEADER_SIZE;
         claim_value.len = tlv_len;
-#ifdef LEGACY_TFM_TLV_HEADER
-        claim_value.len -= SHARED_DATA_ENTRY_HEADER_SIZE;
-#endif
     } else {
         /* If not found in boot status then use callback function to get it
          * from runtime SW
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index 2caf429..0ed262f 100644
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -77,7 +77,6 @@
     PRIVATE
         $<$<CONFIG:Debug>:TFM_CORE_DEBUG>
         $<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
-        $<$<BOOL:${TFM_INTERNAL_MCUBOOT}>:LEGACY_TFM_TLV_HEADER>
 )
 
 # With constant optimizations on tfm_nspc_func emits a symbol that the linker
diff --git a/secure_fw/spm/common/tfm_boot_data.c b/secure_fw/spm/common/tfm_boot_data.c
index 901d43e..fe77002 100644
--- a/secure_fw/spm/common/tfm_boot_data.c
+++ b/secure_fw/spm/common/tfm_boot_data.c
@@ -220,11 +220,9 @@
         /* Create local copy to avoid unaligned access */
         (void)spm_memcpy(&tlv_entry, (const void *)offset,
                          SHARED_DATA_ENTRY_HEADER_SIZE);
-#ifdef LEGACY_TFM_TLV_HEADER
-        next_tlv_offset = tlv_entry.tlv_len;
-#else
+
         next_tlv_offset = SHARED_DATA_ENTRY_HEADER_SIZE + tlv_entry.tlv_len;
-#endif
+
         if (GET_MAJOR(tlv_entry.tlv_type) == tlv_major) {
             /* Check buffer overflow */
             if (((ptr - buf_start) + next_tlv_offset) > buf_size) {