Re: additively computing SHA hash

2010-06-08 Thread Jason Fister
 Stephen,
Thanks for your solution.

Well I'd add the BIG disclaimer that will NOT work in future when OpenSSL
structures are made opaque and almost certainly will fail if you have an
ENGINE.

Understood. I am new to openssl and I am reading up about 'ENGINE's in
openssl. When you say it will fail when there is an 'ENGINE', do you mean if
I use EVP_DIGEST functions (from the example on openssl.org), your solution
will not work? If yes, is the solution as simple as using  SHA1_Init,
SHA1_Update, SHA1_Final functions instead?

What you need to do is copy the md_ctx-data (which will be a flat buffer
for
the software SHA1 implementation) for md_ctx-digest-md_size bytes. Save
that
somewhere and after calling init the second time copy it back. Do NOT try
restoring the context with different versions of OpenSSL or different
architectures.

Will this work with plain old SHA also? I will try to find the answers for
some of the questions on my own by writing some code. But any help from your
side will be much appreciated.

Subra


additively computing SHA hash

2010-06-07 Thread Jason Fister
Hello folks,

I have a service to which people can send data. My service then stores the
data and returns the SHA checksum for the data back to the client. I also
store the checksum I computed and the offset at which it was computed as
part of the metadata.

I want to allow clients to send append requests to this data at a later
time. When they send the append request, I want to be able to use the
checksum that I had already calculated as the starting point and then use
that to generate the new checksum for the appended object.

I know about the init, update and final functions. But I dont see a way to
pass in the checksum value of the original object when computing the
checksum of the new appended object.

Can someone tell me how I can achive the above?

Thanks,
Jason