Class JceBlockCipherWithCBCImplicitIVImpl

java.lang.Object
org.bouncycastle.tls.crypto.impl.jcajce.JceBlockCipherWithCBCImplicitIVImpl
All Implemented Interfaces:
TlsBlockCipherImpl

public class JceBlockCipherWithCBCImplicitIVImpl extends Object implements 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

    Constructors
    Constructor
    Description
    JceBlockCipherWithCBCImplicitIVImpl(JcaTlsCrypto crypto, Cipher cipher, String algorithm, boolean isEncrypting)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    doFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
    Perform the cipher encryption/decryption returning the output in output.
    int
    Return the blocksize (in bytes) of the underlying block cipher.
    void
    init(byte[] iv, int ivOff, int ivLen)
    Initialise the parameters for operator.
    void
    setKey(byte[] key, int keyOff, int keyLen)
    Set the key to be used by the block cipher implementation supporting this service.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setKey

      public void setKey(byte[] key, int keyOff, int keyLen)
      Description copied from interface: TlsBlockCipherImpl
      Set the key to be used by the block cipher implementation supporting this service.
      Specified by:
      setKey in interface TlsBlockCipherImpl
      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: TlsBlockCipherImpl
      Initialise the parameters for operator.
      Specified by:
      init in interface TlsBlockCipherImpl
      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: TlsBlockCipherImpl
      Perform 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:
      doFinal in interface TlsBlockCipherImpl
      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: TlsBlockCipherImpl
      Return the blocksize (in bytes) of the underlying block cipher.
      Specified by:
      getBlockSize in interface TlsBlockCipherImpl
      Returns:
      the cipher's blocksize.