org.logi.crypto.keys
Class TriDESKey

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.keys.K
              |
              +--org.logi.crypto.keys.SymmetricKey
                    |
                    +--org.logi.crypto.keys.TriDESKey
All Implemented Interfaces:
CipherKey, Key

public class TriDESKey
extends SymmetricKey
implements CipherKey

This is the class for triple-DES keys used in an EDE3 configuration. This is a variant of the standard DES cipher which increases the size of the key-space to make exhaustive key-search infeasible.

The CDS for a triple-DES key is TriDESKey(key) with key a string of 48 hexadecimal digits to create a specific key or TriDESKey(?) for a random TriDESKey object.

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
DESKey

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
TriDESKey()
          Create a new random triple-DES key.
TriDESKey(byte[] key)
          Create a new triple-DES key with the key bits from key[0..23].
 
Method Summary
 int cipherBlockSize()
          The block-size for the triple-DES cipher is 8 bytes.
 void decrypt(byte[] source, int i, byte[] dest, int j)
          Decrypt one block of data.
 void encrypt(byte[] source, int i, byte[] dest, int j)
          Encrypt one block of data.
 boolean equals(java.lang.Object o)
          Return true iff the two keys are equivalent.
 java.lang.String getAlgorithm()
          The name of the algorithm is "TriDES".
 byte[] getKey()
          Return the key-bits for this key as an array of 24 bytes.
 int getSize()
          The key-size for the triple-DES cipher is 168 bits.
static TriDESKey parseCDS(java.lang.String key)
          If "TriDESKey( key )" is a valid CDS for a TriDESKey, then TriDESKey.parseCDS(key) will return the described TriDESKey object.
 int plainBlockSize()
          The block-size for the triple-DES cipher is 8 bytes.
 java.lang.String toString()
          Return a CDS for this key.
 
Methods inherited from class org.logi.crypto.keys.SymmetricKey
isPrivate, matches
 
Methods inherited from class org.logi.crypto.keys.K
getFingerprint, getFingerprint, hashCode, matchFingerprint, matchFingerprint
 
Methods inherited from class org.logi.crypto.Crypto
binString, binString, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, readBlock, readInt, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.logi.crypto.keys.Key
getFingerprint, getFingerprint, hashCode, isPrivate, matches, matchFingerprint, matchFingerprint
 

Constructor Detail

TriDESKey

public TriDESKey()
Create a new random triple-DES key.

TriDESKey

public TriDESKey(byte[] key)
Create a new triple-DES key with the key bits from key[0..23].
Method Detail

parseCDS

public static TriDESKey parseCDS(java.lang.String key)
                          throws InvalidCDSException
If "TriDESKey( key )" is a valid CDS for a TriDESKey, then TriDESKey.parseCDS(key) will return the described TriDESKey object.

A valid CDS can be created by calling the TriDESKey.toString() method.

Throws:
InvalidCDSException - if the CDS is malformed.
See Also:
Crypto.fromString(String)

plainBlockSize

public int plainBlockSize()
The block-size for the triple-DES cipher is 8 bytes.
Specified by:
plainBlockSize in interface CipherKey

cipherBlockSize

public int cipherBlockSize()
The block-size for the triple-DES cipher is 8 bytes.
Specified by:
cipherBlockSize in interface CipherKey

getSize

public int getSize()
The key-size for the triple-DES cipher is 168 bits.
Specified by:
getSize in interface Key

getAlgorithm

public java.lang.String getAlgorithm()
The name of the algorithm is "TriDES".
Specified by:
getAlgorithm in interface Key

equals

public boolean equals(java.lang.Object o)
Return true iff the two keys are equivalent.
Overrides:
equals in class java.lang.Object

getKey

public byte[] getKey()
Return the key-bits for this key as an array of 24 bytes.

toString

public java.lang.String toString()
Return a CDS for this key.
Overrides:
toString in class java.lang.Object
See Also:
Crypto.fromString(java.io.Reader)

encrypt

public void encrypt(byte[] source,
                    int i,
                    byte[] dest,
                    int j)
Encrypt one block of data. The plain data is taken from source[i..i+23] and ciphertext is written to dest[j..j+23].
Specified by:
encrypt in interface CipherKey

decrypt

public void decrypt(byte[] source,
                    int i,
                    byte[] dest,
                    int j)
Decrypt one block of data. The encrypted data is taken from dest[i..i+23] and plaintext is written to source[j..j+23].
Specified by:
decrypt in interface CipherKey


Copyright 1997-2000 Logi Ragnarsson