-
+typedef __uint64_t ulong;
typedef unsigned char uchar;
return x;
}
-ulong xorshift64(ulong t)
+
+ulong xorseed;
+
+ulong xorshift64()
{
/* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */
- ulong x = t;
+ ulong x = xorseed;
x ^= x >> 12; // a
x ^= x << 25; // b
x ^= x >> 27; // c
- return x;
+ return xorseed=x;
}
+/*
__uint128_t g_lehmer64_state;
inline uint64_t splitmix64_stateless(uint64_t index) {
return g_lehmer64_state >> 64;
}
-
+*/
uchar Y[h];
uchar fX[h];
uchar gY[h];
- uchar RM1[h];
- uchar RM2[h];
+ uchar *RM1=&RM[0];
+ uchar *RM2=&RM[h];
uchar tmp[h];
ulong *rm1=(ulong*)RM1;
ulong *rm2=(ulong*)RM2;
+
+
for(int it=0;it<len/2;it++) {
int ind1=Pbox[it]*h;
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
uchar tmp[h];
ulong *rm1=(ulong*)RM1;
ulong *rm2=(ulong*)RM2;
+
for(int it=0;it<len/2;it++) {
int ind1=Pbox[it]*h;
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
uchar gY[h];
uchar IV1[h];
uchar IV2[h];
- uchar RM1[h];
- uchar RM2[h];
+ uchar *RM1=&RM[0];
+ uchar *RM2=&RM[h];
uchar tmp[h];
ulong *rm1=(ulong*)RM1;
ulong *rm2=(ulong*)RM2;
+
+
+
for(int it=0;it<len/2;it++) {
int ind1=Pbox[it]*h;
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
uchar gY[h];
uchar IV1[h];
uchar IV2[h];
- uchar RM1[h];
- uchar RM2[h];
+ uchar *RM1=&RM[0];
+ uchar *RM2=&RM[h];
+// uchar RM1[h];
+// uchar RM2[h];
uchar tmp[h];
ulong *rm1=(ulong*)RM1;
ulong *rm2=(ulong*)RM2;
for(int a=0;a<(h>>3);a++) {
- myrand=lehmer64();
+ myrand=xorshift64();
rm1[a]=myrand;
- myrand=lehmer64();
+ myrand=xorshift64();
rm2[a]=myrand;
}
inverse_tables(Sbox2,256,Inv_Sbox2);
-
- lehmer64_seed(myrand);
+ xorseed=myrand;
+// lehmer64_seed(myrand);
time_encrypt=0;
t=TimeStart();
store_RGB_pixmap("lena2.ppm", data_R, data_G, data_B, width, height);
}
-
- lehmer64_seed(myrand);
+
+ xorseed=myrand;
+ // lehmer64_seed(myrand);
time_decrypt=0;
t=TimeStart();
switch(h) {
}
-
return 0;
}