if(strncmp(argv[i],"lena",4)==0) lena = atoi(&(argv[i][4])); //Use Lena or buffer
}
- printf("nb times %d\n",nb_test);
+/* printf("nb times %d\n",nb_test);
printf("cbcrm %d\n",cbcrm);
printf("cbcprng %d\n",cbcprng);
printf("ecbrm %d\n",ecbrm);
printf("h %d\n",h);
printf("lena %d\n",lena);
printf("size_buf %d\n",size_buf);
-
+*/
}
else {
width=height=size_buf;
- imsize=width*height;
- cout<<"imsize "<<imsize<<endl;
+ imsize=width*height*3;
+ //cout<<"imsize "<<imsize<<endl;
buffer=new uchar[imsize];
for(int i=0;i<imsize;i++) {
buffer[i]=lrand48();
-
+ cout<<"imsize "<<imsize<<endl;
uchar* seq= new uchar[imsize];
uchar* seq2= new uchar[imsize];
}
}
else {
- for(int i=0;i<oneD;i++) {
+ for(int i=0;i<oneD*3;i++) {
seq[i]=buffer[i];
}
}
double t=TimeStart();
- rc4key(DK, Sbox1, 8);
-
-
- rc4key(&DK[8], Sbox2, 8);
-
- rc4key(&DK[16], sc, 16);
- prga(sc, h*h*2+256, RM);
-
+ for(int i=0;i<nb_test;i++) {
-
-
- rc4keyperm(&DK[72], len, rp, Pbox, 16);
+ rc4key(DK, Sbox1, 8);
- rc4keyperm(&DK[88], len/2, rp, PboxSRM2, 16);
+ rc4key(&DK[8], Sbox2, 8);
+
+ rc4key(&DK[16], sc, 16);
+ prga(sc, h*h*2+256, RM);
+
+
- for(int i=0;i<len/2;i++) {
- PboxSRM[i]=PboxSRM2[i]&(h-1);
- }
+
+ rc4keyperm(&DK[72], len, rp, Pbox, 16);
+
+
+ rc4keyperm(&DK[88], len/2, rp, PboxSRM2, 16);
+
+ for(int i=0;i<len/2;i++) {
+ PboxSRM[i]=PboxSRM2[i]&(h-1);
+ }
+
/*
for(int i=0;i<h*2;i++) {
for(int j=0;j<h;j++)
cout<<endl;
}
*/
+ }
-
-
- //time+=TimeStop(t);
- //cout<<"Time initializaton "<<time<<endl;
+ double time_init=0;
+ time_init+=TimeStop(t);
+ cout<<"Time initializaton nb times "<<nb_test<<" = "<<time_init<<endl;
time_encrypt+=TimeStop(t);
- //cout<<"Time encrypt "<<
+ cout<<"Time encrypt "<<time_encrypt<<endl;
cout<<(double)imsize*nb_test/time_encrypt<<"\t";
equal=false;
}
}
- cout<<"RESULT CORRECT: "<<equal<<endl;
+ //cout<<"RESULT CORRECT: "<<equal<<endl;
}