Commit d16a613f authored by Rustam Ismayilov's avatar Rustam Ismayilov Committed by Dávid Vincze
Browse files

imgtool: Assert "measurement value" is last in boot_record.py

'Measurement Value' added the 'properties' list initially,
rather than adding it separately later.
Added an assertion to ensure 'Measurement Value' remains as
the last item in the 'properties' list

Signed-off-by: default avatarRustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I106059c6c903c3d560477d5114d866f48590ad7e
parent 36f8bf30
Loading
Loading
Loading
Loading
+6 −6
Changes for scripts/imgtool/boot_record.py: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2019-2021, Arm Limited.
# Copyright (c) 2019-2024, Arm Limited.
# Copyright (c) 2020, Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
@@ -22,6 +22,7 @@ try:
except ImportError:
    from cbor import dumps


class SwComponent(int, Enum):
    """
    Software component property IDs specified by
@@ -36,17 +37,16 @@ class SwComponent(int, Enum):

def create_sw_component_data(sw_type, sw_version, sw_measurement_description,
                             sw_measurement_value, sw_signer_id):

    # List of software component properties (Key ID + value)
    properties = {
        SwComponent.TYPE: sw_type,
    properties = {SwComponent.TYPE: sw_type,
                  SwComponent.VERSION: sw_version,
                  SwComponent.SIGNER_ID: sw_signer_id,
                  SwComponent.MEASUREMENT_DESCRIPTION: sw_measurement_description,
                  SwComponent.MEASUREMENT_VALUE: sw_measurement_value,
                  }

    # Note: The measurement value must be the last item of the property
    #       list because later it will be modified by the bootloader.
    properties[SwComponent.MEASUREMENT_VALUE] = sw_measurement_value

    last_key = list(properties.keys())[-1]
    assert SwComponent.MEASUREMENT_VALUE == last_key, 'Measurement value is not the last item of the property list'
    return dumps(properties)