com.ibm.opencard.crypto
Class DES
java.lang.Object
|
+--com.ibm.opencard.crypto.DES
- public final class DES
- extends java.lang.Object
This class can be used to encrypt/decrypt blocks of 8 bytes using
the standard Data Encryption Algorithm.
- Version:
- $Id: DES.java,v 1.1 1999/12/02 16:06:02 damke Exp $
|
Constructor Summary |
DES()
Constructs a new DES algorithm instance.
|
|
Method Summary |
void |
decrypt(byte[] block)
Performs an in-place decryption of a 64-bit block. |
void |
encrypt(byte[] block)
Performs an in-place encryption of a 64-bit block.
|
void |
encryptSingle(byte[] block)
Performs an in-place encryption of a 64-bit block, always using DES.
|
void |
setkey(byte[] key)
Sets the key to be used by the methods encrypt and decrypt. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
DES
public DES()
- Constructs a new DES algorithm instance.
Each instance can be parameterized with exactly one key using
setkey below. This has to be done before the first
encrypt or decrypt operation.
This constructor prepares the space for a triple length 3DES key.
Only parts of this space are used for double and single length keys.
- See Also:
setkey(byte[])
setkey
public void setkey(byte[] key)
- Sets the key to be used by the methods encrypt and decrypt.
- Parameters:
key - The DES key to be used for encryption/decryption.
The key can be 64, 128, or 192 bit in length. It will
be used for single or triple DES operations, respectively.
No parity checking is performed.
encrypt
public void encrypt(byte[] block)
- Performs an in-place encryption of a 64-bit block.
Depending on the length of the key previously set, DES or 3DES
is used for encryption.
- Parameters:
block - the 8 byte block to be encrypted. The block is
encrypted in place, it's old content will be lost.
encryptSingle
public void encryptSingle(byte[] block)
- Performs an in-place encryption of a 64-bit block, always using DES.
Even if a double or triple length key has been previously set, this
method performs a simple DES encryption, using the first 8 bytes of
the current key. This is useful for some MAC computations.
- Parameters:
block - the 8 byte block to be encrypted. The block is
encrypted in place, it's old content will be lost.
decrypt
public void decrypt(byte[] block)
- Performs an in-place decryption of a 64-bit block.
- Parameters:
block - The block to be decrypted. The block is dedcrypted in place,
so the old contents will be lost.
|