org.logi.crypto.modes
Class EncryptMode

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.modes.EncryptMode
Direct Known Subclasses:
EncryptCBC, EncryptCFB, EncryptECB, EncryptOFB

public abstract class EncryptMode
extends Crypto

Descendants of EncryptMode encrypt arbtrarily large arrays of plaintext. A corresponding DecryptMode should be used for decryption.

Most EncryptModes use a CipherKey object to do actual encryption and do additional computations to mask repetitions in the plaintext.

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

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
EncryptMode()
           
 
Method Summary
 void close()
          Close files and kill threads owned by the object.
abstract  byte[] encrypt(byte[] source, int i, int length)
          Send bytes to the EncryptMode for encryption.
 void finalize()
          This finalizer calls close().
abstract  byte[] flush()
          Pads the internal buffer, encrypts it and returns the ciphertext.
 byte[] flush(byte[] source, int i, int length)
          Equivalent to calling encrypt(source,i,length) followed by flush().
abstract  CipherKey getKey()
          Return the key used for encryption.
abstract  int plainBlockSize()
          Return the size of the blocks of plaintext encrypted by this object.
abstract  void setKey(CipherKey key)
          Set the key to use for encryption.
 
Methods inherited from class org.logi.crypto.Crypto
binString, binString, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, readBlock, readInt, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptMode

public EncryptMode()
Method Detail

getKey

public abstract CipherKey getKey()
Return the key used for encryption.

setKey

public abstract void setKey(CipherKey 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.

plainBlockSize

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

flush

public abstract byte[] flush()
Pads the internal buffer, encrypts it and returns the ciphertext.

flush

public byte[] flush(byte[] source,
                    int i,
                    int length)
Equivalent to calling encrypt(source,i,length) followed by flush().

encrypt

public abstract byte[] encrypt(byte[] source,
                               int i,
                               int length)
Send bytes to the EncryptMode for encryption.

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


close

public void close()
Close files and kill threads owned by the object. This should be called to make sure all resources are freed.

finalize

public void finalize()
This finalizer calls close(). Note, however, that java offers no guarantee that the finalizer is ever called.


Copyright 1997-2000 Logi Ragnarsson