Hello!
My questions concerns if it's possible to use the precomputed hash in the hashing process. Let me present everything in more detail.
Let's say we have such buffers: char buffer1[4096],buffer2[4096],buffer3[4096] which contain some data that is always the same and there is also another buffer: char magic[16] which contains data that change every time you launch the application. The hash in code is calculated as follows:
sha.Initialize();
sha.UpdateData( magic, 16 );
sha.UpdateData( buffer1, sizeof(buffer1) );
sha.UpdateData( buffer2, sizeof(buffer2) );
sha.UpdateData( buffer3, sizeof(buffer3) );
sha.Finalize();
char hash[0x14];
memcpy( hash, sha.GetDigest(), 0x14 );
So 'hash' is the proper output that I'm expecting to get. Now to my question. Is it possible to precompute the hash of the static buffers and somehow include it in the hashing process? I know I can't hash the hash digest result of the buffers because it wouldn't make sense as it would hash the 0x14 bytes of the hash result. Here is what I want to acheive:
char magic[16];
char buffers_sha1_hash[0x14] = { ...hash... };
sha.Initialize();
sha.UpdateData( buffer1, sizeof(buffer1) );
sha.UpdateData( buffer2, sizeof(buffer2) );
sha.UpdateData( buffer3, sizeof(buffer3) );
sha.Finalize();
memcpy( buffers_sha1_hash, sha.GetDigest(), 0x14 );
sha.Initialize();
sha.UpdateData( magic, 10 );
(( here place some code that would include the precomputed buffers_sha1_hash ))
sha.Finalize();
char hash[0x14];
memcpy( hash, sha.GetDigest(), 0x14 );
I have a feeling it may not be possible as to the way how SHA1_Update() operates using previous hash results from SHA_CTX, but I need someone to tell me that it's the wrong approach. Maybe you'll have some other idea on how to acheive the proper hash without having to compute the hashes of the buffers, which are always the same, every time.
Regards,
Black Dot







