+ for(int a=0;a<h;a+=4) {
+ IV[a]=Sbox1[IV[a]^seq_out[ind2+a]]^tmp1[a];
+ IV[a+1]=Sbox1[IV[a+1]^seq_out[ind2+a+1]]^tmp1[a+1];
+ IV[a+2]=Sbox1[IV[a+2]^seq_out[ind2+a+2]]^tmp1[a+2];
+ IV[a+3]=Sbox1[IV[a+3]^seq_out[ind2+a+3]]^tmp1[a+3];
+ }
+
+ }
+ for(int a=0;a<h;a+=4) {
+ IV[a]=Sbox2[IV[a]];
+ IV[a+1]=Sbox2[IV[a+1]];
+ IV[a+2]=Sbox2[IV[a+2]];
+ IV[a+3]=Sbox2[IV[a+3]];
+ }
+}
+
+
+template<int h>
+void decrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Inv_Sbox1, uchar *Inv_Sbox2 ,uchar *Sbox1, uchar *Sbox2, uchar* IV,mylong myrand) {
+ uchar RM1[h];
+ uchar tmp1[h];
+ mylong *rm1=(mylong*)RM1;
+
+ 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;
+ }
+
+ for(int a=0;a<h;a+=4) {
+ tmp1[a]=Inv_Sbox2[seq_in[ind1+a]];
+ tmp1[a+1]=Inv_Sbox2[seq_in[ind1+a+1]];
+ tmp1[a+2]=Inv_Sbox2[seq_in[ind1+a+2]];
+ tmp1[a+3]=Inv_Sbox2[seq_in[ind1+a+3]];
+ }
+
+ for(int a=0;a<h;a+=4) {
+ seq_out[ind2+a]=Inv_Sbox2[seq_in[ind2+a]]^tmp1[a];
+ seq_out[ind2+a+1]=Inv_Sbox2[seq_in[ind2+a+1]]^tmp1[a+1];
+ seq_out[ind2+a+2]=Inv_Sbox2[seq_in[ind2+a+2]]^tmp1[a+2];
+ seq_out[ind2+a+3]=Inv_Sbox2[seq_in[ind2+a+3]]^tmp1[a+3];
+ }
+
+ for(int a=0;a<h;a+=4) {
+ seq_out[ind1+a] =Inv_Sbox1[tmp1[a]]^RM1[a];
+ seq_out[ind1+a+1]=Inv_Sbox1[tmp1[a+1]]^RM1[a+1];
+ seq_out[ind1+a+2]=Inv_Sbox1[tmp1[a+2]]^RM1[a+2];
+ seq_out[ind1+a+3]=Inv_Sbox1[tmp1[a+3]]^RM1[a+3];
+ }
+
+ for(int a=0;a<h;a+=4) {
+ IV[a]=Sbox1[IV[a]^seq_in[ind2+a]]^tmp1[a];
+ IV[a+1]=Sbox1[IV[a+1]^seq_in[ind2+a+1]]^tmp1[a+1];
+ IV[a+2]=Sbox1[IV[a+2]^seq_in[ind2+a+2]]^tmp1[a+2];
+ IV[a+3]=Sbox1[IV[a+3]^seq_in[ind2+a+3]]^tmp1[a+3];
+ }
+
+ }
+ for(int a=0;a<h;a+=4) {
+ IV[a]=Sbox2[IV[a]];
+ IV[a+1]=Sbox2[IV[a+1]];
+ IV[a+2]=Sbox2[IV[a+2]];
+ IV[a+3]=Sbox2[IV[a+3]];
+ }
+}