X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/baa3ba339cf98c71a013ab96c1af552e82470efe..c7332dbd02656103b98fd5ac66fb342388055677:/OneRoundIoT/OneRound/one_round_new.cpp diff --git a/OneRoundIoT/OneRound/one_round_new.cpp b/OneRoundIoT/OneRound/one_round_new.cpp index 95c602e..b394646 100644 --- a/OneRoundIoT/OneRound/one_round_new.cpp +++ b/OneRoundIoT/OneRound/one_round_new.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -27,10 +28,12 @@ using namespace std; int key_size=256; +int nb_test=1; +int ctr=0; + + -const int h=16; -const int h2=h*h; @@ -66,6 +69,14 @@ void inverse_tables(uchar *tab, int size_tab,uchar *inv_perm_tabs) { } +void inverse_tables_int(int *tab, int size_tab,int *inv_perm_tabs) { + + for(int i=0;i +void encrypt_ctr(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, int *PboxRM, uchar *Sbox1, uchar *Sbox2, int enc) { + + +// uchar *X=new uchar[h2]; +// uchar *fX=new uchar[h2]; + uchar X[h2]; + uchar fX[h2]; + + int ind1,ind2; + + + for(int a=0;a void encrypt(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, int *PboxRM, uchar *Sbox1, uchar *Sbox2, int debug) { uchar *X=new uchar[h2]; uchar *fX=new uchar[h2]; - + unsigned int *lX=(unsigned int*)X; + unsigned int *lseq_in=(unsigned int*)seq_in; + + for(int it=0;it void decrypt(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, int *PboxRM, uchar *Sbox1, uchar *Sbox2, int debug) { @@ -190,22 +322,38 @@ void decrypt(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, int *P - for(int a=0;a(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1); + else + encrypt<4*4>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0); + + } + break; + case 8: + for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1); + else + encrypt<8*8>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0); + + } + break; + case 16: + for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1); + else + encrypt<16*16>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0); + + } + break; + case 32: + for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1); + else + encrypt<32*32>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0); + + } + break; + case 64: + for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1); + else + encrypt<64*64>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0); + + } + break; } - time+=TimeStop(t); cout<<"Time encrypt "<(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + else + decrypt<4*4>(seq2,seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + } + break; + case 8: + for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + else + decrypt<8*8>(seq2,seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + } + break; + case 16: + for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + else + decrypt<16*16>(seq2,seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + } + break; + case 32: + for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + else + decrypt<32*32>(seq2,seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + } + break; + case 64: + for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + else + decrypt<64*64>(seq2,seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0); + } + break; } time+=TimeStop(t); cout<<"Time decrypt "<