I'm afraid sizeof(texto) returns the size of the pointer itself (4 in case of 
IA-32), not the data length. sizeof(struct PeticionSeudonimo) would be more 
effective.
Also, you are using pointers in your struct (like char *mensaje), which means 
you are ciphering the pointer only, not the data it is pointing to.

HTH,
Gyorgy

>>> [EMAIL PROTECTED] 5/11/2005 10:07:28 >>>
Hello:

Thanks Nils for you help, but I obtain the problem. I have tried your
advice:
    RSA_public_encrypt(sizeof(texto)+1, texto, textocifrado, claveRSA,
RSA_PKCS1_PADDING);

but the problem is the same.

----- Original Message ----- 
From: "Nils Larsch" <[EMAIL PROTECTED]>
To: <openssl-users@openssl.org>
Sent: Thursday, May 12, 2005 9:51 AM
Subject: Re: Problem to cipher/decypher a struct with RSA


> Angel Martinez Gonzalez wrote:
> > Hello:
> >
> > I want to cypher/decypher an struct:
> >
> > struct PeticionSeudonimo
> >  {
> >   char *mensaje;
> >   int id_peticion;
> >   DES_cblock *clave_simetrica;
> >  }peticion_seudonimo;
> >
> > To do this, I first convert this struct to char *:
> >
> >  char *ptrPeticionSeudonimo = (char *)&peticion_seudonimo;
> >
> > Then I use this function to cipher:
> >
> > char *CifradoClavePublica(RSA *claveRSA, char *texto)
> > {
> >      char *textocifrado;
> >
> >      textocifrado =malloc(RSA_size(claveRSA));
> >      RSA_public_encrypt(strlen(texto)+1, texto, textocifrado, claveRSA,
>
> I wouldn't use strlen(), sizeof() might be more appropriate
>
> Nils
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org 
> User Support Mailing List                    openssl-users@openssl.org 
> Automated List Manager                           [EMAIL PROTECTED] 

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org 
User Support Mailing List                    openssl-users@openssl.org 
Automated List Manager                           [EMAIL PROTECTED]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to