Class ParitySpreader
java.lang.Object
io.github.olyutorskii.aletojio.bijection.ParitySpreader
Diffusion of parity information.
Take the XOR of all even-numbered input bytes to obtain the odd-parity byte. The output is the XOR of the parity byte and the original each byte value.
This conversion is bijection. Perform this operation an even number of times to return to the original value.
Used as a pre-processor for 8bit S-box conversion to improve confusion.
byte-length must be even.
If 1 bit of N bytes input array changes, N-1 bits of output array changes. Hamming distance is N-1 bits.
ex) Input I has 4 bytes (I0-I3) Output O has 4 bytes (O0-O3)
X = I0 ^ I1 ^ I2 ^ I3
O0 = I0 ^ X, O1 = I1 ^ X, O2 = I3 ^ X, O3 = I3 ^ X
-
Method Summary
-
Method Details
-
spread
public static int spread(int iVal) Spread parity information.- Parameters:
iVal
- int value- Returns:
- result
-
spread
public static void spread(byte[] bytes, int length) throws IndexOutOfBoundsException, IllegalArgumentException Spread parity information.- Parameters:
bytes
- input and output bytes arraylength
- length of input must be even and smaller than input array.- Throws:
IndexOutOfBoundsException
- length is negative or too largeIllegalArgumentException
- length is odd number
-