|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--org.logi.crypto.Crypto
|
+--org.logi.crypto.keys.K
|
+--org.logi.crypto.keys.SymmetricKey
|
+--org.logi.crypto.keys.DESKey
This is the class for Data Encryption Standard (DES) keys. See FIPS PUB 46-1 or DEA defined in ANSI X3.92-1981 for a complete specification.
DES is the most widely used block cipher, although it is nowadays normally used repeatedly for each piece of plain-text and is called triple-DES. This is because the 56-bit key-size of the normal DES is too small to offer complete security.
The CDS for a DES key is DESKey(key) with key
a string of 16 hexadecimal digits to create a specific key
or DESKey(?) for a random DESKey object.
This implementation is done from the description given in Schneier's Applied Cryptography.
TriDESKey, Serialized Form| Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
| Fields inherited from interface java.security.Key |
serialVersionUID |
| Constructor Summary | |
DESKey()
Create a new random DES key. |
|
DESKey(byte[] key)
Create a new DES key with the key bits from key[0..7]. |
|
DESKey(long key)
Create a new DES key with the key bits from key. |
|
| Method Summary | |
int |
cipherBlockSize()
The block-size for the 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 "DES". |
byte[] |
getEncoded()
Return encoded version. |
Fingerprint |
getFingerprint()
Return the key's fingerprint using the default hash function. |
Fingerprint |
getFingerprint(java.lang.String algorithm)
Return the key's fingerprint using the specified hash function. |
java.lang.String |
getFormat()
Returns the name of the key-encoding format. |
byte[] |
getKey()
Return the key-bits for this key as an array of 8 bytes. |
int |
getSize()
The key-size for the DES cipher is 56 bits. |
int |
hashCode()
Return a hash-code based on the keys SHA1 fingerprint. |
boolean |
matches(Key key)
Returns true if this and key are the same symmetric key. |
Fingerprint |
matchFingerprint()
Returns the default fingerprint of the matching key in the key-pair. |
Fingerprint |
matchFingerprint(java.lang.String algorithm)
Returns the default fingerprint of the matching key in the key-pair. |
static DESKey |
parseCDS(java.lang.String[] param)
Used by Crypto.fromString when parsing a CDS. |
int |
plainBlockSize()
The block-size for the DES cipher is 8 bytes. |
java.lang.String |
toString()
Return a CDS for this key. |
| Methods inherited from class org.logi.crypto.Crypto |
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, 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, matches, matchFingerprint, matchFingerprint |
| Methods inherited from interface org.logi.crypto.io.PrettyPrintable |
prettyPrint, prettyPrint |
| Methods inherited from interface java.security.Key |
getEncoded, getFormat |
| Constructor Detail |
public DESKey()
public DESKey(byte[] key)
key[0..7].public DESKey(long key)
key.| Method Detail |
public static DESKey parseCDS(java.lang.String[] param)
throws InvalidCDSException
A valid CDS can be created by calling the toString() method.
InvalidCDSException - if the CDS is malformed.Crypto.fromString(String)public int plainBlockSize()
plainBlockSize in interface EncryptionKeypublic int cipherBlockSize()
cipherBlockSize in interface EncryptionKeypublic int getSize()
getSize in interface Keypublic java.lang.String getAlgorithm()
getAlgorithm in interface Keypublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic byte[] getKey()
public java.lang.String toString()
toString in class java.lang.ObjectCrypto.fromString(java.io.Reader)
public void encrypt(byte[] source,
int i,
byte[] dest,
int j)
source[i..i+7] and ciphertext is written to
dest[j..j+7]encrypt in interface EncryptionKey
public void decrypt(byte[] source,
int i,
byte[] dest,
int j)
dest[i..i+7] and plaintext is written to
source[j..j+7].decrypt in interface DecryptionKeypublic boolean matches(Key key)
Symmetric keys simply call equals(key).
public final Fingerprint getFingerprint()
getFingerprint in interface Key
public final Fingerprint getFingerprint(java.lang.String algorithm)
throws InvalidCDSException
getFingerprint in interface KeyInvalidCDSException - if the specified hash function is not
available.public Fingerprint matchFingerprint()
matchFingerprint in interface Key
public Fingerprint matchFingerprint(java.lang.String algorithm)
throws InvalidCDSException
matchFingerprint in interface KeyInvalidCDSException - if the specified hash function is not
available.public final int hashCode()
hashCode in interface KeyhashCode in class java.lang.Objectpublic byte[] getEncoded()
getEncoded in interface java.security.Keypublic java.lang.String getFormat()
getFormat in interface java.security.Key
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL