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)

Constructor Index

 o BlowfishKey()
Create a new random 128 bit Blowfish key.
 o BlowfishKey(byte[])
Create a new Blowfish key with the key bits from key.
 o BlowfishKey(int)
Create a new random n-bit Blowfish key.

Method Index

 o cipherBlockSize()
The block-size for the Blowfish cipher is 8 bytes.
 o decrypt(byte[], int, byte[], int)
Decrypt one block of data.
 o encrypt(byte[], int, byte[], int)
Encrypt one block of data.
 o equals(Object)
Return true iff the two keys are equivalent.
 o getAlgorithm()
The name of the algorithm is "Blowfish".
 o getKey()
Return the key-bits for this key as an array of bytes.
 o getSize()
Return the size of this key.
 o parseCDS(String)
If "BlowfishKey( key )" is a valid CDS for a BlowfishKey, then BlowfishKey.parseCDS(key) will return the described BlowfishKey object.
 o plainBlockSize()
The block-size for the Blowfish cipher is 8 bytes.
 o toString()
Return a CDS for this key.

Constructors

 o 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.

 o BlowfishKey
 public BlowfishKey()
Create a new random 128 bit Blowfish key.

 o BlowfishKey
 public BlowfishKey(byte key[])
Create a new Blowfish key with the key bits from key.

Methods

 o 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
 o plainBlockSize
 public int plainBlockSize()
The block-size for the Blowfish cipher is 8 bytes.

 o cipherBlockSize
 public int cipherBlockSize()
The block-size for the Blowfish cipher is 8 bytes.

 o getSize
 public int getSize()
Return the size of this key.

Overrides:
getSize in class K
 o getAlgorithm
 public String getAlgorithm()
The name of the algorithm is "Blowfish".

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

Overrides:
equals in class Object
 o getKey
 public byte[] getKey()
Return the key-bits for this key as an array of bytes.

 o toString
 public String toString()
Return a CDS for this key.

Overrides:
toString in class Object
See Also:
fromString
 o 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]

 o 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