X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/9bacefcf0e04c26e8c02d9d8871dd42ad1d80490..e38c16ec01bf23e02c6bc0c7ee5d046f253125d1:/OneRoundIoT/OneRound/one_round_new.cpp?ds=inline
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;
}