From b3af72beed65e8fac2833f54ed3a0dde34886548 Mon Sep 17 00:00:00 2001 From: couturie Date: Fri, 15 Sep 2017 19:51:19 +0200 Subject: [PATCH] new --- OneRoundIoT/OneRound/Makefile | 14 +- OneRoundIoT/OneRound/one_round_hash.cpp | 465 +++++++++++++++ OneRoundIoT/OneRound/one_round_new.cpp | 9 +- OneRoundIoT/OneRound/one_round_par.cpp | 761 ------------------------ 4 files changed, 477 insertions(+), 772 deletions(-) create mode 100644 OneRoundIoT/OneRound/one_round_hash.cpp delete mode 100644 OneRoundIoT/OneRound/one_round_par.cpp diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile index 8f0c0cf..cb01d4f 100644 --- a/OneRoundIoT/OneRound/Makefile +++ b/OneRoundIoT/OneRound/Makefile @@ -21,9 +21,10 @@ one_round_new.o: one_round_new.cpp $(CXX) -c -o $@ $< $(CFLAGS) +one_round_hash.o: one_round_hash.cpp + $(CXX) -c -o $@ $< $(CFLAGS) + -one_round_par.o: one_round_par.cpp - $(CXX) -fopenmp -c -o $@ $< $(CFLAGS) one_round_par2.o: one_round_par2.cpp $(CXX) -fopenmp -c -o $@ $< $(CFLAGS) @@ -31,12 +32,13 @@ one_round_par2.o: one_round_par2.cpp one_round_new: pixmap_io.o one_round_new.o $(CXX) -o $@ $^ $(CFLAGS) -one_round_par: pixmap_io.o one_round_par.o - $(CXX) -fopenmp -o $@ $^ $(CFLAGS) - one_round_par2: pixmap_io.o one_round_par2.o $(CXX) -fopenmp -o $@ $^ $(CFLAGS) + +one_round_hash: pixmap_io.o one_round_hash.o + $(CXX) -o $@ $^ $(CFLAGS) + clean: - rm -rf *.o one_round_new one_round_par one_round_par2 + rm -rf *.o one_round_new one_round_hash one_round_par2 diff --git a/OneRoundIoT/OneRound/one_round_hash.cpp b/OneRoundIoT/OneRound/one_round_hash.cpp new file mode 100644 index 0000000..c04dfda --- /dev/null +++ b/OneRoundIoT/OneRound/one_round_hash.cpp @@ -0,0 +1,465 @@ +//gcc pixmap_io.c -c +//g++ -O3 one_round_test.cpp pixmap_io.o -o one_round_test -std=c++11 + +#include +#include +#include +#include +#include +#include +#include +#include + +/*#include +#include +#include +#include +*/ + + +extern "C" { + int load_RGB_pixmap(char *filename, int *width, int *height, unsigned char**R_data, unsigned char**G_data, unsigned char**B_data); + void store_RGB_pixmap(char *filename, unsigned char *R_data, unsigned char *G_data, unsigned char *B_data, int width, int height); +} + + +//using namespace CryptoPP; +using namespace std; + + +int key_size=256; +int nb_test=1; +int ctr=0; + + + + + + + +typedef unsigned char uchar; + + +double TimeStart() +{ + struct timeval tstart; + gettimeofday(&tstart,0); + return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) ); +} + +double TimeStop(double t) +{ + struct timeval tend; + + gettimeofday(&tend,0); + t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t; + return (t); +} + + + + + + +void inverse_tables(uchar *tab, int size_tab,uchar *inv_perm_tabs) { + + for(int i=0;i -#include -#include -#include -#include -#include -#include -#include -#include - -/*#include -#include -#include -#include -*/ - - -extern "C" { - int load_RGB_pixmap(char *filename, int *width, int *height, unsigned char**R_data, unsigned char**G_data, unsigned char**B_data); - void store_RGB_pixmap(char *filename, unsigned char *R_data, unsigned char *G_data, unsigned char *B_data, int width, int height); -} - - -//using namespace CryptoPP; -using namespace std; - - -int key_size=256; -int nb_test=1; -int ctr=0; - - - - - - - -typedef unsigned char uchar; - - -double TimeStart() -{ - struct timeval tstart; - gettimeofday(&tstart,0); - return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) ); -} - -double TimeStop(double t) -{ - struct timeval tend; - - gettimeofday(&tend,0); - t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t; - return (t); -} - - - - - - -void inverse_tables(uchar *tab, int size_tab,uchar *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, int num) { - - - uchar X[h2]; - uchar fX[h2*num]; - uchar RM2[h2*num]; - - - - - 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, int num) { - - -/* uchar *X=new uchar[h2]; - uchar *fX=new uchar[h2]; - unsigned int *lX=(unsigned int*)X; - unsigned int *lseq_in=(unsigned int*)seq_in; -*/ - uchar X[h2*num]; - uchar fX[h2*num]; - uchar RM2[h2*num]; -// unsigned int *lX=(unsigned int*)X; -// unsigned int *lseq_in=(unsigned int*)seq_in; - -#pragma omp parallel for - for(int it=0;it -void decrypt(uchar* seq_in, uchar *seq_out, int len,uchar* RM1,int *Pbox, int *PboxRM, uchar *Inv_Sbox1, uchar *Inv_Sbox2, int debug, int num) { - - - /*uchar *fX=new uchar[h2]; - uchar *Inv_Sbox1=new uchar[256]; - uchar *Inv_Sbox2=new uchar[256]; - */ - uchar fX[h2*num]; - uchar RM2[h2*num]; - -#pragma omp parallel for - for(int it=0;it(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<4*4>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - case 8: - for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<8*8>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - case 16: - for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<16*16>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - case 32: - for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<32*32>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - case 64: - for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<64*64>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - case 128: - for(i=0;i(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,1,num); - else - encrypt<128*128>(seq, seq2,len,RM1,Pbox,PboxRM,Sbox1,Sbox2,0,num); - - } - break; - } - time+=TimeStop(t); - cout<<"Time encrypt "<(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<4*4>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - case 8: - for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<8*8>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - case 16: - for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<16*16>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - case 32: - for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<32*32>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - case 64: - for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<64*64>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - case 128: - for(i=0;i(seq2, seq,len,RM2,Pbox,PboxRM,Sbox1,Sbox2,0,num); - else - decrypt<128*128>(seq2,seq,len,RM2,Pbox,PboxRM,Inv_Sbox1,Inv_Sbox2,0,num); - } - break; - - - } - - time+=TimeStop(t); - cout<<"Time decrypt "<