This will only affect the property based tests, not the test vectors
themselves. The idea is to let paranoid users run the test suite with
lots and lots of different streams of random numbers, just to be safe.
Test vector generation could undergo a similar transformation, though it
is less likely to be worth the trouble (we'd have to generate the test
vectors, compile the test suite all over again).
return status;
}
-int main(void)
+int main(int argc, char *argv[])
{
+ if (argc > 1) {
+ sscanf(argv[1], "%" PRIu64 "", &random_state);
+ }
+ printf("\nRandom seed: %" PRIu64 "\n", random_state);
+
int status = 0;
printf("\nTest against vectors");
printf("\n--------------------\n");
| ((u64)s[7] << 56);
}
+// Must be seeded with a nonzero value.
+// Accessible from the outside so we can modify it
+static u64 random_state = 12345;
+
// Pseudo-random 64 bit number, based on xorshift*
u64 rand64()
{
- static u64 x = 12345; // Must be seeded with a nonzero value.
- x ^= x >> 12;
- x ^= x << 25;
- x ^= x >> 27;
- return x * 0x2545F4914F6CDD1D; // magic constant
+ random_state ^= random_state >> 12;
+ random_state ^= random_state << 25;
+ random_state ^= random_state >> 27;
+ return random_state * 0x2545F4914F6CDD1D; // magic constant
}
void p_random(u8 *stream, size_t size)