| Algorithm 2 Synchronizing and verifying the firmware algorithm |
-
1:
procedureSynchronizeAndVerifyRootHash(firmwareFiles)
-
2:
← FetchFirmwareFromSecureStorage()
-
3:
← DownloadFirmware(URL)
-
4:
← CombineFirmwareFiles(existingFirmwareFiles, firmwareFiles)
-
5:
← []
-
6:
for each file in combinedFirmwareFiles do
-
7:
← CalculateHash(file)
-
8:
leafNodes.append(hashValue)
-
9:
end for
-
10:
← BuildMerkleTree(leafNodes)
-
11:
← merkleTree.getRootHash()
-
12:
if computedRootHash != expectedRootHash then
-
13:
throwVerificationError(“RootHash MisMatch”)
-
14:
end if
-
15:
StoreFirmwareSecurely(firmwareFiles)
-
16:
end procedure
|