javax.crypto.spec
Class DESKeySpec

java.lang.Object
  |
  +--javax.crypto.spec.DESKeySpec
All Implemented Interfaces:
KeySpec

public class DESKeySpec
extends Object
implements KeySpec

DES key specification.


Attention:  This is not a SUN implementation!

This class has been developed by IAIK according to the documentation publicly available.
For SUNīs documentation of this class see http://java.sun.com/security/JCE1.2/spec/apidoc/index.html


This class represents a DES key specification.

A key specification is a transparent representation of the key material constituting the key. For a DES key, this class specifies the underlying byte material constituting the key.

Version:
File Revision 16
See Also:
KeySpec

Field Summary
static int DES_KEY_LEN
           
 
Constructor Summary
DESKeySpec(byte[] key)
          Creates a DES key specification by using the first 8 bytes of the supplied byte array as the DES key.
DESKeySpec(byte[] key, int offset)
          Creates a DES key specification by using 8 bytes of the supplied byte array as DES key, beginning at the given offset.
 
Method Summary
 byte[] getKey()
          Returns the inherent DES key as byte representation.
static boolean isParityAdjusted(byte[] key, int offset)
          Checks if the DES key, supplied in a byte array beginning at the given offset, is parity-adjusted.
static boolean isWeak(byte[] key, int offset)
          Checks if the given DES key material, supplied within a byte array beginning at the given position, represents a weak or semi-weak DES key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DES_KEY_LEN

public static final int DES_KEY_LEN
Constructor Detail

DESKeySpec

public DESKeySpec(byte[] key)
           throws InvalidKeyException
Creates a DES key specification by using the first 8 bytes of the supplied byte array as the DES key.
Parameters:
key - the byte array holding the DES key
Throws:
InvalidKeyException - if the given key is shorter than 8 bytes

DESKeySpec

public DESKeySpec(byte[] key,
                  int offset)
           throws InvalidKeyException
Creates a DES key specification by using 8 bytes of the supplied byte array as DES key, beginning at the given offset.
Parameters:
key - the byte array holding the DES key
offset - the offset indicating the start position within the input key byte array
Throws:
InvalidKeyException - if the given key, beginning at offset, is shorter than 8 bytes
Method Detail

getKey

public byte[] getKey()
Returns the inherent DES key as byte representation.
Returns:
the DES key

isWeak

public static boolean isWeak(byte[] key,
                             int offset)
                      throws InvalidKeyException
Checks if the given DES key material, supplied within a byte array beginning at the given position, represents a weak or semi-weak DES key. Due to the way, the DES algorithm generates sub-keys for the several DES rounds, some initial keys may be classified as weak or semi-weak kyes reducing the security of the DES cipher (see "Applied Cryptography", Bruce Schneier, ISBN 0-471-59756-2).
Parameters:
key - the byte array holding the DES key to be checked
offset - the offset indicating the start position within the given byte array from which the key has to be read
Returns:
true if the given DES key material represents a weak or semi-weak DES key, false if the represented key is a strong one.
Throws:
InvalidKeyException - if the given key, beginning at offset, is shorter than 8 bytes

isParityAdjusted

public static boolean isParityAdjusted(byte[] key,
                                       int offset)
                                throws InvalidKeyException
Checks if the DES key, supplied in a byte array beginning at the given offset, is parity-adjusted.
Parameters:
key - the byte array holding the DES key
offset - the offset indicating the start position within the input key byte array
Returns:
true if the given DES key is parity-adjusted, false otherwise
Throws:
InvalidKeyException - if the given key, beginning at offset, is shorter than 8 bytes

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK