public class CFB extends FeedbackMode
The full block size of the supplied cipher is used for the Cipher Feedback Mode. The bytes supplied are processed and returned immediately.
References:
Copyright © 1995-1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.5 $
currentByte, ivBlock, ivStart, length
DECRYPT, ENCRYPT, UNINITIALIZED
Constructor and Description |
---|
CFB()
Constructs a CFB mode object.
|
CFB(Cipher cipher)
Constructs a CFB cipher, assuming that the IV will be provided
via
setInitializationVector . |
CFB(Cipher cipher,
byte[] iv)
Constructs a CFB cipher, using an initialization vector
provided in the constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
next_block()
Rotates the IV left by currentByte bytes, to mimic the V2.2
behaviour.
|
getInitializationVector, getInitializationVectorLength, setInitializationVector
engineGetParameter, engineSetParameter, getAlgorithms, getAlgorithms, getInstance, getInstance, toString
blockSize, clone, crypt, crypt, crypt, doFinal, doFinal, doFinal, doFinal, engineCiphertextBlockSize, engineCrypt, engineInBufferSize, engineOutBufferSize, enginePlaintextBlockSize, engineSetPaddingScheme, getAlgorithm, getCiphertextBlockSize, getInputBlockSize, getInstance, getMode, getOutputBlockSize, getPadding, getPaddingScheme, getParameter, getPlaintextBlockSize, getProvider, getState, inBufferSize, inBufferSizeFinal, initDecrypt, initEncrypt, isPaddingBlockCipher, outBufferSize, outBufferSizeFinal, setParameter, update, update, update, update
public CFB()
The IV is provided via setInitializationVector
. This IV
must be unique during the lifetime of the key. If it is not
unique, at least the first block of the plaintext can be recovered.
public CFB(Cipher cipher)
setInitializationVector
.
See the previous constructor for more details.cipher
- the cipher object to use in CFB mode.java.lang.NullPointerException
- if cipher == nullpublic CFB(Cipher cipher, byte[] iv)
cipher
- the block cipher to useiv
- the initial value for the shift register (IV)java.lang.NullPointerException
- if cipher == nullprotected void engineSetCipher(Cipher cipher)
FeedbackMode
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 FeedbackMode
cipher
- the underlying cipher objectprotected 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
Cipher
After a call to this method, the cipher's state is set to ENCRYPT.
engineInitEncrypt
in class Cipher
newkey
- 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
Cipher
After a call to this method, the cipher's state is set to DECRYPT.
engineInitDecrypt
in class Cipher
newkey
- 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 Cipher
in
- 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 next_block()
CFB_PGP