#include #include #include #define comp 0 typedef unsigned char ch; typedef struct {ch s[256]; ch j;} state; typedef unsigned int uint; void mv2(char *, state *); void initst(state *, ch *); unsigned int TBl(void); state st; ch k[256]; int main(int argc, char * * args){ void pr(ch* s){ int j; for(j=0; j<256; ++j) printf("%s%02x", j&31?"":"\n", s[j]); printf("\n");} if(argc <2) {printf("Gimme key!!\n"); exit (0);} initst(&st, (ch*)args[1]); {uint t0 = TBl(); const int rn = 4<<17; {int jx=rn; while(jx--) mv2((char*)k, &st);} uint et = TBl() - t0; printf("et = %d, %5.2f clks per byte.\n", et, 16.*et/(rn*256.));} if(1) pr(st.s); // Histogram: if(0){int h[256]; {int j = 256; while (j--) h[j] = 0;} {int j = 256; while(j--) ++h[k[j]];} {int j; for(j=0; j<256; ++j){if(!(j&15)) printf("\n %02x ", j); printf("%d ", h[j]);} printf("\n");}} // Test if state is still a permutation. {ch x[256]; {int j=256; while(j--) x[j]=0;} {int j=256; while(j--) ++x[st.s[j]];} {int j=256; while(j--) if(x[j]!=1) printf("%d %02x's\n", x[j], j);}} if(0) {pr(st.s); pr(k); printf("j=%02x\n", st.j);} return 0;}