org.logi.crypto.modes
Class DecryptOFB

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

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

Use this class to decrypt ciphertext generated by EncryptOFB.

Note that unlike ECB or CBC mode, OFB mode uses teh same key to encrypt and decrypt, even with asymmetric ciphers.

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

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
DecryptOFB(DecryptionKey key, int bufSize)
          Create a new OFB-mode decrypt session with the specified key.
DecryptOFB(int bufSize)
          Create a new OFB-mode decrypt session with no key.
 
Method Summary
 byte[] decrypt(byte[] source, int i, int length)
          Send bytes to the DecryptOFB object for encryption.
 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 encryption.
 int plainBlockSize()
          Return the size of the blocks of plaintext output by this object.
 void setKey(DecryptionKey key)
          Set the key to use for encryption.
 
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

DecryptOFB

public DecryptOFB(DecryptionKey key,
                  int bufSize)
           throws KeyException
Create a new OFB-mode decrypt session with the specified key. A buffer of bufSize bytes is created to hold a pre-calculated xor-stream.

DecryptOFB

public DecryptOFB(int bufSize)
Create a new OFB-mode decrypt session with no key. No encryption can be performed until the setKey() method has been called.

A buffer of bufSize bytes is created to hold a pre-calculated xor-stream.

Method Detail

getKey

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

setKey

public void setKey(DecryptionKey key)
Set the key to use for encryption. The key can only be set once in this version of the library. The 1.1.x and eventually 1.2.x series allows dynamic re-keying.
Following copied from interface: org.logi.crypto.modes.DecryptSession
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 DecryptOFB object for encryption.

Decrypt length bytes from source, starting at i and return the plaintext.


flush

public byte[] flush()
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