uchar X[h2];
for(int a=0;a<h2;a++) {
- X[a]=Sbox1[a&0xFF]; //Warning according to the size of h2, we can be outsize of Sbox1[a]
+ X[a]=Sbox1[(a+10*id)&0xFF]; //Warning according to the size of h2, we can be outsize of Sbox1[a]
}
}
- /*for(int a=0;a<h2;a+=4){
- fX[a]=RM1[X[a]];
- fX[a+1]=RM1[X[a+1]];
- fX[a+2]=RM1[X[a+2]];
- fX[a+3]=RM1[X[a+3]];
- }*/
+ for(int a=0;a<h2;a+=4) {
+ X[a]=X[Sbox1[a]];
+ X[a+1]=X[Sbox1[a+1]];
+ X[a+2]=X[Sbox1[a+2]];
+ X[a+3]=X[Sbox1[a+3]];
+ }
for(int a=0;a<h2;a+=4){
fX[a]=X[a];
+
+
- /* 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+=4) {
- fX[id*h2+a]=fX[id*h2+a]^RM1[id*h2+a];
- fX[id*h2+a+1]=fX[id*h2+a+1]^RM1[id*h2+a+1];
- fX[id*h2+a+2]=fX[id*h2+a+2]^RM1[id*h2+a+2];
- fX[id*h2+a+3]=fX[id*h2+a+3]^RM1[id*h2+a+3];
- }*/
-
-
-
for(int a=0;a<h2;a+=4) {
fX[a]=Sbox2[fX[a]];
int num=omp_get_max_threads();
cout<<"num "<<num<<endl;
- uchar RM1[num*(h * h)];
- uchar RM2[num*(h * h)];
- prga(sc, num*(h * h), RM1);
- for(int i=0;i<num*h2;i++) {
- RM2[i]=RM1[i];
- }
- uchar keyp[16];
- for (int i = 48; i < 64; i++)
- keyp[i-48] = DK[i];
+
+ uchar RM1[num*(h * h)];
+ uchar RM2[num*(h * h)];
+ /*for(int i=0;i<num;i++) {
+
+ rc4key(&DK[48+i*16], sc, 16);
+ prga(sc, h2, &RM1[h2*i]);
+ for(int a=0;a<h2;a++) {
+ cout<<(int)RM1[h2*i+a]<<" ";
+ }
+ cout<<endl<<endl;
+ }*/
+
+ rc4key(&DK[48], sc, 16);
+ prga(sc, h2*num, RM1);
+
+ rc4key(&DK[64], sc, 16);
+ prga(sc, h2, RM2);
+
+
+
+
+
// cout<<len<<endl;
int *Pbox=new int[len];
int *PboxRM=new int[h2];
- rc4keyperm(keyp, len, rp, Pbox, 16);
+ rc4keyperm(&DK[48+16*num], 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<num*h2;i++) {
+ RM2[i]=RM1[i];
+ }
double time=0;
double t=TimeStart();