APIdia Launch Partner
Top Description Fields Constructors Methods
javax.crypto.spec

public Class DESKeySpec

extends Object
implements KeySpec
Class Inheritance
All Implemented Interfaces
java.security.spec.KeySpec
Imports
java.security.InvalidKeyException

This class specifies a DES key.
Author
Jan Luehe
Since
1.4

Field Summary

Modifier and TypeField and Description
public static final int
DES_KEY_LEN

The constant which defines the length of a DES key in bytes.

private final byte[]
private static final byte[][]

Constructor Summary

AccessConstructor and Description
public
DESKeySpec(byte[]
the buffer with the DES key material. The first 8 bytes of the buffer are copied to protect against subsequent modification.
key
)

Creates a DESKeySpec object using the first 8 bytes in key as the key material for the DES key.

public
DESKeySpec(byte[]
the buffer with the DES key material. The first 8 bytes of the buffer beginning at offset inclusive are copied to protect against subsequent modification.
key
,
int
the offset in key, where the DES key material starts.
offset
)

Creates a DESKeySpec object using the first 8 bytes in key, beginning at offset inclusive, as the key material for the DES key.

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

the DES key material. Returns a new array each time this method is called.
getKey
()

Returns the DES key material.

public static boolean

Returns:

true if the given DES key material is parity-adjusted, false otherwise.
isParityAdjusted
(byte[]
the buffer with the DES key material.
key
,
int
the offset in key, where the DES key material starts.
offset
)

Checks if the given DES key material, starting at offset inclusive, is parity-adjusted.

public static boolean

Returns:

true if the given DES key material is weak or semi-weak, false otherwise.
isWeak
(byte[]
the buffer with the DES key material.
key
,
int
the offset in key, where the DES key material starts.
offset
)

Checks if the given DES key material is weak or semi-weak.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DES_KEY_LENback to summary
public static final int DES_KEY_LEN

The constant which defines the length of a DES key in bytes.

keyback to summary
private final byte[] key
WEAK_KEYSback to summary
private static final byte[][] WEAK_KEYS

Constructor Detail

DESKeySpecback to summary
public DESKeySpec(byte[] key) throws InvalidKeyException

Creates a DESKeySpec object using the first 8 bytes in key as the key material for the DES key.

The bytes that constitute the DES key are those between key[0] and key[7] inclusive.

Parameters
key:byte[]

the buffer with the DES key material. The first 8 bytes of the buffer are copied to protect against subsequent modification.

Exceptions
InvalidKeyException:
if the given key material is shorter than 8 bytes.
NullPointerException:
if the given key material is null.
DESKeySpecback to summary
public DESKeySpec(byte[] key, int offset) throws InvalidKeyException

Creates a DESKeySpec object using the first 8 bytes in key, beginning at offset inclusive, as the key material for the DES key.

The bytes that constitute the DES key are those between key[offset] and key[offset+7] inclusive.

Parameters
key:byte[]

the buffer with the DES key material. The first 8 bytes of the buffer beginning at offset inclusive are copied to protect against subsequent modification.

offset:int

the offset in key, where the DES key material starts.

Exceptions
InvalidKeyException:
if the given key material, starting at offset inclusive, is shorter than 8 bytes.
NullPointerException:
if the given key material is null.
ArrayIndexOutOfBoundsException:
if offset is negative.

Method Detail

getKeyback to summary
public byte[] getKey()

Returns the DES key material.

Returns:byte[]

the DES key material. Returns a new array each time this method is called.

isParityAdjustedback to summary
public static boolean isParityAdjusted(byte[] key, int offset) throws InvalidKeyException

Checks if the given DES key material, starting at offset inclusive, is parity-adjusted.

Parameters
key:byte[]

the buffer with the DES key material.

offset:int

the offset in key, where the DES key material starts.

Returns:boolean

true if the given DES key material is parity-adjusted, false otherwise.

Exceptions
InvalidKeyException:
if the given key material is null, or starting at offset inclusive, is shorter than 8 bytes.
ArrayIndexOutOfBoundsException:
if offset is negative.
isWeakback to summary
public static boolean isWeak(byte[] key, int offset) throws InvalidKeyException

Checks if the given DES key material is weak or semi-weak.

Parameters
key:byte[]

the buffer with the DES key material.

offset:int

the offset in key, where the DES key material starts.

Returns:boolean

true if the given DES key material is weak or semi-weak, false otherwise.

Exceptions
InvalidKeyException:
if the given key material is null, or starting at offset inclusive, is shorter than 8 bytes.
ArrayIndexOutOfBoundsException:
if offset is negative.