From: Raphaƫl Couturier Date: Mon, 29 Jul 2019 09:58:01 +0000 (+0200) Subject: test substi X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/37beaada3c7aafc63b4e75fb4e37e2621c23caa3?ds=sidebyside;hp=e0ff6be80e2df6093b167083fe31538b9c97e470 test substi --- diff --git a/OneRoundIoT/EnhancedOneRound/Makefile b/OneRoundIoT/EnhancedOneRound/Makefile index da280af..59e7fc1 100644 --- a/OneRoundIoT/EnhancedOneRound/Makefile +++ b/OneRoundIoT/EnhancedOneRound/Makefile @@ -24,5 +24,8 @@ enhanced_oneround: pixmap_io.o enhanced_oneround.o $(CXX) -o $@ $^ $(CFLAGS) +test_substitution: test_substitution.o + $(CXX) -o $@ $^ $(CFLAGS) + clean: rm -rf *.o enhanced_oneround diff --git a/OneRoundIoT/EnhancedOneRound/test_substitution.cpp b/OneRoundIoT/EnhancedOneRound/test_substitution.cpp new file mode 100644 index 0000000..48ea63f --- /dev/null +++ b/OneRoundIoT/EnhancedOneRound/test_substitution.cpp @@ -0,0 +1,249 @@ +//gcc pixmap_io.c -c +//g++ -O3 one_round_new.cpp pixmap_io.o -o one_round_new -std=c++11 + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + + +int key_size=256; +int nb_test=1; +int cbcprng=0; +int cbcrm=0; +int ecbrm=0; +int ecbprng=0; + + + +typedef __uint64_t mylong; + + +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); +} + + + + +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; +} + + +mylong xorseed; + +mylong xorshift64() +{ + /* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */ + mylong x = xorseed; + x ^= x >> 12; // a + x ^= x << 25; // b + x ^= x >> 27; // c + + + return xorseed=x; +} + +/* +__uint128_t g_lehmer64_state; + +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); +} + + +inline void lehmer64_seed(uint64_t seed) { + g_lehmer64_state = (((__uint128_t)splitmix64_stateless(seed)) << 64) + + splitmix64_stateless(seed + 1); +} + +inline uint64_t lehmer64() { + g_lehmer64_state *= UINT64_C(0xda942042e4dd58b5); + ; + return g_lehmer64_state >> 64; +} + +*/ + + + +void inverse_tables(uchar *tab, int size_tab,uchar *inv_perm_tabs) { + + for(int i=0;i