Does anyone care to explain what is the idea behind the init-update-final functions of cartographic hash functions (e.g.
SHA*_Final from OpenSSL)?
Many libraries, like Java and OpenSSL, provide an Init-Update-Final model for transformations. It's used to minimize memory requirements.
Let's suppose all you have is a single shot SHA-1 function which requires the input to be available.
Then, for example, with a 1GB RAM system, how would you hash a file of 2 GB ?
You simply cannot as the SHA-1 function will require to have the whole input in RAM and you simply can't do it.
What you can do, instead, is to call
SHA_Init, read 1MB of the file into RAM,
SHA_Update that 1MB, read the next 1MB of the file (overwriting the previous one), call
SHA_Update on that 1MB, repeat 1998 more times and then call
This requires only 1MB RAM to hash a 2GB file.