All Packages Class Hierarchy This Package Previous Next Index
Class is.logi.crypto.keys.BlowfishKey
java.lang.Object
|
+----is.logi.crypto.Crypto
|
+----is.logi.crypto.keys.K
|
+----is.logi.crypto.keys.SymmetricKey
|
+----is.logi.crypto.keys.BlowfishKey
- public class BlowfishKey
- extends SymmetricKey
- implements CipherKey
This is the class for Blowfish keys. It is a feistel blockcipher with a
64-bit block size and variable key-size. It was designed by Bruce Schneier
and is in the public domain. (This implementation is licensed in the same
way as the rest of the logi.crypto package.)
The CDS for a Blowfish key is BlowfishKey(key)
with
key
a string of hexadecimal digits to create a specific
key or BlowfishKey(?)
for a random BlowfishKey object.
- Author:
- Logi Ragnarsson
(logir@hi.is)
-
BlowfishKey()
- Create a new random 128 bit Blowfish key.
-
BlowfishKey(byte[])
- Create a new Blowfish key with the key bits from
key
.
-
BlowfishKey(int)
- Create a new random n-bit Blowfish key.
-
cipherBlockSize()
- The block-size for the Blowfish cipher is 8 bytes.
-
decrypt(byte[], int, byte[], int)
- Decrypt one block of data.
-
encrypt(byte[], int, byte[], int)
- Encrypt one block of data.
-
equals(Object)
- Return true iff the two keys are equivalent.
-
getAlgorithm()
- The name of the algorithm is "Blowfish".
-
getKey()
- Return the key-bits for this key as an array of bytes.
-
getSize()
- Return the size of this key.
-
parseCDS(String)
- If "BlowfishKey( key )" is a valid CDS for a BlowfishKey, then
BlowfishKey.parseCDS(key) will return the described BlowfishKey object.
-
plainBlockSize()
- The block-size for the Blowfish cipher is 8 bytes.
-
toString()
- Return a CDS for this key.
BlowfishKey
public BlowfishKey(int n)
- Create a new random n-bit Blowfish key. The size
will be rounded up to the next multiple of 8.
BlowfishKey
public BlowfishKey()
- Create a new random 128 bit Blowfish key.
BlowfishKey
public BlowfishKey(byte key[])
- Create a new Blowfish key with the key bits from
key
.
parseCDS
public static BlowfishKey parseCDS(String key) throws InvalidCDSException
- If "BlowfishKey( key )" is a valid CDS for a BlowfishKey, then
BlowfishKey.parseCDS(key) will return the described BlowfishKey object.
A valid CDS can be created by calling the BlowfishKey.toString() method.
- Throws: InvalidCDSException
- if the CDS is malformed.
- See Also:
- fromString
plainBlockSize
public int plainBlockSize()
- The block-size for the Blowfish cipher is 8 bytes.
cipherBlockSize
public int cipherBlockSize()
- The block-size for the Blowfish cipher is 8 bytes.
getSize
public int getSize()
- Return the size of this key.
- Overrides:
- getSize in class K
getAlgorithm
public String getAlgorithm()
- The name of the algorithm is "Blowfish".
- Overrides:
- getAlgorithm in class K
equals
public boolean equals(Object o)
- Return true iff the two keys are equivalent.
- Overrides:
- equals in class Object
getKey
public byte[] getKey()
- Return the key-bits for this key as an array of bytes.
toString
public String toString()
- Return a CDS for this key.
- Overrides:
- toString in class Object
- See Also:
- fromString
encrypt
public void encrypt(byte source[],
int i,
byte dest[],
int j)
- Encrypt one block of data. The plaintext is taken from
source[i..i+7]
and ciphertext is written to
dest[i..i+7]
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+7]
and plaintext is written to
source[j..j+7]
.
All Packages Class Hierarchy This Package Previous Next Index