|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectxjava.security.IJCE_Traceable
xjava.security.Cipher
xjava.security.Mode
cryptix.provider.mode.FeedbackMode
cryptix.provider.mode.OFB
Implements a byte-oriented stream cipher using n-bit OFB with an n-bit-sized block cipher.
The full block size of the supplied cipher is used for the Output Feedback Mode. The bytes supplied are processed and returned immediately.
References:
sci.crypt FAQ, "Part 5: Product Ciphers,"
ftp://ftp.rtfm.mit.edu/pub/usenet/news.answers/cryptography-faq/part05
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.6 $
| Field Summary | |
|---|---|
protected int |
currentByte
Index into the ivBlock. |
protected byte[] |
ivBlock
Value of the current feedback register/queue/buffer. |
protected byte[] |
ivStart
Value of the IV at initialisation phase as supplied by user. |
protected int |
length
Size of the feedback register/queue/buffer. |
| Fields inherited from class xjava.security.Mode |
|---|
cipher |
| Fields inherited from class xjava.security.Cipher |
|---|
DECRYPT, ENCRYPT, UNINITIALIZED |
| Constructor Summary | |
|---|---|
OFB()
Constructs an OFB cipher, assuming that the IV will be provided via setInitializationVector. |
|
OFB(Cipher cipher)
Constructs an OFB cipher, assuming that the IV will be provided via setInitializationVector. |
|
OFB(Cipher cipher,
byte[] iv)
Constructs a OFB cipher, using an initialization vector provided in the constructor. |
|
| Method Summary | |
|---|---|
protected int |
engineBlockSize()
SPI: Returns the length of a block, in bytes. |
protected void |
engineInitDecrypt(java.security.Key newkey)
SPI: Initializes this cipher for decryption, using the specified key. |
protected void |
engineInitEncrypt(java.security.Key newkey)
SPI: Initializes this cipher for encryption, using the specified key. |
protected void |
engineSetCipher(Cipher cipher)
SPI: Sets the underlying cipher. |
protected int |
engineUpdate(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
SPI: This is the main engine method for updating data. |
byte[] |
getInitializationVector()
Gets a copy of the starting initialization vector. |
int |
getInitializationVectorLength()
Returns the size of the initialization vector expected by setInitializationVector. |
void |
setInitializationVector(byte[] iv)
Sets the initialization vector. |
| Methods inherited from class xjava.security.Mode |
|---|
engineGetParameter, engineSetParameter, getAlgorithms, getAlgorithms, getInstance, getInstance, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected byte[] ivBlock
protected byte[] ivStart
protected int currentByte
protected int length
| Constructor Detail |
public OFB()
setInitializationVector.
The IV value must be unique during the lifetime of the key. If it is not unique, and an attacker has access to a different message encrypted under the same IV and key, all of the plaintext can normally be recovered.
public OFB(Cipher cipher)
setInitializationVector.
See the previous constructor for more details.
cipher - the cipher object to use in OFB mode.
java.lang.NullPointerException - if cipher == null
IllegalBlockSizeException - if cipher.getPlaintextBlockSize() !=
cipher.getCiphertextBlockSize()
public OFB(Cipher cipher,
byte[] iv)
The IV value must be unique during the lifetime of the key. If it is not unique, and an attacker has access to a different message encrypted under the same IV and key, all of the plaintext can normally be recovered.
cipher - the block cipher to useiv - the initial value for the shift register (IV)
java.lang.NullPointerException - if cipher == null| Method Detail |
protected int engineBlockSize()
Cipher
The value may change when initEncrypt or
initDecrypt is called, but it should not change at
other times.
engineBlockSize in class Cipher
protected void engineInitEncrypt(java.security.Key newkey)
throws java.security.KeyException
CipherAfter a call to this method, the cipher's state is set to ENCRYPT.
engineInitEncrypt in class Ciphernewkey - the key to use for encryption.
java.security.KeyException - if the key is invalid.
protected void engineInitDecrypt(java.security.Key newkey)
throws java.security.KeyException
CipherAfter a call to this method, the cipher's state is set to DECRYPT.
engineInitDecrypt in class Ciphernewkey - the key to use for decryption.
java.security.KeyException - if the key is invalid.
protected int engineUpdate(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
in and out may be the same array, and the
input and output regions may overlap.
engineUpdate in class Cipherin - the input data.inOffset - the offset into in specifying where
the data starts.inLen - the length of the subarray.out - the output array.outOffset - the offset indicating where to start writing into
the out array.
protected void engineSetCipher(Cipher cipher)
For example, to create an IDEA cipher in CBC mode, the cipher for "IDEA" would be passed to the mode for "CBC" using this method. It is called once, immediately after the mode object is constructed.
Subclasses that override this method (to do initialization that
depends on the cipher being set) should call
super.engineSetCipher(cipher) first.
engineSetCipher in class Modecipher - the underlying cipher object
java.lang.NullPointerException - if cipher == null
public void setInitializationVector(byte[] iv)
throws java.security.InvalidParameterException
Note: in JavaSoft's version of JCE, this method may only be
called when the cipher is in the UNINITIALIZED state.
In IJCE that is relaxed to also allow it to be called after
initEncrypt/initDecrypt, but before the
first call to update or crypt, provided
that the IV is not set twice.
setInitializationVector in interface FeedbackCipheriv - the initialization vector.
java.security.InvalidParameterException - if the initialization vector
is of the wrong length or has already been set.public byte[] getInitializationVector()
getInitializationVector in interface FeedbackCipherpublic int getInitializationVectorLength()
setInitializationVector. For this class, that is
the block size of the underlying cipher.
getInitializationVectorLength in interface FeedbackCiphersetInitializationVector.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||