Ignacio Gil wrote:
>
> Hello, I still haven't figured out the way to pass a pkcs7 object to a
> char *. I think I understand everything I must do, but it still doesn't
> work.
>
[code deleted]
Well the error messages make more sense if you call
ERR_load_crypto_strings().
There are several things wrong with the code. You are firstly allocating
a memory BIO then changing the pointer to point to a block i K in size
which isn't a valid BIO structure.
When I first say your query I assumed you wanted the DER encoded version
somewhere...
OK lets start again and assume you've got p7 nicely signed and want the
base64 encode version in a block of memory. One way to do it with BIO
shuffling...
BIO *mem, *b64;
mem = BIO_new(BIO_s_mem());
b64 = BIO_new(BIO_f_base64);
BIO_push(b64, mem);
i2d_PKCS7_bio(b64, p7);
BIO_flush(b64);
At this point we have a memory BIO with the data we want in it. The
current release versions of OpenSSL are a bit messy to get the data out
of. One way is:
BUF_MEM *buf = NULL;
BIO_get_mem_ptr(mem, &buf);
at this point buf->data contains buf->length bytes of the memory BIO.
You should copy this somewhere and then call:
BIO_free_all(b64);
I think thats the right way round. I had to look this up myself to see
I'd got the ordering right.
Another way is to avoid BIOs altogether and call the base64 encoding
routines. Then you need the DER encoded data and the stuff I mentioned
earlier.
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
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]