X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/a85d220dc28f5751320089246cc879fbf88686ef..93c9fc23c87b5d3709be87d0f64f5fca0e424691:/OneRoundIoT/OneRound/one_round_hash_new3.cpp diff --git a/OneRoundIoT/OneRound/one_round_hash_new3.cpp b/OneRoundIoT/OneRound/one_round_hash_new3.cpp index b14d819..5e9bf8a 100644 --- a/OneRoundIoT/OneRound/one_round_hash_new3.cpp +++ b/OneRoundIoT/OneRound/one_round_hash_new3.cpp @@ -1,7 +1,7 @@ //gcc pixmap_io.c -c //g++ -O3 one_round_hash_new.cpp pixmap_io.o -o one_round_hash_new -std=c++11 -// +//comparison with cmac #include <iostream> @@ -126,7 +126,7 @@ void prga(uchar *sc, int ldata, uchar *r) { uchar j0=0; for (int it=0; it<ldata; it++) { - i0 = ((i0+1)&0xFE); //%255); + i0 = ((i0+1)%255); j0 = (j0 + sc[i0])&0xFF; uchar tmp = sc[i0]; sc[i0] = sc[j0]; @@ -163,30 +163,14 @@ void hash_DSD_BIN(uchar* seq_in, uchar* RM1,int len, int *Pbox,int *PboxRM, ucha // Mix with dynamic RM - /* + for(int a=0;a<h;a+=4) { RM1[a]=Sbox1[RM1[a]^seq_in[ind1+a]]^seq_in[ind2+a]; RM1[a+1]=Sbox1[RM1[a+1]^seq_in[ind1+a+1]]^seq_in[ind2+a+1]; RM1[a+2]=Sbox1[RM1[a+2]^seq_in[ind1+a+2]]^seq_in[ind2+a+2]; RM1[a+3]=Sbox1[RM1[a+3]^seq_in[ind1+a+3]]^seq_in[ind2+a+3]; } - */ - for(int a=0;a<h;a+=4) { - RM1[a]=RM1[a]^seq_in[ind1+a]; - RM1[a+1]=RM1[a+1]^seq_in[ind1+a+1]; - RM1[a+2]=RM1[a+2]^seq_in[ind1+a+2]; - RM1[a+3]=RM1[a+3]^seq_in[ind1+a+3]; - } - - for(int a=0;a<h;a+=4) { - RM1[a]=Sbox1[RM1[a]]^seq_in[ind2+a]; - RM1[a+1]=Sbox1[RM1[a+1]]^seq_in[ind2+a+1]; - RM1[a+2]=Sbox1[RM1[a+2]]^seq_in[ind2+a+2]; - RM1[a+3]=Sbox1[RM1[a+3]]^seq_in[ind2+a+3]; - } - - for(int a=0;a<h;a+=4) { @@ -234,9 +218,9 @@ int main(int argc, char** argv) { } - cout<<size_buf<<endl; - int seed=time(NULL); - cout<<seed<<endl; + // cout<<size_buf<<endl; + int seed=12;//time(NULL); + // cout<<seed<<endl; srand48(seed); uchar Secretkey[key_size]; @@ -297,7 +281,7 @@ int main(int argc, char** argv) { } } - printf("seq 4 %d\n",seq[4]); + //printf("seq 4 %d\n",seq[4]); if(change==1) { seq[4]++; @@ -307,7 +291,7 @@ int main(int argc, char** argv) { seq[9]++; } - printf("seq 4 %d\n",seq[4]); + // printf("seq 4 %d\n",seq[4]); @@ -315,7 +299,7 @@ int main(int argc, char** argv) { int total_len=imsize; int rp=1; int len= total_len/h; - cout<<len<<endl; + //cout<<len<<endl; uchar *mix=new uchar[256]; @@ -367,7 +351,7 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); time+=TimeStop(t); - cout<<"Time initializaton "<<time<<endl; + // cout<<"Time initializaton "<<time<<endl; @@ -383,7 +367,7 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); RM2[i]=RM1[i]; } - cout<<"imsize "<<imsize<<endl; + // cout<<"imsize "<<imsize<<endl; /* for(int i=0;i<imsize;i++){ cout<<(int)seq[i]<<" "; @@ -402,13 +386,13 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); time+=TimeStop(t); - cout<<"Hash Time "<<time<<endl; + // cout<<"Hash Time "<<time<<endl; cout<<(double)imsize*nb_test/time<<"\t"; - for(int i=0;i<h;i++){ + /* for(int i=0;i<h;i++){ cout<<(int)RM1[i]<<" "; - } - cout<<endl; + }*/ + // cout<<endl;