Skip to main content
. 2024 Feb 23;24(5):1447. doi: 10.3390/s24051447
Algorithm 2 Synchronizing and verifying the firmware algorithm
  • 1:

    procedureSynchronizeAndVerifyRootHash(firmwareFiles)

  • 2:

        expectedRootHashFetchFirmwareFromSecureStorage()

  • 3:

        existingFirmwareFilesDownloadFirmware(URL)

  • 4:

        combinedFirmwareFilesCombineFirmwareFiles(existingFirmwareFiles, firmwareFiles)

  • 5:

        leafNodes[]

  • 6:

        for each file in combinedFirmwareFiles do

  • 7:

            hashValueCalculateHash(file)

  • 8:

            leafNodes.append(hashValue)

  • 9:

        end for

  • 10:

        merkleTreeBuildMerkleTree(leafNodes)

  • 11:

        computedRootHashmerkleTree.getRootHash()

  • 12:

        if computedRootHash != expectedRootHash then

  • 13:

            throwVerificationError(“RootHash MisMatch”)

  • 14:

        end if

  • 15:

        StoreFirmwareSecurely(firmwareFiles)

  • 16:

    end procedure