
kayameti at gmail
Feb 25, 2008, 1:25 AM
Post #1 of 1
(941 views)
Permalink
|
Hi all, I installed libgcrypt-1.4.0 and want to compile this code (which is from "selftest()" function of "cipher/blowfish.c"): -------------------- test.c ------------------------ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <gcrypt.h> int main(){ BLOWFISH_context c; byte plain[] = "BLOWFISH"; byte buffer[8]; bf_setkey((void *) &c, (const unsigned char*) "abcdefghijklmnopqrstuvwxyz", 26); encrypt_block((void *) &c, buffer, plain); if(memcmp(buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8)){ printf("Blowfish selftest failed (1).\n"); exit(-1); } decrypt_block((void *) &c, buffer, buffer); if(memcmp(buffer, plain, 8)){ printf("Blowfish selftest failed (2).\n"); exit(-1); } return 0; } When I give " gcc -Wall -lgcrypt -L/usr/local/lib/ -I/usr/local/include/ -o test test.c -L/usr/local/lib/libgcrypt.so -Wl,--rpath -Wl,/usr/local/lib" command to compile the code, it gives these errors: test.c: In function 'main': test.c:9: error: 'BLOWFISH_context' undeclared (first use in this function) test.c:9: error: (Each undeclared identifier is reported only once test.c:9: error: for each function it appears in.) test.c:9: error: expected ';' before 'c' test.c:10: error: 'byte' undeclared (first use in this function) test.c:10: error: expected ';' before 'plain' test.c:11: error: expected ';' before 'buffer' test.c:13: warning: implicit declaration of function 'bf_setkey' test.c:13: error: 'c' undeclared (first use in this function) test.c:14: warning: implicit declaration of function 'encrypt_block' test.c:14: error: 'buffer' undeclared (first use in this function) test.c:14: error: 'plain' undeclared (first use in this function) test.c:21: warning: implicit declaration of function 'decrypt_block' How can I fix this error? Please help. Thanks a lot. Best regards.
|