All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class is.logi.crypto.modes.EncryptOFB

java.lang.Object
   |
   +----is.logi.crypto.Crypto
           |
           +----is.logi.crypto.modes.EncryptMode
                   |
                   +----is.logi.crypto.modes.EncryptOFB

public class EncryptOFB
extends EncryptMode
Output Fedback Mode iterates the encryption routine on the IV and xors the resulting stream with the plaintext to produce the ciphertext.

This is as fast as ECB or CBC mode, but has the streaming properties of CFB mode. In addition, the stream xored with the plaintext is precalculated in a separate thread, to give better response (although this does not not lower the total time spent calculating).

However, since (with plaintext P, ciphertext C and xor-stream S)

P = C ^ S,

the opponent can alter the plaintext received by changing

C' = C ^ A,

so that

P' = C' ^ S = C ^ A ^ S = P ^ A

is seen. But the opponent will not be able to learn P or control what P' is.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
DecryptOFB

Constructor Index

 o EncryptOFB(CipherKey, int)
Create a new OFB-mode encrypt session with the specified key.
 o EncryptOFB(int)
Create a new OFB-mode encrypt session with no key.

Method Index

 o encrypt(byte[], int, int)
Send bytes to the EncryptOFB object for encryption.
 o flush()
Padds the internal buffer, encrypts it and returns the ciphertext.
 o getKey()
Return the key used for encryption.
 o setKey(CipherKey)
Set the key to use for encryption.

Constructors

 o EncryptOFB
 public EncryptOFB(CipherKey key,
                   int bufSize)
Create a new OFB-mode encrypt session with the specified key. A buffer of bufSize bytes is created to hold a pre-calculated xor-stream.

 o EncryptOFB
 public EncryptOFB(int bufSize)
Create a new OFB-mode encrypt 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.

Methods

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

Overrides:
getKey in class EncryptMode
 o setKey
 public synchronized void setKey(CipherKey key)
Set the key to use for encryption.

Overrides:
setKey in class EncryptMode
 o flush
 public synchronized byte[] flush()
Padds the internal buffer, encrypts it and returns the ciphertext. Since CBF mode doesn't use an internal buffer, an empty array is returned.

Overrides:
flush in class EncryptMode
 o encrypt
 public synchronized byte[] encrypt(byte source[],
                                    int i,
                                    int length)
Send bytes to the EncryptOFB object for encryption.

Encrypt length bytes from source, starting at i and return the ciphertext.

Overrides:
encrypt in class EncryptMode

All Packages  Class Hierarchy  This Package  Previous  Next  Index