org.logi.crypto.modes
Class DecryptECB

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

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

Use this class to decrypt ciphertext generated by EncryptECB.

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.

A padding engine can be passed to the constructor of the DecryptCBC object and should be the same as was used to encrypt the data. If no padding engine is given, then the padding used depends on the key class being used. The default padding is chosen in the same way as for EncryptCBC.

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

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
DecryptECB()
          Create a new ECB-mode decrypt session with no key and default padding.
DecryptECB(DecryptionKey key)
          Create a new ECB-mode decrypt session with default padding.
DecryptECB(DecryptionKey key, Padding padding)
          Create a new ECB-mode decrypt session.
DecryptECB(Padding padding)
          Create a new ECB-mode decrypt session with no key.
 
Method Summary
 byte[] decrypt(byte[] source, int i, int length)
          Send bytes to the DecryptECB object for decryption.
 byte[] flush()
          Flush any buffers internal to the DecryptSession object and releases any and all resources.
 byte[] flush(byte[] source, int i, int length)
          Decrypt the last part of ciphertext and return plaintext.
 DecryptionKey getKey()
          Return the key used for decryption.
 int plainBlockSize()
          Return the size of the blocks of plaintext output by this object.
 void setKey(DecryptionKey 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

DecryptECB

public DecryptECB(DecryptionKey key,
                  Padding padding)
Create a new ECB-mode decrypt session.
Parameters:
key - The key to use for decryption.
padding - The padding engine to use.

DecryptECB

public DecryptECB(DecryptionKey key)
Create a new ECB-mode decrypt session with default padding.
Parameters:
key - The key to use for decryption.
padding - The padding engine to use.

DecryptECB

public DecryptECB(Padding padding)
Create a new ECB-mode decrypt session with no key. No decryption can be performed until a call to setKey() has been made.
Parameters:
padding - The padding engine to use.

DecryptECB

public DecryptECB()
Create a new ECB-mode decrypt session with no key and default padding. No decryption can be performed until a call to setKey() has been made.
Parameters:
padding - The padding engine to use.
Method Detail

getKey

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

setKey

public void setKey(DecryptionKey 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 DecryptECB 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.


flush

public byte[] flush()
             throws CryptoException,
                    PaddingException
Description copied from interface: DecryptSession
Flush any buffers internal to the DecryptSession object and releases any and all resources.

flush

public byte[] flush(byte[] source,
                    int i,
                    int length)
             throws CryptoException
Decrypt the last part of ciphertext and return plaintext. This will flush any buffers internal to the DecryptSession object.
Specified by:
flush in interface DecryptSession


Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL