1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "des.h"
main () {
des_key_schedule k;
unsigned char in[1024*1024];
unsigned char out[1024*1024];
unsigned char ivec[8];
int i;
struct timeval tv;
double t1,t2;
des_set_key("abcdefgh",k);
/* CBC TEST */
for (i=0; i<8; i++) ivec[i] = 0;
for (i=0; i<1024*1024; i++) in[i] = ' ';
gettimeofday(&tv, NULL);
t1 = tv.tv_sec + tv.tv_usec * 1E-6;
des_cbc_encrypt(in, out, 1024*1024, k, ivec, 1);
gettimeofday(&tv, NULL);
t2 = tv.tv_sec + tv.tv_usec * 1E-6;
printf("%f\n", t2-t1);
}
|