Skip to content

Commit d16a613

Browse files
rustammendeldavidvincze
authored andcommitted
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 <[email protected]> Change-Id: I106059c6c903c3d560477d5114d866f48590ad7e
1 parent 36f8bf3 commit d16a613

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

scripts/imgtool/boot_record.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2021, Arm Limited.
1+
# Copyright (c) 2019-2024, Arm Limited.
22
# Copyright (c) 2020, Linaro Limited
33
#
44
# SPDX-License-Identifier: Apache-2.0
@@ -22,6 +22,7 @@
2222
except ImportError:
2323
from cbor import dumps
2424

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

3738
def create_sw_component_data(sw_type, sw_version, sw_measurement_description,
3839
sw_measurement_value, sw_signer_id):
39-
4040
# List of software component properties (Key ID + value)
41-
properties = {
42-
SwComponent.TYPE: sw_type,
43-
SwComponent.VERSION: sw_version,
44-
SwComponent.SIGNER_ID: sw_signer_id,
45-
SwComponent.MEASUREMENT_DESCRIPTION: sw_measurement_description,
46-
}
41+
properties = {SwComponent.TYPE: sw_type,
42+
SwComponent.VERSION: sw_version,
43+
SwComponent.SIGNER_ID: sw_signer_id,
44+
SwComponent.MEASUREMENT_DESCRIPTION: sw_measurement_description,
45+
SwComponent.MEASUREMENT_VALUE: sw_measurement_value,
46+
}
4747

4848
# Note: The measurement value must be the last item of the property
4949
# list because later it will be modified by the bootloader.
50-
properties[SwComponent.MEASUREMENT_VALUE] = sw_measurement_value
51-
50+
last_key = list(properties.keys())[-1]
51+
assert SwComponent.MEASUREMENT_VALUE == last_key, 'Measurement value is not the last item of the property list'
5252
return dumps(properties)

0 commit comments

Comments
 (0)