I have written a decryption function using openssl which I tested in a standalone program and it worked fine. But this function is a part of a huge project so it has to be included in that program. To execute my standalone program I used the following commands which worked fine:
cc -c aaa.c -I/usr/local/ssl/include
gcc -o aaa aaa.o -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lm
./aaa
I have made a makefile for my main program inside which this function will be called.
Both the programs are working fine individually but when I inserted the definition on the function in my program, it gave me errors for those variables which were in one of the header file of openssl (i.e. des.h). I have made use of a few variables of type DES_cblock:
typedef unsigned char DES_cblock[8];
There is another structure with the following definition:
typedef struct DES_ks
{
union
{
DES_cblock cblock;
DES_LONG deslong[2];
}ks[16];
} DES_key_schedule;
I have made use of this structure in my program like this
DES_key_schedule keysched1,keysched2,keysched3;
But it is not recognizing these variables. And since there was no such error when I was executing my standalone program it means that I am not able to link the library files properly in the main program. How do I make this work. These are the errors that I am getting:
Syntax error at line 1399, column 16,file/export/home/jayesho/src/custom/FRB/tgl_frbsenddata.ec:
Error at line 1399, column 16 in file /export/home/jayesho/src/custom/FRB/tgl_fr
bsenddata.ec
DES_cblock hex_key1,hex_key2,hex_key3,hex_ivec,iv;
...............1
PCC-S-02201, Encountered the symbol "hex_key1" when expecting one of the followi
ng:
; , = : ( [ * ? | & < > + - / % . ^ *= /= %= += -= <<= >>=
&&= ||= ^= | & == != <= >= << >> ++ -- ->
The symbol ";" was substituted for "hex_key1" to continue.
Syntax error at line 1402, column 22, file /export/home/jayesho/src/custom/FRB/tgl_frbsenddata.ec:
Error at line 1402, column 22 in file /export/home/jayesho/src/custom/FRB/tgl_fr
bsenddata.ec
DES_key_schedule keysched1,keysched2,keysched3;
.....................1
PCC-S-02201, Encountered the symbol "keysched1" when expecting one of the follow
ing:
; , = : ( [ * ? | & < > + - / % . ^ *= /= %= += -= <<= >>=
&&= ||= ^= | & == != <= >= << >> ++ -- ->
The symbol ";" was substituted for "keysched1" to continue.
Syntax error at line 1436, column 38, file /export/home/jayesho/src/custom/FRB/tgl_frbsenddata.ec:
Error at line 1436, column 38 in file /export/home/jayesho/src/custom/FRB/tgl_fr
bsenddata.ec
if (DES_set_key_checked((C_Block *)hex_key1, &keysched1))
Now I just need to link the library files properly in my program to make the whole program running. The header file as mention before is des.h which is a part of openssl. I tried including the crypto library also by -lcrypto Previously this des.h was not getting included properly but now have I included the des.h successfully without error. Someone also suggested that merely including the header file is not enough and its implementation file also needs to be linked, so I now I want to know how to include and link what? How to find out the name of the link which needs to be linked.