+ mylong *rm1=(mylong*)RM1;
+ mylong *rm2=(mylong*)RM2;
+
+
+ for(int it=0;it<len/2;it++) {
+ int ind1=Pbox[it]*h;
+ int ind2=Pbox[it+len/2]*h;
+
+
+ for(int a=0;a<(h>>3);a++) {
+ myrand=xorshift64();
+ rm1[a]=myrand;
+ myrand=xorshift64();
+ rm2[a]=myrand;
+ }
+
+
+
+ for(int a=0;a<h;a+=4) {
+ gY[a]=seq_in[ind2+a];
+ gY[a+1]=seq_in[ind2+a+1];
+ gY[a+2]=seq_in[ind2+a+2];
+ gY[a+3]=seq_in[ind2+a+3];
+ }
+
+ for(int a=0;a<h;a+=4) {
+ fX[a]=seq_in[ind1+a];
+ fX[a+1]=seq_in[ind1+a+1];
+ fX[a+2]=seq_in[ind1+a+2];
+ fX[a+3]=seq_in[ind1+a+3];
+ }
+
+
+
+
+ for(int a=0;a<h;a+=4) {
+ tmp[a]=Inv_Sbox1[gY[a]]^RM2[a];
+ tmp[a+1]=Inv_Sbox1[gY[a+1]]^RM2[a+1];
+ tmp[a+2]=Inv_Sbox1[gY[a+2]]^RM2[a+2];
+ tmp[a+3]=Inv_Sbox1[gY[a+3]]^RM2[a+3];
+ }
+
+
+ for(int a=0;a<h;a+=4) {
+ invgY[a]=Inv_Sbox2[tmp[a]]^fX[a];
+ invgY[a+1]=Inv_Sbox2[tmp[a+1]]^fX[a+1];
+ invgY[a+2]=Inv_Sbox2[tmp[a+2]]^fX[a+2];
+ invgY[a+3]=Inv_Sbox2[tmp[a+3]]^fX[a+3];
+ }
+
+
+
+ /* for(int a=0;a<h;a+=4) {
+ invgY[a]=Inv_Sbox2[Inv_Sbox1[gY[a]]^RM2[a]]^fX[a];
+ invgY[a+1]=Inv_Sbox2[Inv_Sbox1[gY[a+1]]^RM2[a+1]]^fX[a+1];
+ invgY[a+2]=Inv_Sbox2[Inv_Sbox1[gY[a+2]]^RM2[a+2]]^fX[a+2];
+ invgY[a+3]=Inv_Sbox2[Inv_Sbox1[gY[a+3]]^RM2[a+3]]^fX[a+3];
+ } */
+
+
+
+
+ for(int a=0;a<h;a+=4) {
+ tmp[a]=Inv_Sbox2[fX[a]]^invgY[a];
+ tmp[a+1]=Inv_Sbox2[fX[a+1]]^invgY[a+1];
+ tmp[a+2]=Inv_Sbox2[fX[a+2]]^invgY[a+2];
+ tmp[a+3]=Inv_Sbox2[fX[a+3]]^invgY[a+3];
+
+ }
+
+ for(int a=0;a<h;a+=4) {
+ invfX[a]=Inv_Sbox1[tmp[a]]^RM1[a];
+ invfX[a+1]=Inv_Sbox1[tmp[a+1]]^RM1[a+1];
+ invfX[a+2]=Inv_Sbox1[tmp[a+2]]^RM1[a+2];
+ invfX[a+3]=Inv_Sbox1[tmp[a+3]]^RM1[a+3];
+
+ }
+
+
+ /*
+ for(int a=0;a<h;a+=4) {
+ invfX[a]=Inv_Sbox1[Inv_Sbox2[fX[a]]^invgY[a]]^RM1[a];
+ invfX[a+1]=Inv_Sbox1[Inv_Sbox2[fX[a+1]]^invgY[a+1]]^RM1[a+1];
+ invfX[a+2]=Inv_Sbox1[Inv_Sbox2[fX[a+2]]^invgY[a+2]]^RM1[a+2];
+ invfX[a+3]=Inv_Sbox1[Inv_Sbox2[fX[a+3]]^invgY[a+3]]^RM1[a+3];
+
+ }
+ */
+
+ for(int a=0;a<h;a+=4) {
+ seq_out[ind2+a]=invfX[a];
+ seq_out[ind2+a+1]=invfX[a+1];
+ seq_out[ind2+a+2]=invfX[a+2];
+ seq_out[ind2+a+3]=invfX[a+3];
+ }
+
+ for(int a=0;a<h;a+=4) {
+ seq_out[ind1+a]=invgY[a];
+ seq_out[ind1+a+1]=invgY[a+1];
+ seq_out[ind1+a+2]=invgY[a+2];
+ seq_out[ind1+a+3]=invgY[a+3];
+ }
+
+
+
+ }
+
+
+
+
+}
+
+
+
+
+
+
+template<int h>
+void encrypt_ecb_rm(uchar* seq_in, uchar *seq_out, int len,uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, mylong myrand, int debug) {
+
+ uchar X[h];
+ uchar Y[h];
+ uchar fX[h];
+ uchar gY[h];
+ uchar RM1[h];
+ uchar RM2[h];
+ uchar tmp[h];
+ mylong *rm1=(mylong*)RM1;
+ mylong *rm2=(mylong*)RM2;