net.sourceforge.blowfishj
Class BlowfishECB

java.lang.Object
  extended bynet.sourceforge.blowfishj.BlowfishECB
Direct Known Subclasses:
BlowfishCBC

public class BlowfishECB
extends java.lang.Object

Implementation of the Blowfish encryption algorithm in ECB mode.


Field Summary
static int BLOCKSIZE
          block size of this cipher (in bytes)
static int MAXKEYLENGTH
          maximum possible key length in bytes
 
Constructor Summary
BlowfishECB()
          The default constructor, call initialize() afterwards to do the final setup.
BlowfishECB(byte[] key)
          Deprecated. use BlowfishECB(byte[], int, int) instead
BlowfishECB(byte[] key, int nOfs, int nLen)
           
 
Method Summary
 void cleanUp()
          To clear data in the boxes before an instance is freed, the actual value of this call can be argued, yet still nice to have it.
 void decrypt(byte[] buf)
          Deprecated. use decrypt(byte[], int, byte[], int, int) instead
 void decrypt(byte[] inBuf, byte[] outBuf)
          Deprecated. use decrypt(byte[], int, byte[], int, int) instead
 int decrypt(byte[] inBuf, int nInPos, byte[] outBuf, int nOutPos, int nLen)
          Decrypts a byte buffer to another buffer, extra misaligned data will not be processed.
 void decrypt(int[] buf)
          Deprecated. use decrypt(int[], int, int[], int, int) instead
 void decrypt(int[] inBuf, int[] outBuf)
          Deprecated. use decrypt(int[], int, int[], int, int) instead
 void decrypt(int[] inBuf, int nInPos, int[] outBuf, int nOutPos, int nLen)
          Decrypts an integer buffer to another integer buffer.
 void decrypt(long[] buf)
          Deprecated. use decrypt(long[], int, long[], int, int) instead
 void decrypt(long[] inBuf, int nInPos, long[] outBuf, int nOutPos, int nLen)
          Decrypts an long buffer to another long buffer.
 void decrypt(long[] inBuf, long[] outBuf)
          Deprecated. use decrypt(long[], int, long[], int, int) instead
 void encrypt(byte[] buf)
          Deprecated. use encrypt(byte[], int, byte[], int, int) instead
 void encrypt(byte[] inBuf, byte[] outBuf)
          Deprecated. use encrypt(byte[], int, byte[], int, int) instead
 int encrypt(byte[] inBuf, int nInPos, byte[] outBuf, int nOutPos, int nLen)
          Encrypts a byte buffer to another buffer, extra misaligned data will not be processed.
 void encrypt(int[] buf)
          Deprecated. use encrypt(int[], int, int[], int, int) instead
 void encrypt(int[] inBuf, int[] outBuf)
          Deprecated. use encrypt(int[], int, int[], int, int) instead
 void encrypt(int[] inBuf, int nInPos, int[] outBuf, int nOutPos, int nLen)
          Encrypts an integer buffer to another integer buffer.
 void encrypt(long[] buf)
          Deprecated. use encrypt(long[], int, long[], int, int) instead
 void encrypt(long[] inBuf, int nInPos, long[] outBuf, int nOutPos, int nLen)
          Encrypts an long buffer to another long buffer.
 void encrypt(long[] inBuf, long[] outBuf)
          Deprecated. use encrypt(long[], int, long[], int, int) instead
protected  int encryptPrv(byte[] inBuf, int nInPos, byte[] outBuf, int nOutPos, int nLen)
           
 void initialize(byte[] key, int nOfs, int nLen)
          Initializes (or resets) the instances.
static boolean selfTest()
          Selftest routine, for instance to check for a valid class file loading.
 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 in bytes

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()
The default constructor, call initialize() afterwards to do the final setup.


BlowfishECB

public BlowfishECB(byte[] key)
Deprecated. use BlowfishECB(byte[], int, int) instead

The default constructor, using a simple binary key.

Parameters:
key - key material, up to MAXKEYLENGTH bytes

BlowfishECB

public BlowfishECB(byte[] key,
                   int nOfs,
                   int nLen)
See Also:
initialize(byte[], int, int)
Method Detail

initialize

public void initialize(byte[] key,
                       int nOfs,
                       int nLen)
Initializes (or resets) the instances.

Parameters:
key - key material, up to MAXKEYLENGTH bytes
nOfs - where to start reading
nLen - number of bytes

cleanUp

public void cleanUp()
To clear data in the boxes before an instance is freed, the actual value of this call can be argued, yet still nice to have it.


selfTest

public static boolean selfTest()
Selftest routine, for instance to check for a valid class file loading.

Returns:
true: selftest passed / false: selftest failed

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

encryptPrv

protected int encryptPrv(byte[] inBuf,
                         int nInPos,
                         byte[] outBuf,
                         int nOutPos,
                         int nLen)

encrypt

public int encrypt(byte[] inBuf,
                   int nInPos,
                   byte[] outBuf,
                   int nOutPos,
                   int nLen)
Encrypts a byte buffer to another buffer, extra misaligned data will not be processed.

Parameters:
inBuf - buffer with plaintext data
nInPos - where to start reading the plaintext data
outBuf - buffer to put the ciphertext data
nOutPos - where to start writing the ciphertext data
nLen - number of bytes to encrypt
Returns:
number of bytes to encrypted

encrypt

public void encrypt(byte[] inBuf,
                    byte[] outBuf)
