From a1ac08a57a9e6c12c850494de412941edf7dbdf9 Mon Sep 17 00:00:00 2001 From: couturie Date: Sat, 16 Feb 2019 10:28:21 +0100 Subject: [PATCH] new --- IDA/Makefile | 20 ++++-- OneRoundIoT/NEW/test.c | 146 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 OneRoundIoT/NEW/test.c diff --git a/IDA/Makefile b/IDA/Makefile index f34a69b..89f8e9e 100644 --- a/IDA/Makefile +++ b/IDA/Makefile @@ -3,20 +3,26 @@ CPP_FLAGS= -fopenmp -O3 -lc -lm -LIBS= -larmadillo -lopenblas -test_mat2: test_mat2.cpp - g++ -std=c++11 $(CPP_FLAGS) -o $@ $< $(LIBS) +C_INCLUDE=gf-complete/include/ +#LIBS= -larmadillo -lopenblas -ida: ida.cpp - g++ -std=c++11 $(CPP_FLAGS) -o $@ $< $(LIBS) +#test_mat2: test_mat2.cpp +# g++ -std=c++11 $(CPP_FLAGS) -o $@ $< $(LIBS) + +#ida: ida.cpp +# g++ -std=c++11 $(CPP_FLAGS) -o $@ $< $(LIBS) ida_gf64: ida_gf64.cpp g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -I/home/couturie/ajeter/jerasure/include /home/couturie/ajeter/jerasure/src/.libs/jerasure.o /home/couturie/ajeter/jerasure/src/.libs/galois.o -lgf_complete -fpermissive ida_gf65: ida_gf65.cpp - g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -I/home/couturie/ajeter/jerasure/include /home/couturie/ajeter/jerasure/src/.libs/jerasure.o /home/couturie/ajeter/jerasure/src/.libs/galois.o -lgf_complete -fpermissive -lpthread + g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -Ijerasure/include jerasure/src/.libs/jerasure.o jerasure/src/.libs/galois.o -lgf_complete -fpermissive -lpthread -I $(C_INCLUDE) + + +ida_gf65_paper1: ida_gf65_paper1.cpp + g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -Ijerasure/include jerasure/src/.libs/jerasure.o jerasure/src/.libs/galois.o -lgf_complete -fpermissive -lpthread -I $(C_INCLUDE) clean: - rm test_mat2 ida ida_gf64 + rm test_mat2 ida ida_gf64 ida_gf65_paper1 diff --git a/OneRoundIoT/NEW/test.c b/OneRoundIoT/NEW/test.c new file mode 100644 index 0000000..a074ec9 --- /dev/null +++ b/OneRoundIoT/NEW/test.c @@ -0,0 +1,146 @@ +#include +#include +#include +#include + + +typedef unsigned char uchar; + +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_stateless(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); +} + +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); +} + + +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; +} + + +void rc4key(uchar *key, uchar *sc, int size_DK) { + + for(int i=0;i<256;i++) { + sc[i]=i; + } + + + uchar j0 = 0; + for(int i0=0; i0<256; i0++) { + j0 = (j0 + sc[i0] + key[i0%size_DK] )&0xFF; + uchar tmp = sc[i0]; + sc[i0] = sc[j0 ]; + sc[j0] = tmp; + } +} + + +void rc4keyperm(uchar *key,int len, int rp,int *sc, int size_DK) { + + //sc=1:len; + + + + for (int i=0;i