org.logi.crypto.modes
Class DecryptCBC

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.modes.DecryptMode
              |
              +--org.logi.crypto.modes.DecryptCBC
All Implemented Interfaces:
DecryptSession, PrettyPrintable

public class DecryptCBC
extends org.logi.crypto.modes.DecryptMode

Use this class to decrypt ciphertext generated by EncryptCBC.

If you are using symmetric keys, the DecryptECB object must be initialized with the same key as the EncryptECB object it is decrypting data from. If you are using asymetric keys, the DecryptECB object must be initialized with the other key from the key-pair.

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
EncryptCBC

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
DecryptCBC()
          Create a new CBC-mode decrypt session with no key.
DecryptCBC(CipherKey key)
          Create a new CBC-mode decrypt session with the specified key.
 
Method Summary
 void close()
          Close files and kill threads owned by the object.
 byte[] decrypt(byte[] source, int i, int length)
          Send bytes to the DecryptCBC object for decryption.
 CipherKey getKey()
          Return the key used for decryption.
 int plainBlockSize()
          Return the size of the blocks of plaintext output by this object.
 void setKey(CipherKey key)
          Set the key to use for decryption.
 
Methods inherited from class org.logi.crypto.Crypto
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecryptCBC

public DecryptCBC(CipherKey key)
Create a new CBC-mode decrypt session with the specified key.

DecryptCBC

public DecryptCBC()
Create a new CBC-mode decrypt session with no key. No decryption can be performed until a call to setKey() has been made.
Method Detail

getKey

public CipherKey getKey()
Return the key used for decryption.

setKey

public void setKey(CipherKey key)
            throws CryptoException
Set the key to use for decryption. Do not call this method when there may be data in the internal buffer.
Throws:
CryptoException - if there is data in the internal buffer which should be encrypted with the old key.

plainBlockSize

public int plainBlockSize()
Return the size of the blocks of plaintext output by this object.

decrypt

public byte[] decrypt(byte[] source,
                      int i,
                      int length)
Send bytes to the DecryptCBC object for decryption.

Decrypt length bytes from source, starting at i and return the plaintext. Data may be encrypted in blocks in which case only whole blocks of plaintext are written to dest. Any remaining data will be stored and prepended to source in the next call to decrypt.


close

public void close()
Description copied from interface: DecryptSession
Close files and kill threads owned by the object. This should be called to make sure all resources are freed.
Specified by:
close in interface DecryptSession


Copyright 1997-2000 Logi Ragnarsson