On Tuesday August 29th 2006 at 14:18 Heikki Toivonen wrote:

> I am trying to use SMIME_read_PKCS7 to read a signed and encrypted MIME
> message from memory BIO, but I can't get it to work. It works fine if I
> construct a file BIO to read from. Am I doing something wrong, or is
> this a bug?
> 
> See the test application below that shows the problem. Please note that
> you need to save the contents of smime_text variable into a file called
> "smime_text.txt" manually, before the file BIO case will work.
> 
> When I run the program, I get the following output:
> 
> 3445
> Memory BIO case, error: 218542222

This error, converted to hexadecimal, is 0xd06b08e which when used in

        $ openssl errstr d06b08e
gives

        error:0D06B08E:asn1 encoding routines:ASN1_d2i_bio:not enough data

So reading from the memory BIO seems not to give enough data, at least
that is what is suggested here. There might be a bug or at least
misconception here, read on:
> 
> This is on Cygwin, with OpenSSL 0.9.8a.

Confirmed with OpenSSL 0.9.8b and OpenSSL 0.9.7e on Debian 'sid' and
Debian 'sarge', so with GNU/Linux.

> ---CLIP---
> 
> ...
> 
>     BIO *signedEncryptedBio = BIO_new(BIO_s_mem());

If we put an extra line after this, with what seems to be the default:

        BIO_set_mem_eof_return(signedEncryptedBio, -1);

the reading of the PKCS7 structure from the memory BIO fails in exactly
your reported manner. If however we put the following:

        BIO_set_mem_eof_return(signedEncryptedBio, 0);

suddenly it starts working. I leave it to the experts if the default is
the most wanted behaviour, but at least you have a workaround now.

The man page is in BIO_s_mem(3ssl).
-- 
Marco Roeland
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to