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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/time.h>
+
+
+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<len;i++) {
+ sc[i]=i;
+ }
+ for (int it = 0; it < rp; it++) {
+ int j0 = 1;
+ for(int i0 = 0; i0<len; i0++) {
+ j0 = (j0 + sc[i0] + sc[j0] + key[i0%size_DK] )% len;
+ int tmp = sc[i0];
+ sc[i0] = sc[j0];
+ sc[j0] = tmp;
+ }
+
+ }
+}
+
+
+int main() {
+ printf("%d %d \n",sizeof(__uint64_t),sizeof(ulong));
+
+
+ uint64_t val=1021;
+ uint64_t val2=1021;
+
+ uint r1=21,r2=93;
+
+ uchar DK[64];
+ for(int i=0;i<64;i++)
+ DK[i]=splitmix64_stateless(i);
+
+
+ uchar Sbox1[256];
+ rc4key(DK, Sbox1, 8);
+ uchar Sbox2[256];
+ rc4key(&DK[8], Sbox2, 8);
+
+ const int bufsize=4096;
+ int Pbox[bufsize];
+ rc4keyperm(&DK[16], bufsize, 1, Pbox, 16);
+
+
+ int plain[bufsize];
+ int cipher[bufsize];
+
+
+
+ uint64_t Val[bufsize];
+ for(int i=0;i<bufsize;i++)
+ Val[i]=splitmix64_stateless(i+DK[i&63]);
+
+
+ int size=1000*16;
+ double t=TimeStart();
+ for(int iter=0;iter<size;iter++) {
+ for(int j=0;j<bufsize;j++) {
+ Val[j]^=xorshift64(Val[Pbox[j]])^plain[j];
+ }
+
+
+ if(iter%128==0) {
+
+ uchar *ptr=(uchar*)Val;
+ for(int j=0;j<bufsize*8;j++)
+ ptr[j]^=Sbox2[Sbox1[ptr[j]+DK[j&63]]];
+ rc4keyperm(ptr, bufsize, 1, Pbox, 16);
+
+ }
+ }
+
+ double time=TimeStop(t);
+ printf("time %e\n",size*bufsize*8/time);
+}