This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using the openssl library - weird warnings


Hi!

I am using the openssl des <openssl/des.h> library for some code, and
have encountered some weird warnings while compiling.

==> my code #1

	int foo (const_des_cblock key)
	{
		des_key_schedule ks;
		des_set_key (&key, keySchedule);
		......
	}

Gives a warning while compiling saying :
warning: passing arg 1 of `des_set_key' from incompatible pointer type

The declarations in openssl/des.h are as follows:
==> openssl/des.h 
	.....
	typedef unsigned char des_cblock[8];
	.....
	int des_set_key(const_des_cblock *key,des_key_schedule
schedule);

If I change my code to :

==> my code #2
	int foo1 (const_des_cblock key1)
	{
		des_key_schedule ks;
		const_des_cblock key;
		memcpy ((void *)key, (void *)key1, 8);
		des_set_key (&key, keySchedule);
		......
	}

Then there are no compilation warnings. Further, the execution of
foo(..) gives incorrect results whereas foo1(..) works fine, so its not
just another warning which I can ignore. If I print out the contents of
the 8-char arrays pointed to by 'key' in both the cases ,it is the same.

The entire encryption part is being done in foo(..) or foo1(..) only -
and I have no reason to reuse the key outside of the function call(s).

1. Why the warnings in the case of foo and not in foo1; and
2. Why is the compiler compiling the two function calls differently?

Regards
- Ujval




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]