|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.flexiprovider.api.Mode
The abstract class Mode is the base for all modes implemented in the package cdc. It defines the set of methods which have to be implemented to cooperate with the BasicCipher class. Each class that implements such a mode has to exist in the package "de.flexiprovider.common.mode" and the classname must be the same as the name used in the call of Cipher.getInstance(). e.g. if you call Cipher.getInstance("SAFER+/CBC/NoPadding"), the code will look for the class de.flexiprovider.common.mode.CBC
| Field Summary | |
protected int |
blockSize
The block size of the mode |
protected byte[] |
iv
The initialization vector |
| Constructor Summary | |
Mode()
|
|
| Method Summary | |
protected int |
getCipherBlockSize()
Return the block size of the underlying cipher. |
protected void |
initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec cipherParams)
Initialize the block cipher for decryption. |
protected void |
initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec cipherParams)
Initialize the block cipher for encryption. |
protected abstract void |
initDecrypt(SecretKey key,
ModeParameterSpec modeParams,
AlgorithmParameterSpec cipherParams)
Initialize the Mode object for decryption and compute the mode block size. |
protected abstract void |
initEncrypt(SecretKey key,
ModeParameterSpec modeParams,
AlgorithmParameterSpec cipherParams)
Initialize the Mode object for encryption and compute the mode block size. |
protected abstract void |
nextChunkDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
Decrypt the next data block. |
protected abstract void |
nextChunkEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
Encrypt the next data block. |
protected abstract void |
reset()
reset() is called after doFinal() in order to prepare the mode for the next operation. |
(package private) void |
setBlockCipher(BlockCipher blockCipher)
Set the BlockCipher to use with this mode. |
protected void |
singleBlockDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
Decrypt a single block with the cipher engine. |
protected void |
singleBlockEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
Encrypt a single block with the cipher engine. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected byte[] iv
protected int blockSize
| Constructor Detail |
public Mode()
| Method Detail |
final void setBlockCipher(BlockCipher blockCipher)
BlockCipher to use with this mode.blockCipher - the block cipher
protected abstract void initEncrypt(SecretKey key,
ModeParameterSpec modeParams,
AlgorithmParameterSpec cipherParams)
throws InvalidKeyException,
InvalidAlgorithmParameterException
BlockCipher.getCipherBlockSize() after initialization.key - the key used for encryptionmodeParams - additional mode parameterscipherParams - additional algorithm parametersInvalidKeyException - if the key is inappropriate for initializing the
underlying block cipher.InvalidAlgorithmParameterException - if the parameters are inappropriate for initializing the
underlying block cipher.
protected abstract void initDecrypt(SecretKey key,
ModeParameterSpec modeParams,
AlgorithmParameterSpec cipherParams)
throws InvalidKeyException,
InvalidAlgorithmParameterException
BlockCipher.getCipherBlockSize() after initialization.key - the key used for decryptionmodeParams - additional mode parameterscipherParams - additional algorithm parametersInvalidKeyException - if the key is inappropriate for initializing the
underlying block cipher.InvalidAlgorithmParameterException - if the parameters are inappropriate for initializing the
underlying block cipher.
protected abstract void nextChunkEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
input - input data bufferinOff - input data offsetoutput - output data bufferoutOff - output data offset
protected abstract void nextChunkDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
input - input data bufferinOff - input data offsetoutput - output data bufferoutOff - output data offsetprotected abstract void reset()
protected final void initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec cipherParams)
throws InvalidKeyException,
InvalidAlgorithmParameterException
key - the secret key to use for encryptioncipherParams - the parametersInvalidKeyException - if the given key is inappropriate for this cipher.InvalidAlgorithmParameterException - if the given parameters are inappropriate for this
cipher.
protected final void initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec cipherParams)
throws InvalidKeyException,
InvalidAlgorithmParameterException
key - the secret key to use for decryptioncipherParams - the parametersInvalidKeyException - if the given key is inappropriate for this cipher.InvalidAlgorithmParameterException - if the given parameters are inappropriate for this
cipher.protected final int getCipherBlockSize()
BlockCipher.getCipherBlockSize() after initialization.
protected final void singleBlockEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
input - array of bytes which contains the plaintext to be
encryptedinOff - index in array in, where the plaintext block startsoutput - array of bytes which will contain the ciphertext startig
at outOffsetoutOff - index in array out, where the ciphertext block will start
protected final void singleBlockDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
input - array of bytes which contains the ciphertext to be
decryptedinOff - index in array in, where the ciphertext block startsoutput - array of bytes which will contain the plaintext starting
at outOffsetoutOff - index in array out, where the plaintext block will start
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||