14 const int size_mesg=1024;
16 typedef unsigned char byte;
25 struct timeval tstart;
26 gettimeofday(&tstart,0);
27 return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) );
30 double TimeStop(double t)
34 gettimeofday(&tend,0);
35 t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t;
42 int main(int argc, char** argv) {
45 printf("\nTesting AES128\n\n");
47 printf("\nTesting AES192\n\n");
49 printf("\nTesting AES256\n\n");
51 printf("You need to specify a symbol between AES128, AES192 or AES256. Exiting");
57 byte plain[size_mesg];
58 byte cipher [size_mesg] ;
59 byte check [size_mesg] ;
67 for(int i=0;i<16;i++) {
72 for(int i=0;i<8;i++) {
80 for(int i=0;i<size_mesg;i++) {
83 /* for(int i=0;i<size_mesg;i++) {
84 printf("%d ",plain[i]);
94 for(int i=0;i<nb_times;i++)
97 printf("time generate sbox %f\n",time);
100 // AES_init_ctx_iv(&ctx, mykey, iv);
103 for(int i=0;i<nb_times;i++) {
104 My_KeyExpansion(ctx.RoundKey, mykey);
105 memcpy (ctx.Iv, iv, AES_BLOCKLEN);
109 printf("time key expansion %f\n",time);
113 for(int i=0;i<nb_times;i++)
114 My_AES_CTR_xcrypt_buffer(&ctx, plain, size_mesg);
116 printf("time cipher %f size %d\n",time,size_mesg);
119 /* for(int i=0;i<size_mesg;i++) {
120 printf("%d ",plain[i]);
124 // AES_init_ctx_iv(&ctx, mykey, iv);
125 My_KeyExpansion(ctx.RoundKey, mykey);
126 memcpy (ctx.Iv, iv, AES_BLOCKLEN);
129 My_AES_CTR_xcrypt_buffer(&ctx, plain, size_mesg);
132 /* for(int i=0;i<size_mesg;i++) {
133 printf("%d ",plain[i]);