All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.Crypto.CbcBlockCipher

java.lang.Object
   |
   +----Acme.Crypto.CryptoUtils
           |
           +----Acme.Crypto.Cipher
                   |
                   +----Acme.Crypto.BlockCipher
                           |
                           +----Acme.Crypto.CbcBlockCipher

public class CbcBlockCipher
extends BlockCipher
Use a block cipher in CBC mode.

A plain old block cipher, key and cleartext-block in, ciphertext-block out, is said to be in Electronic Code Book (ECB) mode. A given block of plaintext always encrypts to the same block of ciphertext. This makes it somewhat vulnerable to known plaintext attacks, block replay attacks, etc.

A fairly cheap alternative is to use it in Cipher Block Chaining (CBC) mode. All this does is XOR each plaintext block with the previous ciphertext block before encryption. For the first block, where there is no previous ciphertext block, a caller-specified Initialization Vector (IV) is used for the XOR. This makes each block's encryption depend on all the previous blocks

This class lets you use any given block cipher in CBC mode.

Fetch the software.
Fetch the entire Acme package.

See Also:
Cipher, BlockCipher, StreamCipher, EncryptedOutputStream, EncryptedInputStream

Constructor Index

 o CbcBlockCipher(BlockCipher)
Constructor.

Method Index

 o decrypt(byte[], int, byte[], int)
Decrypt a block of bytes.
 o encrypt(byte[], int, byte[], int)
Encrypt a block of bytes.
 o setIv(byte[])
Set the Initialization Vector.
 o setKey(byte[])
Set the key from a block of bytes.
 o setRandomIv()
Set and return a random IV.

Constructors

 o CbcBlockCipher
 public CbcBlockCipher(BlockCipher blockCipher)
Constructor.

Methods

 o setKey
 public void setKey(byte key[])
Set the key from a block of bytes.

Overrides:
setKey in class Cipher
 o setIv
 public void setIv(byte iv[])
Set the Initialization Vector.

 o setRandomIv
 public byte[] setRandomIv()
Set and return a random IV. In CBC mode, the IV does not have to be kept secret. Typical usage is for the caller to set a random IV and then transmit it as the first block of the message.

 o encrypt
 public void encrypt(byte clearText[],
                     int clearOff,
                     byte cipherText[],
                     int cipherOff)
Encrypt a block of bytes.

Overrides:
encrypt in class BlockCipher
 o decrypt
 public void decrypt(byte cipherText[],
                     int cipherOff,
                     byte clearText[],
                     int clearOff)
Decrypt a block of bytes.

Overrides:
decrypt in class BlockCipher

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs