'Is there a easy algortihm to make a 8 bit s-box?

I want to make a 8 bit s-box using 4 bit s-box. So is there any easy, understandable algorithm or source to help me?



Solution 1:[1]

There is always an easy one, however, that is not guaranteed to carry the security.

  • 4-bit SBox has 4-bit input and 4-bit output. So we can consider that as an array of size 16' S16[16]

  • 8-bit SBox has 8-bit input and 8-bit output. So we can consider that as an array of size 64' S64[64]

Initially, we can copy 4 copies of S16 into S64, however, that won't be a good SBox and the inverse will be failed.

Now, we can use the extra 4-bit to modify the 2,3, and 4 copies as

   # copy the 4-Box directly
   for i in range(0..16):
       S64[i] = S16[i]  

   #  Add 16 the 4-Box's elements then assign
   for i in range(16..32):
       S64[i] = S16[i-16] *2

   #  Now add 32 to the first half then assign.
   for i in range(32..64):
       S64[i] = 32 + S64[i-32] ```

So

  • the 1st quarter has elements in the range [ 0,15]
  • the 2nd quarter has elements in the range [16,31]
  • the 3rd quarter has elements in the range [32,47]
  • the 4th quarter has elements in the range [48,64]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kelalaka