Class Sbox8x4
java.lang.Object
io.github.olyutorskii.aletojio.bijection.Sbox8x4
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkSbox
(int[] sboxArg) Check S-box table.static int
mapRijndael
(int iVal) Map int value with Rijndael(AES) table.static int
mapTable
(int iVal, int[] table) Map int value with specified S-box table.int
Return next random number as 32bit int with random sign-bit.
-
Constructor Details
-
Sbox8x4
Constructor.S-box of AES(Rijndael) is used.
- Parameters:
rndArg
- random source- Throws:
NullPointerException
- argument is nullIllegalArgumentException
- invalid S-box
-
Sbox8x4
public Sbox8x4(RndInt32 rndArg, int[] sboxArg) throws NullPointerException, IllegalArgumentException Constructor.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:
rndArg
- random sourcesboxArg
- S-box table- Throws:
NullPointerException
- argument is nullIllegalArgumentException
- invalid S-box
-
-
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 valuetable
- S-box table- Returns:
- mapped value
- Throws:
NullPointerException
- table is nullIndexOutOfBoundsException
- table is too small
-
checkSbox
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 argumentIllegalArgumentException
- size unmatch or not bijection detected
-
nextInt32
public int nextInt32()Return next random number as 32bit int with random sign-bit.
-