From c1233f272a367c9770d6e352b5018887c14a8c9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Couturier?= Date: Sun, 7 Jul 2019 17:41:55 +0200 Subject: [PATCH 1/1] new hash version --- OneRoundIoT/OneRound/Makefile | 5 + OneRoundIoT/OneRound/one_round_hash_new3.cpp | 398 +++++++++++++++++++ 2 files changed, 403 insertions(+) create mode 100644 OneRoundIoT/OneRound/one_round_hash_new3.cpp diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile index 2b99c8a..a300f32 100644 --- a/OneRoundIoT/OneRound/Makefile +++ b/OneRoundIoT/OneRound/Makefile @@ -39,6 +39,8 @@ one_round_hash_new.o: one_round_hash_new.cpp one_round_hash_new2.o: one_round_hash_new2.cpp $(CXX) -c -o $@ $< $(CFLAGS) +one_round_hash_new3.o: one_round_hash_new3.cpp + $(CXX) -c -o $@ $< $(CFLAGS) one_round_par2.o: one_round_par2.cpp @@ -67,6 +69,9 @@ one_round_hash_new: pixmap_io.o one_round_hash_new.o one_round_hash_new2: pixmap_io.o one_round_hash_new2.o $(CXX) -o $@ $^ $(CFLAGS) +one_round_hash_new3: pixmap_io.o one_round_hash_new3.o + $(CXX) -o $@ $^ $(CFLAGS) + one_round_auth: pixmap_io.o one_round_auth.o $(CXX) -o $@ $^ $(CFLAGS) diff --git a/OneRoundIoT/OneRound/one_round_hash_new3.cpp b/OneRoundIoT/OneRound/one_round_hash_new3.cpp new file mode 100644 index 0000000..f7c622d --- /dev/null +++ b/OneRoundIoT/OneRound/one_round_hash_new3.cpp @@ -0,0 +1,398 @@ +//gcc pixmap_io.c -c +//g++ -O3 one_round_hash_new.cpp pixmap_io.o -o one_round_hash_new -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> (8 - n));} + + +//the proposed hash function, which is based on DSD structure. Sensitivity is ensured by employing the binary diffusion + +void hash_DSD_BIN(uchar* seq_in, uchar* RM1,int len, int *Pbox,int *PboxRM, uchar *Sbox1, uchar *Sbox2, int h) { + + + // Goal: Calculate the hash value + // Output: RM (hash value) + +// uchar *X=new uchar[h2]; +// uchar *fX=new uchar[h2]; + uchar X[h]; + int ind1,ind2; + + + + for(int it=0;it