From: Raphaƫl Couturier Date: Fri, 28 Feb 2020 15:27:41 +0000 (+0100) Subject: new X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/121b99635da1e62a424bea25d9d54fb0845cba43?ds=inline;hp=a3e6fe442440811ebd5f7288bf01d9782f3a7ea7 new --- diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile index 42d5774..250dc55 100644 --- a/OneRoundIoT/OneRound/Makefile +++ b/OneRoundIoT/OneRound/Makefile @@ -78,8 +78,11 @@ rc4_hash: pixmap_io.o rc4_hash.o rc4_hash2: pixmap_io.o rc4_hash2.o $(CXX) -o $@ $^ $(CFLAGS) +rc4_hash3: pixmap_io.o rc4_hash3.o + $(CXX) -o $@ $^ $(CFLAGS) + one_round_auth: pixmap_io.o one_round_auth.o $(CXX) -o $@ $^ $(CFLAGS) clean: - rm -rf *.o one_round_new one_round_hash one_round_par2 one_round_hash_new rc4_hash rc4_hash2 one_round_steph + rm -rf *.o one_round_new one_round_hash one_round_par2 one_round_hash_new rc4_hash rc4_hash2 rc4_hash3 one_round_steph diff --git a/OneRoundIoT/OneRound/rc4_hash3.cpp b/OneRoundIoT/OneRound/rc4_hash3.cpp new file mode 100644 index 0000000..5c9061c --- /dev/null +++ b/OneRoundIoT/OneRound/rc4_hash3.cpp @@ -0,0 +1,419 @@ +//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));} + + +uint64_t xorshift64( const uint64_t state) +{ + uint64_t x = state; + x^= x << 13; + x^= x >> 7; + x^= x << 17; + return x; +} +uint xorshift32(const uint t) +{ + /* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */ + uint x = t; + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + return x; +} + +static inline uint64_t splitmix64(uint64_t index) { + uint64_t z = (index + UINT64_C(0x9E3779B97F4A7C15)); + z = (z ^ (z >> 30)) * UINT64_C(0xBF58476D1CE4E5B9); + z = (z ^ (z >> 27)) * UINT64_C(0x94D049BB133111EB); + return z ^ (z >> 31); +} + + + + + + + +//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, uchar *S, 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; + + + uint32_t *rm=(uint32_t*)RM1; + uint32_t *xx=(uint32_t*)X; + uint32_t *ss=(uint32_t*)seq_in; + + + + for(int it=0;it