We have given 16 bytes and apply some order to them. For example sorting them by their absolute value.
We want to obfuscate them as best as possible while maintaining their order. That means if we apply the order function after the obfuscation (e.g. sorting them) nothing should change.
If it did not work out we are allowed to obfuscate them again until they are in order.
This should happen as least as possible.
Need to be bijective, so applying the inverse obfuscation function at the result will end up where we started in forward direction.
For variation of the obfuscation function we have given a 128-bit value $x$ (which also needed to be obfuscated at the very end, order not relevant for that).
Example (which needs too many operations)
Let $B_s$ be our 16-bytes in sorted order. We can use AES for obfuscation $$AES(x,B_s) = c$$ Apply xor on it $$B_{x} = c \oplus B_s$$ To make them less dependent again we apply AES again $$AES^{-1}(x,B_x) = x'$$
If $B_x$ is in order we end. If not we repeat those 3 calculations until it is (starts with $AES(x',B_x)$ this time).
This will (mostly) work out but will take way too long. If all bytes are different chance are only $\approx 1:2^{44}$ to be in order.
Can we do (much) better? Looking for something as quick as possible. $< 2^{16}$ trials wood be ok. The smaller the better.
Further requirements:
- Obfuscation by just a constant or a single variable or just $\pm 1$ for all bytes is not enough obfuscation.
- Obfuscation need to depend on the 2nd input $x$.
- Chosen order need to be well specified unless two bytes are equal it need to be deterministic if byte $a$ stands before or after byte $b$
- Doing obfuscation $n$ times should not be able to be simplified to compute it much faster than doing it $n$ times. Even with knowing all runtime variables.
- (Variance of trials not too high)
Allowed:
- The order function used before the forward obfuscation function does not need to be equal to the order function of the result or in other words the order function applied before doing the inverse obfuscation function. So e.g. we could start with bytes sorted ascending and end with bytes sorted descending.
Some weakening
Best would be as described above but to higher the chances we could split the 16-bytes in two groups of 8 bytes each. Order only need to be maintained inside those groups. Further order group splitting not allowed.
Doing this with the top approach highers the chances to $~ 1:2^{30}$. Still too long. With the weakening it should not take longer than $2^{6}$ trials.
Yes, obfuscation and maintaining are in conflict to each other.