Angel Martinez Gonzalez wrote:
Hello:

I want to cypher a struct like this:

struct {
    DES_cblock *key;
    int id;
} Request;

but, the "RSA_public_encrypt" function receive as parameter "unsigned char
*from", no a struct:
        int RSA_public_encrypt(int flen, unsigned char *from,
                unsigned char *to, RSA *rsa, int padding);

How I do to cypher my struct?.

Serialize it.

int Request_serialize(const struct Request *in, unsigned char **out)
{
   unsigned char *data = malloc(sizeof(DES_cblock) + sizeof uint32_t);
   *out = data;
   memcpy(data,in->key,sizeof(DES_cblock));
   data+=sizeof(DES_cblock);
   (uint32_t*)data = htonl(in->id);
   return sizeof(DES_cblock) + sizeof uint32_t;
}

Or something like that.

Bye

Goetz

--
DMCA: The greed of the few outweighs the freedom of the many

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to