}
template<int h>
-void encrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uchar* IV,mylong myrand) {
+void encrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uchar* IV,uchar* MAC,mylong myrand) {
uchar RM1[h];
uchar tmp1[h];
mylong *rm1=(mylong*)RM1;
}
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]];
+ MAC[a]=Sbox2[IV[a]];
+ MAC[a+1]=Sbox2[IV[a+1]];
+ MAC[a+2]=Sbox2[IV[a+2]];
+ MAC[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) {
+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,uchar* MAC,mylong myrand) {
uchar RM1[h];
uchar tmp1[h];
mylong *rm1=(mylong*)RM1;
}
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]];
+ MAC[a]=Sbox2[IV[a]];
+ MAC[a+1]=Sbox2[IV[a+1]];
+ MAC[a+2]=Sbox2[IV[a+2]];
+ MAC[a+3]=Sbox2[IV[a+3]];
}
}
uchar RM[h*h*2+256];
uchar IV1[h];
uchar IV2[h];
- uchar MAC[2*h];
+ uchar MAC[h];
+
+
mylong myrand=0;
double t=TimeStart();
+ for(int i=0;i<h;i++) {
+ IV1[i]=i;
+ IV2[i]=i;
+ MAC[i]=i;
+ }
+
+
+
for(int i=0;i<nb_test;i++) {
rc4key(DK, Sbox1, 8);
if(v2b2)
encrypt_authenticate_algorithm_2Blocks_V2<32>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand);
if(v2b3)
- encrypt_authenticate_algorithm_2Blocks_V3<32>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,myrand);
+ encrypt_authenticate_algorithm_2Blocks_V3<32>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,MAC,myrand);
}
break;
}
cout<<"Time encrypt "<<time_encrypt<<endl;
cout<<(double)imsize*nb_test/time_encrypt<<"\t";
+ /* for(int i=0;i<h;i++)
+ printf("%d ",MAC[i]);
+ printf("\n");
+ */
if(lena) {
for(int i=0;i<oneD;i++) {
store_RGB_pixmap("lena2.ppm", data_R, data_G, data_B, width, height);
}
+ for(int i=0;i<h;i++) {
+ IV1[i]=i;
+ IV2[i]=i;
+ MAC[i]=i;
+ }
+
xorseed=myrand;
// lehmer64_seed(myrand);
time_decrypt=0;
if(v2b2)
decrypt_authenticate_algorithm_2Blocks_V2<32>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand);
if(v2b3)
- decrypt_authenticate_algorithm_2Blocks_V3<32>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,myrand);
+ decrypt_authenticate_algorithm_2Blocks_V3<32>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand);
}
break;
}
+
time_decrypt+=TimeStop(t);
// cout<<"Time decrypt "<<time_decrypt<<endl;
cout<<(double)imsize*nb_test/time_decrypt<<"\t";
-
+ /* for(int i=0;i<h;i++)
+ printf("%d ",MAC[i]);
+ printf("\n");
+ */
+
if(lena) {
for(int i=0;i<oneD;i++) {
data_R[i]=seq[i];