public class DESParameterSpec
extends java.lang.Object
implements java.security.spec.AlgorithmParameterSpec
This class represents an initialization vector (IV), and the DES S-Boxes and P-Boxes.
If you want to use the default S-Boxes or P-Box or want the IV to be
generated automatically pass null
.
The S-Boxes have to be a byte array with 8*64 entries ranging from 0 to 15. S-Box 1 starts at index 0, S-Box 2 at 64, etc. Entries have to be present in the order originally specified; for the standard DES S-Box 1 that is 14, 4, 13, 1, 2, 15, ... , 14, 10, 0, 6, 13.
The P-Box has to be a byte array with 32 distinct entries ranging from 1 to 32. The original DES P-Box is 16, 7, 20, 21, 29, 12, ... , 30, 6, 22, 11, 4, 25.
You will typically not want to use a custom P-Box but it is implemented as the code supports it anyway. It may make sense to use custom S-Boxes, like the improved s3DES which is resistant to both differential and linear cryptanalysis (see Bruce Schneier's Applied Cryptography, page 299). However, never use random or not carefully evaluated S-Boxes as this greatly reduces DES's security (even if the attacker does not know them).
AlgorithmParameterSpec
Constructor and Description |
---|
DESParameterSpec(byte[] SBoxes,
byte[] PBox,
byte[] initVector)
Creates a DES Parameter specification by using the given SBoxes, PBox, and
the first 8 bytes of the supplied byte array as initialization vector (IV).
|
DESParameterSpec(byte[] SBoxes,
byte[] PBox,
byte[] initVector,
int offset)
Creates a DES Parameter specification by using the given SBoxes, PBox, and
8 bytes of the supplied byte array as initialization vector (IV), beginning
at the given offset.
|
public DESParameterSpec(byte[] SBoxes, byte[] PBox, byte[] initVector)
public DESParameterSpec(byte[] SBoxes, byte[] PBox, byte[] initVector, int offset)
public byte[] getIV()
public byte[] getSBoxes()
public byte[] getPBox()