org.logi.crypto.modes
Interface EncryptSession

All Known Implementing Classes:
org.logi.crypto.modes.EncryptMode

public interface EncryptSession

Descendants of EncryptSession encrypt arbtrarily large arrays of plaintext. A corresponding DecryptSession should be used for decryption.

Most EncryptSessions 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:
DecryptSession

Method Summary
 byte[] encrypt(byte[] source, int i, int length)
          Send bytes to the EncryptMode for encryption.
 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().
 EncryptionKey getKey()
          Return the key used for encryption.
 int plainBlockSize()
          Return the size of the blocks of plaintext encrypted by this object.
 void setKey(EncryptionKey key)
          Set the key to use for encryption.
 

Method Detail

getKey

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

setKey

public void setKey(EncryptionKey key)
            throws CryptoException
Set the key to use for encryption. 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 encrypted by this object.

flush

public byte[] flush()
             throws PaddingException
Pads the internal buffer, encrypts it and returns the ciphertext. Also releases any and all resources.

flush

public byte[] flush(byte[] source,
                    int i,
                    int length)
             throws PaddingException
Equivalent to calling encrypt(source,i,length) followed by flush(). Also releases any and all resources.

encrypt

public 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.



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