Assuming a bit string is deemed cryptographically secure, e.g. PRNG using AES in counter mode, can we equally assume any permutation of said bit string is also cryptographically secure?

In a more practical sense, using a PRNG with AES in counter mode again (for instance), assume it turns out that AES can be more efficiently computed by permutating the input data and rearranging the implementation of the algorithm accordingly. Does the resulting pseudorandom bit string need to be permutated back to the correct order or can I use it directly as a cryptographically secure bitstring? (this is from a purely theoretical pov.)

PS: I used AES as an example, it could be any secure block cipher.

PS2: sorry about the sloppy use of technical terms, but I hope you will understand what I mean.

  • 2
    $\begingroup$ Any permutation ... is cryptographically secure? NO. A specific permutation is cryptographically secure? Possibly so, but careful evaluation needs to be done. $\endgroup$ Mar 12, 2012 at 1:03

1 Answer 1


Yes, an additional bit permutation of pseudo-random data from a secure Pseudo-Random Number Generator is secure, subject to the condition that this bit permutation is independent of the key material of the PRNG and of any data derived from that (including the pseudo-random data).

An argument is that if this permutation is public, the adversary can do/undo it at negligible cost and is back to the original problem of breaking the PRNG (with no usable information, given the sated condition); if this permutation is secret, its addition can only be an additional complexity for the attacker (given the stated condition). That could be formalized.

If the stated condition is not met, a counterexample can often be found. For example, if the permutation is chosen from the output of the original PRNG so as to put all the 0 bits first, then the output is weak. Same if the permutation is part of the key of a cipher, with the cipher ending in that permutation, and the cipher transformed into a PRNG by using counter mode.

  • 3
    $\begingroup$ Thanks for the help, I am using a public (constant) permutation to perform some optimizations. For instance, interleaving the input to a Threefish cipher allows the cipher to be completely vectorized, and if I'm using it as a PRNG it means I don't need to spend time reversing the permutation at the end. Thanks! $\endgroup$
    – Thomas
    Mar 12, 2012 at 7:44
  • 1
    $\begingroup$ FWIW, turns out it can be done with the same amount of permutations while implicitly restoring the correct order at the end anyway. It was a headache combining the different permutation vectors though. And I am not doing that for the 512 and 1024 versions! $\endgroup$
    – Thomas
    Apr 7, 2012 at 14:36
  • $\begingroup$ +1, but a question: if the run time can be consistently affected like @Thomas describes, could this open side-channel timing attacks that the original implementation is safe from? $\endgroup$
    – orip
    Aug 27, 2012 at 20:06
  • $\begingroup$ @orip: most implementations of bit permutations (be it in software or hardwired) have no timing dependency on the value of the data bits permuted. Therefore adding a final permutation after something without timing dependency should leave it without timing dependency. The same should hold in practice for REMOVING a final permutation, whenever there exist a simple architecture-independent proof that the original algorithm exhibits no data-dependent timing. $\endgroup$
    – fgrieu
    Aug 28, 2012 at 7:23
  • $\begingroup$ @fgrieu I was interested in Thomas's experience of affecting (in his case, accelerating) Threefish's performance. Could this expose a timing attack not on the permutation, but on the cipher itself? $\endgroup$
    – orip
    Aug 28, 2012 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.