X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/fb1c4ba527de0eaf2f035d1124b53f8efa7dfcc8..aab4f66d038fc5892e7ff9fb280f8c6d0c858b66:/OneRoundIoT/OneRound/one_round_new.cpp diff --git a/OneRoundIoT/OneRound/one_round_new.cpp b/OneRoundIoT/OneRound/one_round_new.cpp index f5546cf..b7940af 100644 --- a/OneRoundIoT/OneRound/one_round_new.cpp +++ b/OneRoundIoT/OneRound/one_round_new.cpp @@ -135,7 +135,7 @@ void prga(uchar *sc, int ldata, uchar *r) { uchar j0=0; for (int it=0; it>=8; + X[a+1]=Sbox1[mm&255]; + mm>>=8; + X[a+2]=Sbox2[mm&255]; + mm>>=8; + X[a+3]=Sbox1[mm&255]; } @@ -198,16 +204,16 @@ 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; }