Phil Howard wrote:
> 
> I want to get an interim digest of a data stream.  Is the appropriate way
> to do this to just copy the CTX structure, and call the Final function on
> that copy?  In a library I wrote a while back, I did this by having the
> function that gets the digest not be destructive, there being a separate
> destruct call.
> 

Yes except you shouldn't use something like memcpy() to copy the
structure, instead use EVP_MD_CTX_copy() and check its return value (0
== failure).

The reason for this is that although all current digests are in pure
software and their entire context is in the memory structure, in future
hardware based digest implementations may have different techniques for
copying digest contexts or indeed not support it at all. memcpy may not
work properly with these but there's much more chance that
EVP_MD_CTX_copy() will.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to