# RC4 via nonlinear mixer -- sound?

We implemented a rc4 (ARC4) variant for creating a cryptographic stream - question is: Is this sound?

(I'll give an example for 32 bit variant, though 64 bit/larger is possible)

Algorithm is as follows:
We have an array of integers A (32 bit) and array of 8 bit numbers B. Perform a round of rc4 to mix the B array positions.

We then shift the values of B into A, ie for 0..255, A[i]=(A[i]<<8)|B[i]; We rerun that 4 times such that each integer has 32 bits of random positions.

We keep A and B, we then pass the B keystream (arc4) through the A mixer.
Given a 32 bit value of "hash":

      hash = (hash>>8) ^ A[ arc4(B) ];


Thus the 8 bit arc4 is looking up 32 bit values, and XORing with the previous value of hash. We then say the

       output= (hash)&0xff;


The output of the stream then is a nonlinear mix of the last 4 values of the arc4 algorithm.

Question: Would this 'fix' the rc4/arc4 holes/issues that have been reported?

What is the cryptographic opinion of the community on the soundness of this algorithm?

Many thanks.

• "What is the cryptographic opinion of the community on the soundness of this algorithm?" - Don't roll your own crypto. If you need a stream cipher did you take a look at Salsa20, ChaCha or AES-CTR?
– SEJPM
Aug 21 '15 at 12:28
• I can see a description of a cipher based on RC4 and I see that you know about attacks on RC4. What I'm missing is a description on how you think your changes avoid the attacks on RC4. This we could use as a base for cryptanalysis. If you just make random changes (pun intended) then you will probably not succeed in creating a more secure cipher. Aug 21 '15 at 21:32
• We had thought, removing biases. Using array A we have effectively done a "drop 1024" to remove initial weakness of key scheduling. Any statistical bias for certain ranges should be removed by the the fact the current output is the product of the last 4 inputs, with each input having its own substitution. Substitution table also being pseudorandom. Runtime processing required an extra hash and output (4 logic instructions) to strengthen. With our non-expert view, it seemed that would knock out biases and correlation. However, we were curious to hear what the experts thought. Aug 21 '15 at 21:59