Ignacio Gil wrote:
>
> Thank you for your help, but it doesn't work at all.
> I need to sign a "char * msg" to obtain a "char * (or similar)"
> for sending a signed mail.
Well you can't really send the DER encoded version because its in binary
format and may well contain embedded nulls. You can however edit the PEM
format which is essentially a base64 version of the DER.
It is possible to do some BIO shuffling and get the base64 encoding
without the -----BEGIN and ------END lines.
Anyway...
> /*Here I've got the problem*/
>
> /*printf("mark1\n");*/ /*I know if there is a segmentation fault, it won't
> show the marks... but...*/
> i=i2d_PKCS7(p7,NULL);
> /*printf("mark2\n");*/
> buf=malloc(i);
> /*printf("mark3\n");*/
> msg_aux=buf;
> /*printf("mark4\n");*/
> i=i2d_PKCS7(p7,&msg_aux);
>
> printf("Printting PKCS7\n%s\n",msg_aux);
> strcpy(der,msg_aux);
>
Here at least is part of the problem. As I said msg_aux is incremented
to point to the *end* of the data it has just written.. that is it will
write the DER encoding to buf using i bytes and afterwards updated
msg_aux to be buf + i. So you'd need to write i bytes starting from buf.
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]