One danger with casting a structure as a string is that zero bytes
(which can happen due to "slack bits" in the structure) might be
interpreted as an end-of-string that would prematurely terminate
the data.

If you're going to process binary data, look for an API where you
specify both a pointer and a length.  Or else encode the binary
data in printable format (such as base 64 or hexadecimal) and then
pass THAT string to an API that takes a C string.

And, technically, you CANNOT cast a structure as a string.

What is being talked about is casting a (pointer to a structure) as
a (pointer to a string).

Casting does not actually change the data, only the way in which
it is treated by the program.

Jayashree Kanchana wrote:

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]


-- Charles B (Ben) Cranston mailto: [EMAIL PROTECTED] http://www.wam.umd.edu/~zben

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

Reply via email to