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: Rustam Ismayilov <rustam.ismayilov@arm.com> Change-Id: I106059c6c903c3d560477d5114d866f48590ad7e
This commit is contained in:
parent
36f8bf3085
commit
d16a613f6d
|
@ -1,4 +1,4 @@
|
|||
# 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,
|
||||
SwComponent.VERSION: sw_version,
|
||||
SwComponent.SIGNER_ID: sw_signer_id,
|
||||
SwComponent.MEASUREMENT_DESCRIPTION: sw_measurement_description,
|
||||
}
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue