On Mon, Jun 07, 2010, Subra Aswathanarayanan wrote:

> Steve/Victor,
> 
> >You mean you want to do:
> >SHA1(A)
> >and later do:
> >SHA1(A || B)
> >without including A again?
> 
> That is correct. Thats exactly what I want to do.
> 
> >You need to serialize, save and restore the intermediate state of
> >the digest before you call "final" if you need to be able to append
> >more data without re-computing the entire checksum.
> 
> I am open to the idea of serializing, saving and restoring.
> 
> > OpenSSL does not provide a serialization interface for MD_CTX objects.
> > Perhaps you're better off with a simpler library that does not support
> > engines, and other features that make serialization difficult.
> 
> Both of you mention that OpenSSL doesn't provide such an interface. May be
> this question is not appropriate for this forum, but do you know of any such
> simpler libraries that I might be able to use?
> 
> Has anyone else on this forum ran in to a similar situation and had to dive
> deep in to the source code to make this work?
> 

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.

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.

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

Reply via email to