X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/3ec5ac6eaae843080a637d31fe99abea7c327f94..c1233f272a367c9770d6e352b5018887c14a8c9c:/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp?ds=sidebyside diff --git a/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp b/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp index 13971e6..c895a8a 100644 --- a/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp +++ b/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp @@ -197,8 +197,8 @@ void encrypt_ecb_prng(uchar* seq_in, uchar *seq_out, int len,uchar* RM, int *Pbo uchar Y[h]; uchar fX[h]; uchar gY[h]; - uchar *RM1=&RM[0]; - uchar *RM2=&RM[h]; + uchar RM1[h]; + uchar RM2[h]; uchar tmp[h]; mylong *rm1=(mylong*)RM1; mylong *rm2=(mylong*)RM2; @@ -487,7 +487,7 @@ void encrypt_ecb_rm(uchar* seq_in, uchar *seq_out, int len,uchar* RM, int *Pbox, RM1=&RM[PboxSRM[it]*h]; - RM2=&RM[h*h+PboxSRM[len/2-it]*h]; + RM2=&RM[h*h+PboxSRM[len/2-it-1]*h]; @@ -629,7 +629,7 @@ void decrypt_ecb_rm(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox RM1=&RM[PboxSRM[it]*h]; - RM2=&RM[h*h+PboxSRM[len/2-it]*h]; + RM2=&RM[h*h+PboxSRM[len/2-it-1]*h]; @@ -1133,14 +1133,19 @@ void encrypt_cbc_rm(uchar* seq_in, uchar *seq_out, int len,uchar* RM, int *Pbox, } + + for(int it=0;it -void encrypt_cbc(uchar* seq_in, uchar *seq_out, int len,uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uint myrand, int debug) { - - uchar X[h]; - uchar Y[h]; - uchar fX[h]; - uchar gY[h]; - uchar IV1[h]; - uchar IV2[h]; - uchar *RM1; - uchar *RM2; - - int h2=h*h; - - - - - for(int a=0;a>=8; - IV1[a+1]=(mm&255); - mm>>=8; - IV1[a+2]=(mm&255); - mm>>=8; - IV1[a+3]=(mm&255); - } - - for(int a=0;a>=8; - IV2[a+1]=(mm&255); - mm>>=8; - IV2[a+2]=(mm&255); - mm>>=8; - IV2[a+3]=(mm&255); - - } - - - - for(int it=0;it -void decrypt_cbc(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uchar *Inv_Sbox1, uchar *Inv_Sbox2, uint myrand, int debug) { - - uchar invfX[h]; - uchar invgY[h]; - uchar fX[h]; - uchar gY[h]; - uchar IV1[h]; - uchar IV2[h]; - uchar *RM1; - uchar *RM2; - - for(int a=0;a>=8; - IV1[a+1]=(mm&255); - mm>>=8; - IV1[a+2]=(mm&255); - mm>>=8; - IV1[a+3]=(mm&255); - } - - for(int a=0;a>=8; - IV2[a+1]=(mm&255); - mm>>=8; - IV2[a+2]=(mm&255); - mm>>=8; - IV2[a+3]=(mm&255); - - } - - - - - - - for(int it=0;it