Class BaseCipherSpi
java.lang.Object
javax.crypto.CipherSpi
org.bouncycastle.jcajce.provider.asymmetric.util.BaseCipherSpi
- Direct Known Subclasses:
CipherSpi
public abstract class BaseCipherSpi extends CipherSpi
-
Field Summary
Fields Modifier and Type Field Description protected AlgorithmParametersengineParamsprotected WrapperwrapEngine -
Constructor Summary
Constructors Modifier Constructor Description protectedBaseCipherSpi() -
Method Summary
Modifier and Type Method Description protected intengineGetBlockSize()Returns the block size of this cipher (in bytes)protected byte[]engineGetIV()Returns the Initialization Vector (IV) that was used to initialize this cipher ornullif none was used.protected intengineGetKeySize(Key key)Returns the size of a specified key object in bits.protected intengineGetOutputSize(int inputLen)Returns the size for a buffer (in bytes), that the next call toupdateofdoFinalwould return, taking into account any buffered data from previousupdatecalls and padding.protected AlgorithmParametersengineGetParameters()Returns the parameters that where used to create this cipher instance.protected voidengineSetMode(String mode)Sets the mode for this cipher.protected voidengineSetPadding(String padding)Sets the padding method for this cipher.protected KeyengineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)Unwraps a key using this cipher instance.protected byte[]engineWrap(Key key)Wraps a key using this cipher instance.Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineDoFinal, engineDoFinal, engineInit, engineInit, engineInit, engineUpdate, engineUpdate, engineUpdate, engineUpdateAAD, engineUpdateAAD
-
Field Details
-
engineParams
-
wrapEngine
-
-
Constructor Details
-
BaseCipherSpi
protected BaseCipherSpi()
-
-
Method Details
-
engineGetBlockSize
protected int engineGetBlockSize()Description copied from class:CipherSpiReturns the block size of this cipher (in bytes)- Specified by:
engineGetBlockSizein classCipherSpi- Returns:
- the block size of this cipher, or zero if this cipher is not a block cipher.
-
engineGetIV
protected byte[] engineGetIV()Description copied from class:CipherSpiReturns the Initialization Vector (IV) that was used to initialize this cipher ornullif none was used.- Specified by:
engineGetIVin classCipherSpi- Returns:
- the Initialization Vector (IV), or
nullif none was used.
-
engineGetKeySize
Description copied from class:CipherSpiReturns the size of a specified key object in bits. This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws anUnsupportedOperationException.- Overrides:
engineGetKeySizein classCipherSpi- Parameters:
key- the key to get the size for.- Returns:
- the size of a specified key object in bits.
-
engineGetOutputSize
protected int engineGetOutputSize(int inputLen)Description copied from class:CipherSpiReturns the size for a buffer (in bytes), that the next call toupdateofdoFinalwould return, taking into account any buffered data from previousupdatecalls and padding.The actual output length of the next call to
updateordoFinalmay be smaller than the length returned by this method.- Specified by:
engineGetOutputSizein classCipherSpi- Parameters:
inputLen- the length of the input (in bytes).- Returns:
- the size for a buffer (in bytes).
-
engineGetParameters
Description copied from class:CipherSpiReturns the parameters that where used to create this cipher instance.These may be a the same parameters that were used to create this cipher instance, or may be a combination of default and random parameters, depending on the underlying cipher implementation.
- Specified by:
engineGetParametersin classCipherSpi- Returns:
- the parameters that where used to create this cipher instance, or
nullif this cipher instance does not have any parameters at all.
-
engineSetMode
Description copied from class:CipherSpiSets the mode for this cipher.- Specified by:
engineSetModein classCipherSpi- Parameters:
mode- the name of the cipher mode.- Throws:
NoSuchAlgorithmException- if the specified cipher mode is not supported by this provider.
-
engineSetPadding
Description copied from class:CipherSpiSets the padding method for this cipher.- Specified by:
engineSetPaddingin classCipherSpi- Parameters:
padding- the name of the padding method.- Throws:
NoSuchPaddingException- if the specified padding method is not supported by this cipher.
-
engineWrap
Description copied from class:CipherSpiWraps a key using this cipher instance. This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws anUnsupportedOperationException.- Overrides:
engineWrapin classCipherSpi- Parameters:
key- the key to wrap.- Returns:
- the wrapped key
- Throws:
IllegalBlockSizeException- if the size of the resulting bytes is not a multiple of the cipher block size.InvalidKeyException- if this cipher instance cannot wrap this key.
-
engineUnwrap
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyExceptionDescription copied from class:CipherSpiUnwraps a key using this cipher instance.This method has been added to this class (for backwards compatibility, it cannot be abstract). If this method is not overridden, it throws an
UnsupportedOperationException.- Overrides:
engineUnwrapin classCipherSpi- Parameters:
wrappedKey- the wrapped key to unwrap.wrappedKeyAlgorithm- the algorithm for the wrapped key.wrappedKeyType- the type of the wrapped key (one of:SECRET_KEY,PRIVATE_KEYorPUBLIC_KEY)- Returns:
- the unwrapped key.
- Throws:
InvalidKeyException- if thewrappedKeycannot be unwrapped to a key of typewrappedKeyTypefor thewrappedKeyAlgorithm.
-