| Algorithm 1 Firmware download and verification algorithm |
-
1:
procedureDownloadAndVerifyFirmware(URL)
-
2:
← ReceiveExpectedHashViaMQTT()
-
3:
← DownloadFirmware(URL)
-
4:
← []
-
5:
while not EndOfFirmware(firmware) do
-
6:
← ReadNextChunk(firmware, 4096)
-
7:
-
8:
end while
-
9:
← Concatenate(allChunks)
-
10:
← CalculateHash(completeFirmware)
-
11:
if hashValue != expectedHashValue then
-
12:
throwVerificationError(“Hash MisMatch”)
-
13:
end if
-
14:
StoreInTemporaryDirectory(firmware)
-
15:
end procedure
|