#include //#include "./printf.h" //#include typedef byte uchar; const int size_mesg=256; // size of plain-message const int sleepTimeS = 10; const int h=4; // size of each block const int nblocks=size_mesg/h; // number of blocks int rp=1; byte DK[64]; int PboxRM[h]; uchar Sbox1[256]; //-------------------------------------------------------------------- //Function: KSA algorithm of RC4 //-------------------------------------------------------------------- void rc4key(uchar *key, uchar *sc, int size_DK) { for(int i=0;i<256;i++) { sc[i]=i; } uchar j0 = 0; for(int i0=0; i0<256; i0++) { j0 = (j0 + sc[i0] + key[i0%size_DK] )&0xFF; uchar tmp = sc[i0]; sc[i0] = sc[j0 ]; sc[j0] = tmp; } } //-------------------------------------------------------------------- //Function: Modified KSA of RC4 //-------------------------------------------------------------------- void rc4keyperm(uchar *key,int nblocks, int rp,int *sc, int size_DK) { //sc=1:nblocks; for (int i=0;i