From 5fac2bf4cccbb19b96848db07686fd7a5d7bf8d7 Mon Sep 17 00:00:00 2001 From: couturie Date: Sun, 9 Dec 2018 10:58:17 +0100 Subject: [PATCH] new --- .../EnhancedOneRound/enhanced_oneround.cpp | 297 ++---------------- 1 file changed, 24 insertions(+), 273 deletions(-) diff --git a/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp b/OneRoundIoT/EnhancedOneRound/enhanced_oneround.cpp index 13971e6..db3d98c 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