fX[a+3]=X[a+3];
}
- /* if(it<513) {
- for(int a=0;a<h2;a++)
- printf("%d ",fX[a]);
- printf("\n");
- }*/
+
*(int*)&fX[0]^=it;
- /* if(it<513) {
- for(int a=0;a<h2;a++)
- printf("%d ",fX[a]);
- printf("\n");
- }*/
+
+/* for(int a=0;a<h2;a+=16) {
+ *(int*)&fX[a]^=it;
+ *(int*)&fX[a+4]^=it;
+ *(int*)&fX[a+8]^=it;
+ *(int*)&fX[a+12]^=it;
+ }
+*/
for(int a=0;a<h2;a+=4) {
fX[a]=fX[a]^RM1[a];
-
+ int *Pbox=new int[len];
+ int *PboxRM=new int[h2];
uchar Sbox1[256];
- rc4key(DK, Sbox1, 16);
-
- uchar Sbox2[256];
- rc4key(&DK[16], Sbox2, 16);
+ uchar Sbox2[256];
uchar Inv_Sbox1[256];
uchar Inv_Sbox2[256];
- inverse_tables(Sbox1,256,Inv_Sbox1);
- inverse_tables(Sbox2,256,Inv_Sbox2);
+ uchar sc[256];
+ uchar RM1[h2];
+ uchar RM2[h2];
+
+ double time=0;
+ double t=TimeStart();
+ rc4key(DK, Sbox1, 8);
+
+
+ rc4key(&DK[8], Sbox2, 8);
- uchar sc[256];
- rc4key(&DK[32], sc, 16);
+ rc4key(&DK[16], sc, 16);
- uchar outd[2*(h * h)];
- prga(sc, 2*(h * h), outd);
+
+ prga(sc, h2, RM1);
+
+
+ rc4keyperm(&DK[32], len, rp, Pbox, 16);
+
+
+ rc4keyperm(&DK[48], h2, rp, PboxRM, 16);
+
+ time+=TimeStop(t);
+ cout<<"Time initializaton "<<time<<endl;
+
+
- uchar RM1[h*h];
- uchar RM2[h*h];
- for(int i=0;i<h2;i++){
- RM1[i]=outd[i];
- RM2[i]=outd[i+h2];
- }
-
-
-
-
- uchar keyp[16];
- for (int i = 48; i < 64; i++)
- keyp[i-48] = DK[i];
-// cout<<len<<endl;
- int *Pbox=new int[len];
- int *PboxRM=new int[h2];
- rc4keyperm(keyp, len, rp, Pbox, 16);
-// printf("len %d\n",len);
- for(int i=0;i<len;i++) {
-// printf("%d \n",Pbox[i]);
- }
-
- rc4keyperm(RM2, h2, rp, PboxRM, h2);
+
for(int i=0;i<h2;i++){
RM2[i]=RM1[i];
}
- int *Inv_Pbox=new int[len];
- inverse_tables_int(Pbox,len,Inv_Pbox);
+
-
- double time=0;
- double t=TimeStart();
+ inverse_tables(Sbox1,256,Inv_Sbox1);
+ inverse_tables(Sbox2,256,Inv_Sbox2);
+
+
+
+
+
+ time=0;
+ t=TimeStart();
int i;
switch(h) {
else
encrypt<64*64>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0);
+ }
+ break;
+ case 128:
+ for(i=0;i<nb_test;i++)
+ {
+ if(ctr)
+ encrypt_ctr<128*128>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1);
+ else
+ encrypt<128*128>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0);
+
}
break;
}
decrypt<64*64>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0);
}
break;
+ case 128:
+ for(i=0;i<nb_test;i++) {
+ if(ctr)
+ encrypt_ctr<128*128>(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0);
+ else
+ decrypt<128*128>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0);
+ }
+ break;
}
time+=TimeStop(t);