java.lang.Object
io.github.olyutorskii.aletojio.bijection.Sbox8x4
All Implemented Interfaces:
RndInt32

public class Sbox8x4 extends Object implements RndInt32
S-box Bijection confusion.

Takes a 32-bit integer as input and outputs a confused 32-bit integer. Substitution is done in 8-bit units.

S-box of AES(Rijndael) is available. Any Sbox with 8bit-entry can be specified.

If there is a 1-bit change in the input, we can expect a 4-bit change from the output.

See Also:
  • Constructor Details

  • Method Details

    • mapRijndael

      public static int mapRijndael(int iVal)
      Map int value with Rijndael(AES) table.
      Parameters:
      iVal - int value
      Returns:
      mapped value
    • mapTable

      public static int mapTable(int iVal, int[] table)
      Map int value with specified S-box table.

      There is no bijection check.

      Parameters:
      iVal - int value
      table - S-box table
      Returns:
      mapped value
      Throws:
      NullPointerException - table is null
      IndexOutOfBoundsException - table is too small
    • checkSbox

      public static void checkSbox(int[] sboxArg) throws NullPointerException, IllegalArgumentException
      Check S-box table.

      S-box table length must be 256.

      S-box table must be bijection. (minimal perfect hash function)

      (sboxArg[253] = 119) means substitution from 253 to 119.

      Parameters:
      sboxArg - S-box table
      Throws:
      NullPointerException - null argument
      IllegalArgumentException - size unmatch or not bijection detected
    • nextInt32

      public int nextInt32()
      Return next random number as 32bit int with random sign-bit.
      Specified by:
      nextInt32 in interface RndInt32
      Returns:
      random number