Re: Convert struct to char* in C



rachedi.dz@xxxxxxxxx wrote:

1- I want to program a specific certificate of the following form :
struct cert {
int node_i;
unsigned char clepub_i[1024];
u_int8_t status_i;
int node_ca;
double tps_gen;
double dur_val;
};

I want convert that structure to (unsigned char * ) type in order to
hash structur and crypter the hash result with a public key. eg. SHA-1
and RSA .

The purpose of computing a secure hash (not any old hash function) and signing it is to effectively prove that the key holder signed the original data. The purpose of THAT is to produce the original data and prove that it was signed by the key holder. You are much better off converting the original data to standard text form (say ASCII with 8th bit of octet = 0) before computing the secure hash, e.g. with sprintf on a suitable platform. You then would send or save the text form of the data, not the binary.


--
Thad
.



Relevant Pages