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

public class Pbox32 extends Object implements RndInt32
P-box diffusion by bit permutation.

Takes a 32-bit integer as input and outputs a diffused 32-bit integer.

See Also:
  • Constructor Details

  • Method Details

    • mapPermutation

      public static int mapPermutation(int iVal)
      Map int value with default P-box table.

      Default P-box tabel is used. p[N] = (17 + 19 * N) mod 32

      Parameters:
      iVal - int value
      Returns:
      mapped value
    • mapTable

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

      There is no bijection check.

      Parameters:
      iVal - int value
      table - P-box table
      Returns:
      mapped value
      Throws:
      NullPointerException - table is null
    • checkPbox

      public static void checkPbox(int[] permuteArg) throws NullPointerException, IllegalArgumentException
      Check P-box table.

      P-box table length must be 32.

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

      (permuteArg[31] = 7) means copying bit from bit-31 to bit-7.

      Parameters:
      permuteArg - P-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