Class Pbox32
java.lang.Object
io.github.olyutorskii.aletojio.bijection.Pbox32
- All Implemented Interfaces:
RndInt32
P-box diffusion by bit permutation.
Takes a 32-bit integer as input and outputs a diffused 32-bit integer.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkPbox
(int[] permuteArg) Check P-box table.static int
mapPermutation
(int iVal) Map int value with default P-box table.static int
mapTable
(int iVal, int[] table) Map int value with specified P-box table.int
Return next random number as 32bit int with random sign-bit.
-
Constructor Details
-
Pbox32
Constructor.Default P-box tabel is used.
p[N] = (17 + 19 * N) mod 32
- Parameters:
rndArg
- random source- Throws:
NullPointerException
IllegalArgumentException
-
Pbox32
public Pbox32(RndInt32 rndArg, int[] permuteArg) throws NullPointerException, IllegalArgumentException Constructor.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:
rndArg
- random sourcepermuteArg
- P-box bit-permutation table- Throws:
NullPointerException
- null argumentIllegalArgumentException
- invalid P-box
-
-
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 valuetable
- 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 argumentIllegalArgumentException
- size unmatch or not bijection detected
-
nextInt32
public int nextInt32()Return next random number as 32bit int with random sign-bit.
-