Alex1 wrote:
The problem is that since it is not based on sound mathematics, we do not know if there are loops for some seeds or not. It would be necessary to test all the seeds of 1 to $FFFFFF and check if for each seed we obtain 2^32 bytes without loop. So you should run rng_test for each 2^32 seed.
Not quite. You can prove that the ADC chain goes through all possible states before repeating. That is this part, which has 32 bits.
Code:
ADD( s0, 0x45 );
ADC( s1, s0 );
ADC( s2, s1 );
ADC( s3, s2 );
This property breaks with the next line, because it has a feedback from s6, resulting in chaotic behavior and shorter loops.
Code:
ADC( s4, s3 ^ s6 );
Whatever happens in s4, s5, s6 is random, but s0-s3 are counting systematically. You can see this by skipping ahead 256 steps, and notice that every time s1 is incremented by same amount. This can be explained mathematically. Starting with s0=0, after 256 steps, the variable 's0' will be back at 0, having gone through every other number exactly once. That means that a value of 0+1+2+...+255 has been added to s1, which is equal to 255*256/2 = 32640 is equal to 128 modulo 256. So, without any carries, when s0 loops around, s1 will be 0x80 higher. Now, adding the carries, when you add 256 times 0x45, you will overflow exactly 0x45 times, producing 0x45 carries to s1. So, including the carries, s1 will be 0xc5 (mod 256) higher, and because that's an odd number, you need to repeat that 256 times before s1 is back at 0.
The same argument goes for s1->s2 and s2->s3.