Deprecated. use encrypt(byte[], int, byte[], int, int) instead

Encrypts a byte buffer (should be aligned to a block border) to another buffer (of the same size or bigger).

Parameters:
inBuf - buffer with plaintext data
outBuf - buffer to get the ciphertext data

encrypt

public void encrypt(byte[] buf)
Deprecated. use encrypt(byte[], int, byte[], int, int) instead

Encrypts a byte buffer (should be aligned to a block border) to itself.

Parameters:
buf - buffer to encrypt

encrypt

public void encrypt(int[] inBuf,
                    int nInPos,
                    int[] outBuf,
                    int nOutPos,
                    int nLen)
Encrypts an integer buffer to another integer buffer.

Parameters:
inBuf - buffer with plaintext data
nInPos - where to start reading the plaintext data
outBuf - buffer to write the ciphertext data
nOutPos - where to start writing the ciphertext data
nLen - number of integers to encrypt

encrypt

public void encrypt(int[] inBuf,
                    int[] outBuf)
Deprecated. use encrypt(int[], int, int[], int, int) instead

Encrypts an integer buffer (should be aligned to a two integer border) to another int buffer (of the same size or bigger).

Parameters:
inBuf - buffer with ciphertext data
outBuf - buffer to get the plaintext data

encrypt

public void encrypt(int[] buf)
Deprecated. use encrypt(int[], int, int[], int, int) instead

Encrypts an integer buffer to itself.

Parameters:
buf - buffer to decrypt

encrypt

public void encrypt(long[] inBuf,
                    int nInPos,
                    long[] outBuf,
                    int nOutPos,
                    int nLen)
Encrypts an long buffer to another long buffer.

Parameters:
inBuf - buffer with plaintext data
nInPos - where to start reading the plaintext data
outBuf - buffer to write the ciphertext data
nOutPos - where to start writing the ciphertext data
nLen - number of longs to decrypt

encrypt

public void encrypt(long[] inBuf,
                    long[] outBuf)
Deprecated. use encrypt(long[], int, long[], int, int) instead

Encrypts a long buffer to another long buffer (of the same size or bigger).

Parameters:
inBuf - buffer with ciphertext data
outBuf - buffer to get the plaintext data

encrypt

public void encrypt(long[] buf)
Deprecated. use encrypt(long[], int, long[], int, int) instead

Encrypts a long buffer to itself.

Parameters:
buf - buffer to decrypt

decrypt

public int decrypt(byte[] inBuf,
                   int nInPos,
                   byte[] outBuf,
                   int nOutPos,
                   int nLen)
Decrypts a byte buffer to another buffer, extra misaligned data will not be processed.

Parameters:
inBuf - buffer with ciphertext data
nInPos - where to start reading the ciphertext data
outBuf - buffer to put the plaintext data
nOutPos - where to start writing the plaintext data
nLen - number of bytes to decrypt
Returns:
number of bytes to encrypted

decrypt

public void decrypt(byte[] inBuf,
                    byte[] outBuf)
Deprecated. use decrypt(byte[], int, byte[], int, int) instead

Decrypts a byte buffer (should be aligned to a block border) to another byte buffer (of the same size or bigger).

Parameters:
inBuf - buffer with ciphertext data
outBuf - buffer to get the plaintext data

decrypt

public void decrypt(byte[] buf)
Deprecated. use decrypt(byte[], int, byte[], int, int) instead

Decrypts a byte buffer (should be aligned) to itself.

Parameters:
buf - buffer to decrypt

decrypt

public void decrypt(int[] inBuf,
                    int nInPos,
                    int[] outBuf,
                    int nOutPos,
                    int nLen)
Decrypts an integer buffer to another integer buffer.

Parameters:
inBuf - buffer with ciphertext data
nInPos - where to start reading the ciphertext data
outBuf - buffer to get the plaintext data
nOutPos - where to start writing the plaintext data
nLen - number of integers to decrypt

decrypt

public void decrypt(int[] inBuf,
                    int[] outBuf)
Deprecated. use decrypt(int[], int, int[], int, int) instead

Decrypts an integer buffer (should be aligned to a two integer border) to another int buffer (of the same size or bigger).

Parameters:
inBuf - buffer with ciphertext data
outBuf - buffer to get the plaintext data

decrypt

public void decrypt(int[] buf)
Deprecated. use decrypt(int[], int, int[], int, int) instead

Decrypts an integer buffer to itself.

Parameters:
buf - buffer to decrypt

decrypt

public void decrypt(long[] inBuf,
                    int nInPos,
                    long[] outBuf,
                    int nOutPos,
                    int nLen)
Decrypts an long buffer to another long buffer.

Parameters:
inBuf - buffer with ciphertext data
nInPos - where to start reading the ciphertext data
outBuf - buffer to write the plaintext data
nOutPos - where to start writing the plaintext data
nLen - number of longs to decrypt

decrypt

public void decrypt(long[] inBuf,
                    long[] outBuf)
Deprecated. use decrypt(long[], int, long[], int, int) instead

Decrypts a long buffer to another long buffer (of the same size or bigger).

Parameters:
inBuf - buffer with ciphertext data
outBuf - buffer to get the plaintext data

decrypt

public void decrypt(long[] buf)
Deprecated. use decrypt(long[], int, long[], int, int) instead

Decrypts a long buffer to itself.

Parameters:
buf - buffer to decrypt


Copyright © 2004-2005 Sourceforge. All Rights Reserved.