Class JceBlockCipherWithCBCImplicitIVImpl
java.lang.Object
org.bouncycastle.tls.crypto.impl.jcajce.JceBlockCipherWithCBCImplicitIVImpl
- All Implemented Interfaces:
TlsBlockCipherImpl
A basic wrapper for a JCE Cipher class to provide the needed block cipher functionality for TLS where the
cipher requires the IV to be continued between calls.
-
Constructor Summary
ConstructorsConstructorDescriptionJceBlockCipherWithCBCImplicitIVImpl(JcaTlsCrypto crypto, Cipher cipher, String algorithm, boolean isEncrypting) -
Method Summary
Modifier and TypeMethodDescriptionintdoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) Perform the cipher encryption/decryption returning the output in output.intReturn the blocksize (in bytes) of the underlying block cipher.voidinit(byte[] iv, int ivOff, int ivLen) Initialise the parameters for operator.voidsetKey(byte[] key, int keyOff, int keyLen) Set the key to be used by the block cipher implementation supporting this service.
-
Constructor Details
-
JceBlockCipherWithCBCImplicitIVImpl
public JceBlockCipherWithCBCImplicitIVImpl(JcaTlsCrypto crypto, Cipher cipher, String algorithm, boolean isEncrypting) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
-
Method Details
-
setKey
public void setKey(byte[] key, int keyOff, int keyLen) Description copied from interface:TlsBlockCipherImplSet the key to be used by the block cipher implementation supporting this service.- Specified by:
setKeyin interfaceTlsBlockCipherImpl- Parameters:
key- array holding the block cipher key.keyOff- offset into the array the key starts at.keyLen- length of the key in the array.
-
init
public void init(byte[] iv, int ivOff, int ivLen) Description copied from interface:TlsBlockCipherImplInitialise the parameters for operator.- Specified by:
initin interfaceTlsBlockCipherImpl- Parameters:
iv- array holding the initialization vector (IV).ivOff- offset into the array the IV starts at.ivLen- length of the IV in the array.
-
doFinal
public int doFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) Description copied from interface:TlsBlockCipherImplPerform the cipher encryption/decryption returning the output in output.Note: we have to use doFinal() here as it is the only way to guarantee output from the underlying cipher.
- Specified by:
doFinalin interfaceTlsBlockCipherImpl- Parameters:
input- array holding input data to the cipher.inputOffset- offset into input array data starts at.inputLength- length of the input data in the array.output- array to hold the cipher output.outputOffset- offset into output array to start saving output.- Returns:
- the amount of data written to output.
-
getBlockSize
public int getBlockSize()Description copied from interface:TlsBlockCipherImplReturn the blocksize (in bytes) of the underlying block cipher.- Specified by:
getBlockSizein interfaceTlsBlockCipherImpl- Returns:
- the cipher's blocksize.
-