On Mon, Jul 05, 2004, Stephen Soltesz wrote:

> Hello,
> 
> I apologize if my last question was too involved to test easily.
> 
> I've attached a new version of the test code that is much more direct in 
> its use of a message digest.
> 
> The program opens /dev/zero and reads four bytes, one byte at a time, and 
> after each byte retrieves the digest using BIO_gets().
> 
> As you can see from the output, the first digest is not equal to the 
> following three.
> 
> Why is this?  Am I misusing the BIO_gets() api?  Is there an initial value 
> injected into the BIO stream for digests that must be cleared before a 
> first call to BIO_gets can be made?
> 
> Any help you can provide would be appreciated.
> 

The intended use of a digest BIO is to only retrieve the digest once. The
current implementations behaviour when BIO_gets() is called more than once is
undefined: the underlying digest will attempt to interpret a finalized context
as an unfinalized one with unpredictable results.

You should be able to work around this by calling BIO_reset() on the BIO but
this will also send BIO_reset() down the chain which may have undesirable
consequences. Alternatively calling BIO_set_md() again with a NULL digest
value should work.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to