}
}
-void prga(uchar *sc, int ldata, uchar *r) {
+void prga(uchar *sc, uchar *X, int ldata, uchar *r, int h) {
uchar i0=0;
uchar j0=0;
for (int it=0; it<ldata; it++) {
- i0 = (i0+1);
+ i0 = X[(i0+1)&(h-1)];
j0 = (j0 + sc[i0]);
uchar tmp = sc[i0];
sc[i0] = sc[j0];
sc[j0] = tmp;
- r[it]=sc[(sc[i0]+sc[j0])&0xFF];
+ r[it]=sc[i0];//sc[(sc[i0]+sc[j0])&255];
}
}
//cout<<endl;
- prga(S, h, RM1);
+ prga(S, X,h, RM1,h);
/*
for(int i=0;i<h;i++) {
cout<<(int)RM1[i]<<" ";
*/
// if(it==40)
// exit(0);
+
+
for(int a=0;a<h;a+=4) {
RM1[a]=S[RM1[a]];
RM1[a+1]=S[RM1[a+1]];
Secretkey[i]=lrand48()&0xFF;
counter[i]=lrand48()&0xFF;
}
-
int size = 64;
uchar DK[size];
for (int i = 0; i < 64 ; i++) {
// DK[i]=digest[i];
DK[i]=mix[i];
+ //cout<<(int)DK[i]<<" ";
}
+ //cout<<endl;
+
- prga(sc, h, RM1);
+ prga(sc, sc,h,RM1,h);