I think that your code should look like the following (not tested) : struct MyStruct { int iMyInt; float fMyFloat; char szMyString[5]; long lMyLong }
int main () { struct MyStruct sStruct; unsigned char szEncrypted[...]; RSA Rsa; int iResult; /* Do some initializations here ... */ /* Encryption */ iResult = RSA_public_encrypt (sizeof (struct MyStruct), (unsigned char *)&sStruct, szEncrypted, &Rsa, RSA_PKCS1_PADDING); /* Decryption */ iResult = RSA_public_decrypt (sizeof (szEncrypted), szEncrypted, (unsigned char *)&sStruct, &Rsa, RSA_PKCS1_PADDING); } I hope this helps. Marc. > -----Message d'origine----- > De : Jayashree Kanchana [mailto:[EMAIL PROTECTED] > Envoyé : mardi 3 août 2004 16:43 > À : [EMAIL PROTECTED] > Objet : Re: RE : RSA encryption - to encrypt a c structure ?? > > > > Hi Marc, > > I am sorry, I am not sure how I can type cast the structure > to string, should I do (char *) ? Once I encrypt I am not > sure if the encrypted string has the same structure as the > original "structure". > > Can you please show me the synatx to type cast a structure to string. > > Thanks, > Jayashree > > > > On Tue, 3 Aug 2004, Marc Gaudichet wrote: > > > Maybe you could cast the contents of your structure to a string, > > encrypt this string and then cast the string back to your structure > > type. > > > > Marc. > > > > > -----Message d'origine----- > > > De : Jayashree Kanchana [mailto:[EMAIL PROTECTED] > Envoyé : mardi > > > 3 août 2004 16:00 À : [EMAIL PROTECTED] > > > Objet : RSA encryption - to encrypt a c structure ?? > > > > > > > > > Hi, > > > > > > I am hoping that someone might have come across this problem and > > > will be able to help me. > > > > > > I am trying to use openssl to encrypt a "c structure" instead of > > > just a "string", is there any function in openssl that I > could use? > > > > > > I have a RSA key structure that is already created and I > am able to > > > encrypt and decrypt just a "string" using > RSA_public_encrypt command > > > and this RSA key pair . > > > > > > Thanks in advance, > > > Jayashree > > > > > > > ______________________________________________________________________ > > > OpenSSL Project > http://www.openssl.org > > > User Support Mailing List > [EMAIL PROTECTED] > > > Automated List Manager > [EMAIL PROTECTED] > > > > > > ______________________________________________________________________ > > OpenSSL Project > http://www.openssl.org > > User Support Mailing List > [EMAIL PROTECTED] > > Automated List Manager > [EMAIL PROTECTED] > > > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List [EMAIL PROTECTED] > Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]