org.gregoire.util.crypto
Class BlowfishECB

java.lang.Object
  extended byorg.gregoire.util.crypto.BlowfishECB
All Implemented Interfaces:
BlockCipher
Direct Known Subclasses:
BlowfishCBC

public class BlowfishECB
extends java.lang.Object
implements BlockCipher

implementation of the Blowfish encryption algorithm in ECB mode

Version:
September 21, 2002
Author:
Markus Hahn

Field Summary
static int BLOCKSIZE
          block size of this cipher (in bytes)
static int MAXKEYLENGTH
          maximum possible key length
 
Constructor Summary
BlowfishECB()
          default constructor
BlowfishECB(byte[] bfkey)
           
 
Method Summary
 void cleanUp()
          to clear data in the boxes before an instance is freed
 void decrypt(byte[] buffer)
          decrypts a byte buffer (should be aligned to an 8 byte border) to itself
 void decrypt(byte[] inbuffer, byte[] outbuffer)
          decrypts a byte buffer (should be aligned to an 8 byte border) to another byte buffer (of the same size or bigger)
 void decrypt(int[] buffer)
          decrypts an int buffer (should be aligned to an two integer border)
 void decrypt(int[] inbuffer, int[] outbuffer)
          decrypts an integer buffer (should be aligned to an two integer border) to another int buffer (of the same size or bigger)
 void decrypt(long[] buffer)
          decrypts a long buffer to itself
 void decrypt(long[] inbuffer, long[] outbuffer)
          decrypts a long buffer to another long buffer (of the same size or bigger)
protected  long decryptBlock(long lCipherBlock)
           
 void encrypt(byte[] buffer)
          encrypts a byte buffer (should be aligned to an 8 byte border) to itself
 void encrypt(byte[] inbuffer, byte[] outbuffer)
          encrypts a byte buffer (should be aligned to an 8 byte border) to another buffer (of the same size or bigger)
 void encrypt(int[] buffer)
          encrypts an int buffer (should be aligned to a two integer border)
 void encrypt(int[] inbuffer, int[] outbuffer)
          encrypts an integer buffer (should be aligned to an two integer border) to another int buffer (of the same size or bigger)
 void encrypt(long[] buffer)
          encrypts a long buffer to itself
 void encrypt(long[] inbuffer, long[] outbuffer)
          encrypts a long buffer to another long buffer (of the same size or bigger)
protected  long encryptBlock(long lPlainBlock)
           
 int getBlockSize()
          Returns the block size, in bits, of the given block-cipher
 int getKeySize()
          Returns the key size, in bits, of the given block-cipher
 void initialize(byte[] bfkey)
          Initializes the cipher context with the given key.
 boolean weakKeyCheck()
          to check if an instance actually was using a weak key, if so it might be better to use a different key or salt the existing one as alternative
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXKEYLENGTH

public static final int MAXKEYLENGTH
maximum possible key length

See Also:
Constant Field Values

BLOCKSIZE

public static final int BLOCKSIZE
block size of this cipher (in bytes)

See Also:
Constant Field Values
Constructor Detail

BlowfishECB

public BlowfishECB()
default constructor


BlowfishECB

public BlowfishECB(byte[] bfkey)
Method Detail

initialize

public void initialize(byte[] bfkey)
Description copied from interface: BlockCipher
Initializes the cipher context with the given key. This might entail performing pre-encryption calculation of subkeys, S-Boxes, etc.

Specified by:
initialize in interface BlockCipher
Parameters:
bfkey - key material, up to MAXKEYLENGTH bytes

getKeySize

public int getKeySize()
Description copied from interface: BlockCipher
Returns the key size, in bits, of the given block-cipher

Specified by:
getKeySize in interface BlockCipher

getBlockSize

public int getBlockSize()
Description copied from interface: BlockCipher
Returns the block size, in bits, of the given block-cipher

Specified by:
getBlockSize in interface BlockCipher

cleanUp

public void cleanUp()
to clear data in the boxes before an instance is freed


weakKeyCheck

public boolean weakKeyCheck()
to check if an instance actually was using a weak key, if so it might be better to use a different key or salt the existing one as alternative

Returns:
true: weak key detected / false: key is fine

encryptBlock

protected long encryptBlock(long lPlainBlock)

decryptBlock

protected long decryptBlock(long lCipherBlock)

encrypt

public void encrypt(byte[] inbuffer,
                    byte[] outbuffer)
encrypts a byte buffer (should be aligned to an 8 byte border) to another buffer (of the same size or bigger)

Specified by:
encrypt in interface BlockCipher
Parameters:
inbuffer - buffer with plaintext data
outbuffer - buffer to get the ciphertext data

encrypt

public void encrypt(byte[] buffer)
encrypts a byte buffer (should be aligned to an 8 byte border) to itself

Parameters:
buffer - buffer to encrypt

encrypt

public void encrypt(int[] inbuffer,
                    int[] outbuffer)
encrypts an integer buffer (should be aligned to an two integer border) to another int buffer (of the same size or bigger)

Parameters:
inbuffer - buffer with plaintext data

encrypt

public void encrypt(int[] buffer)
encrypts an int buffer (should be aligned to a two integer border)

Parameters:
buffer - buffer to encrypt

encrypt

public void encrypt(long[] inbuffer,
                    long[] outbuffer)
encrypts a long buffer to another long buffer (of the same size or bigger)

Parameters:
inbuffer - buffer with plaintext data
outbuffer - buffer to get the ciphertext data

encrypt

public void encrypt(long[] buffer)
encrypts a long buffer to itself

Parameters:
buffer - buffer to encrypt

decrypt

public void decrypt(byte[] inbuffer,
                    byte[] outbuffer)
decrypts a byte buffer (should be aligned to an 8 byte border) to another byte buffer (of the same size or bigger)

Specified by:
decrypt in interface BlockCipher
Parameters:
inbuffer - buffer with ciphertext data

decrypt

public void decrypt(byte[] buffer)
decrypts a byte buffer (should be aligned to an 8 byte border) to itself

Parameters:
buffer - buffer to decrypt

decrypt

public void decrypt(int[] inbuffer,
                    int[] outbuffer)
decrypts an integer buffer (should be aligned to an two integer border) to another int buffer (of the same size or bigger)

Parameters:
inbuffer - buffer with ciphertext data
outbuffer - buffer to get the plaintext data

decrypt

public void decrypt(int[] buffer)
decrypts an int buffer (should be aligned to an two integer border)

Parameters:
buffer - buffer to decrypt

decrypt

public void decrypt(long[] inbuffer,
                    long[] outbuffer)
decrypts a long buffer to another long buffer (of the same size or bigger)

Parameters:
inbuffer - buffer with ciphertext data
outbuffer - buffer to get the plaintext data

decrypt

public void decrypt(long[] buffer)
decrypts a long buffer to itself

Parameters:
buffer - buffer to decrypt


Copyright © Paul Gregoire, All Rights Reserved.