On Tue, Feb 23, 2010, Reinaldo Matukuma wrote: > > Hello all. > > I will try to explain what I need and what I want to do. > > I know a hash from a file "X". And I also know that this file "X" has data > always been appended at end periodically. > > So, I want to only update the hash information of the file without the need > to read all the file again. > > I know that I have only the previous hash from file before the update. So I > imagine that I need another way to initiate the message digest context, > setting up this as a "initial value" or something. > > But... How can I set this previous hash information on a new MD context > (really isolated because will be done by another process)? >
There isn't a standard solution. To do this you need to mess around with digests at a low level using internals which I normally advise people to steer well clear of. Note to anyone reading this in future... This is a horrible hack. Don't expect this to work. If it does count yourself lucky. Don't even think of doing it if the digest is provided by an ENGINE. With that warning in mind her goes: If you take SHA1 for example the structure SHA_CTX contains the digest context see the sha.h header file.. You can copy the contents of this structure. If the two processes run on the same machine/architecture you should be able to use a binary copy not taking any notice of its contents. Other digest have similar associated structures. You can also do this at the EVP level by copying the md_data struture into an initialised context. The size of that data is in ctx->digest->md_size. You can't just copy the EVP_MD_CTX because it contains pointers to other structures which wont be copied. Just make sure you get a copy of the data before it is finalised. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org