I'm trying to use the Tivaware hash acceleration functions to process (Sha256) of a very long file by calling the SHAMD5DataWrite () & SHAMD5ResultRead () Tivaware API. But looking at the examples, I observed that this function(SHAMD5DataWrite (()) requires the prior use of SHAMD5HashLengthSet (), that requires to know a priori the total length of bytes to be processed for the hash calculation . Looking at the source code, I noticed this function resets the calculation of the hash whenever it is called:
Void SHAMD5HashLengthSet (uint32_t ui32Base, uint32_t ui32Length)
{
//
// Check the arguments.
//
ASSERT (ui32Base == SHAMD5_BASE);
//
// Set the LENGTH register and start processing.
//
HWREG (ui32Base + SHAMD5_O_LENGTH) = ui32Length;
}
I have tested, and I have concluded. that SHAMD5HashLengthSet () is called incrementally, the previous hash calculation is lost.
In my case to know the total length of the data in bytes precisely, it is necessary to process the entire file to count the bytes (which would take precious time) or load the file into memory (which is not possible due to big size of file , dozens of Mbytes.)
So I ask if it be possible to save the previous state of the hash calculation using SHAMD5DataWrite () in order to process the hash in a really incremental manner, without prior knowledge of the total bytes to be processed, as it happens in some SW libraries ( which are very slow to use,.wasting about 30% time of saving of file with same size in USB Pen drive).