X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/6df9f32e1ab10a1e08a191ac7fac273e74397831..ef1bb31b1f11fc87b07abff3c53c577425d4ccb3:/OneRoundIoT/OneRound/one_round_new.cpp?ds=sidebyside
diff --git a/OneRoundIoT/OneRound/one_round_new.cpp b/OneRoundIoT/OneRound/one_round_new.cpp
index f0cafd6..5022573 100644
--- a/OneRoundIoT/OneRound/one_round_new.cpp
+++ b/OneRoundIoT/OneRound/one_round_new.cpp
@@ -160,10 +160,16 @@ void encrypt_ctr(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, in
for(int a=0;a
>=8;
+ X[a+1]=Sbox1[mm&255];
+ mm>>=8;
+ X[a+2]=Sbox2[mm&255];
+ mm>>=8;
+ X[a+3]=Sbox1[mm&255];
}
@@ -198,9 +204,9 @@ void encrypt_ctr(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, in
for(int a=0;a
-void decrypt(uchar* seq_in, uchar *seq_out, int len, uchar* RM1, int *Pbox, int *PboxRM, uchar *Inv_Sbox1, uchar *Inv_Sbox2, uint myrand, int debug) {
+void decrypt(uchar* seq_in, uchar *seq_out, int len, uchar* RM1, int *Pbox, int *PboxRM, uchar *Sbox1, uchar *Sbox2, uchar *Inv_Sbox1, uchar *Inv_Sbox2, uint myrand, int debug) {
@@ -339,9 +345,9 @@ void decrypt(uchar* seq_in, uchar *seq_out, int len, uchar* RM1, int *Pbox, int
}
for(int a=0;a>=8;
- seq_out[ind2+a+1]=Inv_Sbox1[fX[a+1]]^(mm&255);
+ seq_out[ind2+a+1]=Inv_Sbox2[fX[a+1]]^(mm&255);
mm>>=8;
seq_out[ind2+a+2]=Inv_Sbox1[fX[a+2]]^(mm&255);
mm>>=8;
- seq_out[ind2+a+3]=Inv_Sbox1[fX[a+3]]^(mm&255);
+ seq_out[ind2+a+3]=Inv_Sbox2[fX[a+3]]^(mm&255);
}
@@ -666,7 +674,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<4*4>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<4*4>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<4*4>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
case 8:
@@ -674,7 +682,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<8*8>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<8*8>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<8*8>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
case 16:
@@ -682,7 +690,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<16*16>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<16*16>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<16*16>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
case 32:
@@ -690,7 +698,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<32*32>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<32*32>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<32*32>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
case 64:
@@ -698,7 +706,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<64*64>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<64*64>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<64*64>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
case 128:
@@ -706,7 +714,7 @@ int main(int argc, char** argv) {
if(ctr)
encrypt_ctr<128*128>(seq2, seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,myrand,0);
else
- decrypt<128*128>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,myrand,0);
+ decrypt<128*128>(seq2,seq,len,RM1_copy,Pbox,PboxRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,myrand,0);
}
break;
}