#include<stdlib.h>
#include <stdint.h>
#include <string.h>
+#include <sys/time.h>
#include"aes.h"
#define CTR 1
-const int size_mesg=64;
+const int size_mesg=1024;
typedef unsigned char byte;
+double TimeStart()
+{
+ struct timeval tstart;
+ gettimeofday(&tstart,0);
+ return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) );
+}
+
+double TimeStop(double t)
+{
+ struct timeval tend;
+
+ gettimeofday(&tend,0);
+ t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t;
+ return (t);
+}
+
for(int i=0;i<size_mesg;i++) {
plain[i]=i;
}
- for(int i=0;i<size_mesg;i++) {
+/* for(int i=0;i<size_mesg;i++) {
printf("%d ",plain[i]);
}
printf("\n\n");
-
+*/
struct AES_ctx ctx;
- rc4key(mykey, 8);
+ int nb_times=1000;
+
+ double time=0;
+ double t=TimeStart();
+ for(int i=0;i<nb_times;i++)
+ rc4key(mykey, 8);
+ time+=TimeStop(t);
+ printf("time generate sbox %f\n",time);
+
// AES_init_ctx_iv(&ctx, mykey, iv);
- My_KeyExpansion(ctx.RoundKey, mykey);
- memcpy (ctx.Iv, iv, AES_BLOCKLEN);
- My_AES_CTR_xcrypt_buffer(&ctx, plain, size_mesg);
+ time=0;
+ t=TimeStart();
+ for(int i=0;i<nb_times;i++) {
+ My_KeyExpansion(ctx.RoundKey, mykey);
+ memcpy (ctx.Iv, iv, AES_BLOCKLEN);
+ }
+ time+=TimeStop(t);
+ printf("time key expansion %f\n",time);
+ time=0;
+ t=TimeStart();
+ for(int i=0;i<nb_times;i++)
+ My_AES_CTR_xcrypt_buffer(&ctx, plain, size_mesg);
+ time+=TimeStop(t);
+ printf("time cipher %f size %d\n",time,size_mesg);
- for(int i=0;i<size_mesg;i++) {
+
+/* for(int i=0;i<size_mesg;i++) {
printf("%d ",plain[i]);
}
-
+*/
printf("\n\n");
// AES_init_ctx_iv(&ctx, mykey, iv);
My_KeyExpansion(ctx.RoundKey, mykey);
My_AES_CTR_xcrypt_buffer(&ctx, plain, size_mesg);
- for(int i=0;i<size_mesg;i++) {
+ /* for(int i=0;i<size_mesg;i++) {
printf("%d ",plain[i]);
- }
+ }*/
printf("\n\n");