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,
RSA_PKCS1_PADDING);

     return (textocifrado);
}

and I call this function at this way:
    solicitudCifrada = CifradoClavePublica(clavePublicaRSA_TTP,
ptrPeticionSeudonimo);

Then, I decipher (solicitudCifrada) using this function:

char *DescifradoClavePrivada(RSA *claveRSA, char *texto)
{
     char *textoclaro;

     textoclaro = malloc(RSA_size(claveRSA));
     RSA_private_decrypt(RSA_size(claveRSA), texto, textoclaro, claveRSA,
RSA_PKCS1_PADDING);

     return (textoclaro);
}

and I call this function at this way:
    solicitudDescifrada = DescifradoClavePrivada(clavePrivadaRSA_TTP,
solicitudCifrada);

Finally, I convert "solicitudDescifrada" from char * to struct:
    peticion_seudonimo_descifrada = (struct PeticionSeudonimo
*)solicitudDescifrada;

But, when I want to show the fields of this struct
"peticion_seudonimo_descifrada", I only obtain the first field (char
*mensaje), the others fileds are "missing". I obtain an error at execution
time. This fields are disappear.

What is wrong?.

Thanks for your help.

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

Reply via email to