ewe.security
Class BlowfishCBC

java.lang.Object
  extended byewe.security.BlowfishECB
      extended byewe.security.BlowfishCBC

public class BlowfishCBC
extends BlowfishECB

Implementation of the Blowfish encryption algorithm in CBC mode.


Field Summary
 
Fields inherited from class ewe.security.BlowfishECB
BLOCKSIZE, MAXKEYLENGTH
 
Constructor Summary
BlowfishCBC(byte[] key)
          Default constructor, uses a zero CBC IV.
BlowfishCBC(byte[] key, byte[] initCBCIV)
          Deprecated. use BlowfishCBC(byte[], int, int, byte[], int) instead
BlowfishCBC(byte[] key, int nOfs, int nLen)
          Constructor, uses a zero CBC IV.
BlowfishCBC(byte[] key, int nOfs, int nLen, byte[] initCBCIV, int nIVOfs)
          Constructor to define the CBC IV.
BlowfishCBC(byte[] key, int nOfs, int nLen, long lInitCBCIV)
          Constructor to define the CBC IV.
BlowfishCBC(byte[] key, long lInitCBCIV)
          Deprecated. use BlowfishCBC(byte[], int, int, long) instead
 
Method Summary
 void cleanUp()
          see BlowfishJ.BlowfishECB#cleanUp()
 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.
 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.
 long getCBCIV()
          Gets the current CBC IV.
 void getCBCIV(byte[] dest)
          Deprecated. use getCBCIV(byte[], int) instead
 void getCBCIV(byte[] dest, int nOfs)
          Gets a copy of the current CBC IV.
 void reset(byte[] key, int offset, int length)
          Reset the Encryptor/Decryptor using a specific key.
 void setCBCIV(byte[] newCBCIV)
          Deprecated. use setCBCIV(byte[], int) instead
 void setCBCIV(byte[] newCBCIV, int nOfs)
          Sets the current CBC IV (for cipher resets).
 void setCBCIV(long lNewCBCIV)
          Sets the current CBC IV (for cipher resets).
 
Methods inherited from class ewe.security.BlowfishECB
byteArrayToInt, encryptPrv, initialize, reset, weakKeyCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

BlowfishCBC

public BlowfishCBC(byte[] key)
Default constructor, uses a zero CBC IV.

Parameters:
key - key material, up to MAXKEYLENGTH bytes

BlowfishCBC

public BlowfishCBC(byte[] key,
                   int nOfs,
                   int nLen)
Constructor, uses a zero CBC IV.

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

BlowfishCBC

public BlowfishCBC(byte[] key,
                   long lInitCBCIV)
Deprecated. use BlowfishCBC(byte[], int, int, long) instead

Constructor to define the CBC IV.

Parameters:
key - key material, up to MAXKEYLENGTH bytes
lInitCBCIV - the CBC IV

BlowfishCBC

public BlowfishCBC(byte[] key,
                   int nOfs,
                   int nLen,
                   long lInitCBCIV)
Constructor to define the CBC IV.

Parameters:
key - key material, up to MAXKEYLENGTH bytes
nOfs - where to start reading the key
nLen - size of the key in bytes
lInitCBCIV - the CBC IV

BlowfishCBC

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

Constructor to define the CBC IV.

Parameters:
key - key material, up to MAXKEYLENGTH bytes
initCBCIV - the CBC IV (array with BLOCKSIZE bytes)

BlowfishCBC

public BlowfishCBC(byte[] key,
                   int nOfs,
                   int nLen,
                   byte[] initCBCIV,
                   int nIVOfs)
Constructor to define the CBC IV.

Parameters:
key - key material, up to MAXKEYLENGTH bytes
nOfs - where to start reading the key
nLen - size of the key in bytes
initCBCIV - the CBC IV
nIVOfs - where to start reading the IV
Method Detail

getCBCIV

public long getCBCIV()
Gets the current CBC IV.

Returns:
current CBC IV

getCBCIV

public void getCBCIV(byte[] dest)
Deprecated. use getCBCIV(byte[], int) instead

Gets a copy of the current CBC IV.

Parameters:
dest - where to put current CBC IV

getCBCIV

public void getCBCIV(byte[] dest,
                     int nOfs)
Gets a copy of the current CBC IV.

Parameters:
dest - buffer
nOfs - where to start writing

setCBCIV

public void setCBCIV(long lNewCBCIV)
Sets the current CBC IV (for cipher resets).

Parameters:
lNewCBCIV - the new CBC IV

setCBCIV

public void setCBCIV(byte[] newCBCIV)
Deprecated. use setCBCIV(byte[], int) instead

Sets the current CBC IV (for cipher resets).

Parameters:
newCBCIV - the new CBC IV

setCBCIV

public void setCBCIV(byte[] newCBCIV,
                     int nOfs)
Sets the current CBC IV (for cipher resets).

Parameters:
newCBCIV - the new CBC IV
nOfs - where to start reading the IV

reset

public void reset(byte[] key,
                  int offset,
                  int length)
Description copied from class: BlowfishECB
Reset the Encryptor/Decryptor using a specific key.

Overrides:
reset in class BlowfishECB

cleanUp

public void cleanUp()
see BlowfishJ.BlowfishECB#cleanUp()

Overrides:
cleanUp in class BlowfishECB

encrypt

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

Overrides:
encrypt in class BlowfishECB
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
See Also:
BlowfishJ.BlowfishECB#encrypt(byte[], int, byte[], int, int)

decrypt

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

Overrides:
decrypt in class BlowfishECB
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
See Also:
BlowfishJ.BlowfishECB#decrypt(byte[], int, byte[], int, int)