Package javax.crypto.spec
Class DESKeySpec
java.lang.Object
javax.crypto.spec.DESKeySpec
- All Implemented Interfaces:
KeySpec
public class DESKeySpec extends Object implements KeySpec
The key specification for a DES key.
-
Field Summary
Fields Modifier and Type Field Description static intDES_KEY_LENThe length of a DES key in bytes. -
Constructor Summary
Constructors Constructor Description DESKeySpec(byte[] key)Creates a newDESKeySpecfrom the first 8 bytes of the specified key data.DESKeySpec(byte[] key, int offset)Creates a newDESKeySpecfrom the first 8 bytes of the specified key data starting atoffset. -
Method Summary
Modifier and Type Method Description byte[]getKey()Returns a copy of the key.static booleanisParityAdjusted(byte[] key, int offset)Returns whether the specified key data starting atoffsetis parity-adjusted.static booleanisWeak(byte[] key, int offset)Returns whether the specified key data starting atoffsetis weak or semi-weak.
-
Field Details
-
DES_KEY_LEN
public static final int DES_KEY_LENThe length of a DES key in bytes.- See Also:
- Constant Field Values
-
-
Constructor Details
-
DESKeySpec
Creates a newDESKeySpecfrom the first 8 bytes of the specified key data.- Parameters:
key- the key data.- Throws:
InvalidKeyException- if the length of the specified key data is less than 8.
-
DESKeySpec
Creates a newDESKeySpecfrom the first 8 bytes of the specified key data starting atoffset.- Parameters:
key- the key dataoffset- the offset to start at.- Throws:
InvalidKeyException- if the length of the specified key data starting at offset is less than 8.
-
-
Method Details
-
getKey
public byte[] getKey()Returns a copy of the key.- Returns:
- a copy of the key.
-
isParityAdjusted
Returns whether the specified key data starting atoffsetis parity-adjusted.- Parameters:
key- the key data.offset- the offset to start checking at.- Returns:
trueif the specified key data is parity-adjusted,falseotherwise.- Throws:
InvalidKeyException- if the length of the key data starting at offset is less than 8, or the key is null.
-
isWeak
Returns whether the specified key data starting atoffsetis weak or semi-weak.- Parameters:
key- the key data.offset- the offset to start checking at.- Returns:
trueif the specified key data is weak or semi-weak.- Throws:
InvalidKeyException- if the length of the key data starting at offset is less than 8, or it is null.
-