From: Raphaƫl Couturier Date: Fri, 28 Feb 2020 13:33:16 +0000 (+0100) Subject: rc4_hash2 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/a3e6fe442440811ebd5f7288bf01d9782f3a7ea7?hp=75e626fcb74674b211ce19ce7f299449690c3775 rc4_hash2 --- diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile index 4eb5c44..42d5774 100644 --- a/OneRoundIoT/OneRound/Makefile +++ b/OneRoundIoT/OneRound/Makefile @@ -75,8 +75,11 @@ one_round_hash_new3: pixmap_io.o one_round_hash_new3.o rc4_hash: pixmap_io.o rc4_hash.o $(CXX) -o $@ $^ $(CFLAGS) +rc4_hash2: pixmap_io.o rc4_hash2.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 one_round_steph + rm -rf *.o one_round_new one_round_hash one_round_par2 one_round_hash_new rc4_hash rc4_hash2 one_round_steph diff --git a/OneRoundIoT/OneRound/one_round_hash_new2.cpp b/OneRoundIoT/OneRound/one_round_hash_new2.cpp index 25bcb17..ae346fe 100644 --- a/OneRoundIoT/OneRound/one_round_hash_new2.cpp +++ b/OneRoundIoT/OneRound/one_round_hash_new2.cpp @@ -126,7 +126,7 @@ void prga(uchar *sc, int ldata, uchar *r) { uchar j0=0; for (int it=0; it @@ -126,7 +126,7 @@ void prga(uchar *sc, int ldata, uchar *r) { uchar j0=0; for (int it=0; it +#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; +} + + +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; + + + uint64_t *rm=(uint64_t*)RM1; + uint64_t *xx=(uint64_t*)X; + uint64_t *ss=(uint64_t*)seq_in; + + + + for(int it=0;it