我已经下载了libtomcrypt API,想对AES算法进行基准测试。我所做的是创建一个源文件并包含tomcrypt.h头文件。然后我写了测试加密功能的代码--“rijndael_ecb_encrypt”。
#include <time.h>
#include <tomcrypt.h>
#define MIN_TIME 10.0
#define MIN_ITERS 20
double test_rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey) {
int iterations = 0;
clock_t start;
double elapsed=0.0;
int out;
start=clock();
do{
out = rijndael_ecb_encrypt(pt, ct, skey);
iterations++;
elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
} while(elapsed<MIN_TIME || iterations<MIN_ITERS);
elapsed=1000.0*elapsed/iterations;
printf("%s \n",pt);
//printf("%s \n",skey->data);
printf("%s \n",ct);
printf("iterations: %8d \n",iterations);
printf("%8.2lf ms per iteration \n",elapsed);
printf("out: %d \n",out);
return elapsed;
}
int main(){
//called the function
}它可以正确编译,但存在实时链接错误。并且它没有检测到函数"rijndael_ecb_encrypt“,错误显示为:
gcc -o "TestC" ./src/TestC.o
./src/TestC.o: In function `test_rijndael_ecb_encrypt':
/home/anvesh/workspace/TestC/Debug/../src/TestC.c:35: undefined reference to `rijndael_ecb_encrypt'
collect2: error: ld returned 1 exit status
make: *** [TestC] Error 1对于测试AES加密的执行时间,我是否做了正确的实现?如果不是,有什么替代方案可以实现吗??有什么建议吗?请帮帮我。
发布于 2013-05-31 14:09:35
安装tom加密库。
sudo apt-get install libtomcrypt-dev然后在编译时包含该库:
gcc file.c -ltomcrypthttps://stackoverflow.com/questions/16843836
复制相似问题