|
Cumulus4j API (1.1.0) |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.cumulus4j.crypto.AbstractCipher
public abstract class AbstractCipher
Abstract base class for Cipher
implementations. Implementors should not implement
the Cipher
interface directly, but sub-class this class instead.
Constructor Summary | |
---|---|
protected |
AbstractCipher(String transformation)
|
Method Summary | |
---|---|
protected abstract void |
_init(CipherOperationMode mode,
CipherParameters parameters)
|
byte[] |
doFinal(byte[] in)
Convenience method to encrypt/decrypt the complete input byte array at once. |
CipherOperationMode |
getMode()
Get the mode of this cipher. |
CipherParameters |
getParameters()
Get the parameters of this cipher. |
String |
getTransformation()
Get the transformation that was passed to CryptoRegistry.createCipher(String)
for obtaining this Cipher . |
void |
init(CipherOperationMode mode,
CipherParameters parameters)
Initialise the cipher. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.cumulus4j.crypto.Cipher |
---|
doFinal, getInputBlockSize, getIVSize, getOutputBlockSize, getOutputSize, getUpdateOutputSize, reset, update, update |
Constructor Detail |
---|
protected AbstractCipher(String transformation)
Method Detail |
---|
public final String getTransformation()
Cipher
CryptoRegistry.createCipher(String)
for obtaining this Cipher
.
getTransformation
in interface Cipher
public byte[] doFinal(byte[] in) throws DataLengthException, IllegalStateException, CryptoException
Cipher
Cipher.reset()
implicitly.
doFinal
in interface Cipher
in
- the input to be encrypted or decrypted. Must not be null
.
IllegalStateException
- if the cipher isn't initialised.
CryptoException
- if padding is expected and not found or sth. else goes wrong while encrypting or decrypting.
DataLengthException
public final void init(CipherOperationMode mode, CipherParameters parameters) throws IllegalArgumentException
Cipher
Initialise the cipher.
A cipher cannot be used, before this method was called.
A cipher can be re-initialised to modify only certain parameters (and keep the others). For example to modify
the IV while keeping the key, a cipher can
be re-initialised with an IV only (i.e. null
is passed to
ParametersWithIV.ParametersWithIV(CipherParameters, byte[], int, int)
instead of a KeyParameter
).
This is useful for performance reasons, because modifying an IV is a very fast operation while changing the key is
slow (especially Blowfish is known for its very
slow key initialisation).
init
in interface Cipher
mode
- the operation mode; must not be null
.parameters
- the parameters; for example an instance of ParametersWithIV
with a wrapped KeyParameter
to pass IV and secret key.
IllegalArgumentException
- if the given arguments are invalid - for example if the given parameters
are not understood by the implementation (parameters not compatible with the chosen algorithm).public CipherOperationMode getMode()
Cipher
null
, before
Cipher.init(CipherOperationMode, CipherParameters)
was called the first
time.
getMode
in interface Cipher
public CipherParameters getParameters()
Cipher
null
, before
Cipher.init(CipherOperationMode, CipherParameters)
was called the first
time.
getParameters
in interface Cipher
protected abstract void _init(CipherOperationMode mode, CipherParameters parameters) throws IllegalArgumentException
IllegalArgumentException
|
Cumulus4j API (1.1.0) |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |