de.cscc.crypto.provider.spec
Class DESede3KeySpec

java.lang.Object
  extended byde.cscc.crypto.provider.spec.DESede3KeySpec
All Implemented Interfaces:
Cloneable, DESKeySpec, KeySpec

public class DESede3KeySpec
extends Object
implements DESKeySpec, Cloneable

3 Key Triple DES secret keys specification (168 bit or 192 bit with parity) class.

This class is immutable.

Version:
$Revision: 1.8 $
Author:
Uwe Günther

Constructor Summary
DESede3KeySpec(byte[] key)
          Creates a new DESede3KeySpec from a 24 bytes long byte array.
DESede3KeySpec(byte[] key, int offset)
          Creates a new DESede3KeySpec from a 24 bytes long byte array.
DESede3KeySpec(DESede3KeySpec key)
          Creates a new DESede3KeySpec from an existing one.
 
Method Summary
 Object clone()
          Creates and returns a deep copy of this object.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 byte[] getKey()
          Get the DES Key as byte[24].
 int hashCode()
          Returns a hash code value for the object.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DESede3KeySpec

public DESede3KeySpec(byte[] key)
               throws InvalidKeyException
Creates a new DESede3KeySpec from a 24 bytes long byte array. We use the first 24 bytes in key as the key material for the DES key. The first (leftmost) DES key (key[0] to key[7]) is key1, the second (middle) DES key (key[8] to key[15]) is key2 and the third (rightmost) DES key (key[16] to key[13]) is key3.

Parameters:
key - the buffer with the three DES keys.
Throws:
InvalidKeyException - if the given key material is shorter than 24 bytes or the key is weak or semi weak.

DESede3KeySpec

public DESede3KeySpec(byte[] key,
                      int offset)
               throws InvalidKeyException
Creates a new DESede3KeySpec from a 24 bytes long byte array.

Parameters:
key - the buffer with the DES keys.
offset - the offset in key, where the key starts.
Throws:
InvalidKeyException - if the given key material is shorter than 24 bytes or the key is weak or semi weak.

DESede3KeySpec

public DESede3KeySpec(DESede3KeySpec key)
Creates a new DESede3KeySpec from an existing one.

Parameters:
key - DesKeySpec object with a key.
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Creates and returns a deep copy of this object.

Returns:
a clone of this instance.
Throws:
CloneNotSupportedException - if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
See Also:
Cloneable

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Returns:
a hash code value for this object.
See Also:
equals(java.lang.Object), Hashtable

toString

public String toString()
Returns a string representation of the object. The Format may catch (change in further releases.

Returns:
a string representation of the object.

getKey

public byte[] getKey()
Get the DES Key as byte[24].

Specified by:
getKey in interface DESKeySpec
Returns:
the DES Key as byte[24].


Copyright © 2001, 2002 by Uwe Günther. See the COPYING file for more details. Browse the source as HTML.