I am currently working on a firmware update mechanism for embedded system with low memories.
Part of the system requires to hash (with SHA-256) the binary file before sending the file (other security features are added but do not impact this question). The device must verify this hash before validating it, but is pretty low on memory. It will receive the data in small chunks, and I am wondering if it is possible to compute partial hash "on the fly", to avoid loading the whole binary again after the full transfer.
As an example, let's say the data to hash is "part1part2part3". The hash of the full data is "hash", the hash of "part1" is "hash1", the hash of "part2" is "hash2" and the hash of "part3" is "hash3".
Is there any mathematical operation I can do to convert partial hashes to the full one? Something like
hashReceived = hash
tempHash = operation(hash1,hash2)
tempHash = operation(tempHash, hash3)
if(hashReceived == tempHash)
... continue
else
... fail
I am looking for a mathematical property (something like the distributive property) of SHA-256 that could allow such behavior without breaking any of the SHA-256 properties.