Skip to content

Commit

Permalink
[NXP] Clarify usage of hash id in factory data. Update MATTER_ROOT to…
Browse files Browse the repository at this point in the history
… use a more generic path

Signed-off-by: marius-alex-tache <[email protected]>
  • Loading branch information
marius-alex-tache committed Dec 11, 2023
1 parent 3fc23db commit b94a6f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions scripts/tools/nxp/factory_data_generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
SetupPasscode, StrArgument, UniqueId, VendorId, VendorName, Verifier)
from default import InputArgument

# Global variable for hash ID
hash_id = "CE47BA5E"
# A magic value used in the factory data integrity check.
# The value will be checked at runtime, before verifying the
# factory data integrity. Factory data header has the following format:
# | hash id (4 bytes) | size (4 bytes) | hash (4 bytes) |
# If the hash id check fails, it means the factory data is either missing
# or has become corrupted.
HASH_ID = "CE47BA5E"


def set_logger():
Expand Down Expand Up @@ -158,7 +163,7 @@ def to_bin(self, klv, out, aes128_key):
fullContentCipher = size.to_bytes(4, "little") + fullContentCipher

# Add hash id
hashId = bytearray.fromhex(hash_id)
hashId = bytearray.fromhex(HASH_ID)
hashId.reverse()
fullContentCipher = hashId + fullContentCipher

Expand Down
2 changes: 1 addition & 1 deletion scripts/tools/nxp/generate_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os
import subprocess

MATTER_ROOT = os.path.dirname(os.path.realpath(__file__))[:-len("/scripts/tools/nxp")]
MATTER_ROOT = os.path.dirname(os.path.realpath(f"{__file__}/../../../"))


def gen_test_certs(chip_cert_exe: str,
Expand Down

0 comments on commit b94a6f1

Please sign in to comment.