|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xjava.security.IJCE_Traceable | +--xjava.security.Cipher | +--xjava.security.Mode | +--cryptix.provider.mode.FeedbackMode | +--cryptix.provider.mode.CBC
Implements a block cipher in CBC mode. The block size is the same as that of the underlying cipher.
References:
Copyright © 1997, 1998
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.7 $
Field Summary | |
protected byte[] |
xorBlock
Temporary buffer to hold input bytes when there's not enough of them to cipher. |
Fields inherited from class cryptix.provider.mode.FeedbackMode |
currentByte, ivBlock, ivStart, length |
Fields inherited from class xjava.security.Mode |
cipher |
Fields inherited from class xjava.security.Cipher |
DECRYPT, ENCRYPT, UNINITIALIZED |
Fields inherited from class xjava.security.IJCE_Traceable |
tracing |
Constructor Summary | |
CBC()
Constructs a CBC cipher, assuming that the IV will be provided via setInitializationVector .
|
|
CBC(Cipher cipher)
Constructs a CBC cipher, assuming that the IV will be provided via setInitializationVector .
|
|
CBC(Cipher cipher,
byte[] iv)
Constructs a CBC 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. |
Methods inherited from class cryptix.provider.mode.FeedbackMode |
getInitializationVector, getInitializationVectorLength, setInitializationVector |
Methods inherited from class xjava.security.Mode |
engineGetParameter, engineSetParameter, getAlgorithms, getAlgorithms, getInstance, getInstance, toString |
Methods inherited from class xjava.security.IJCE_Traceable |
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected byte[] xorBlock
Constructor Detail |
public CBC()
setInitializationVector
.
The IV value should be random, but unlike CFB mode, it is not absolutely required to be unique.
public CBC(Cipher cipher)
setInitializationVector
.
See the previous constructor for more details.cipher
- the cipher object to use in CBC mode.NullPointerException
- if cipher == nullIllegalBlockSizeException
- if cipher.getPlaintextBlockSize() !=
cipher.getCiphertextBlockSize()public CBC(Cipher cipher, byte[] iv)
For CBC mode the IV value should be random, but unlike CFB mode, it is not absolutely required to be unique.
cipher
- the block cipher to useiv
- the initial value for the shift register (IV)NullPointerException
- if cipher == nullMethod Detail |
protected 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
cryptix.provider.mode.FeedbackMode
cipher
- the underlying cipher objectNullPointerException
- if cipher == nullprotected 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
xjava.security.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
xjava.security.Cipher
key
- 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
xjava.security.Cipher
key
- 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |