Interface CryptoHandler

All Known Subinterfaces:
MessageCryptoHandler
All Known Implementing Classes:
DecryptionHandler, EncryptionHandler, LazyMessageCryptoHandler

public interface CryptoHandler
This interface defines the contract for the implementation of encryption and decryption handlers in this library.

The implementations of this interface provided in this package currently process bytes in a single block mode (where all input data is processed in entirety, or in a framing mode (where data is processed incrementally in chunks).

  • Method Details

    • processBytes

      ProcessingSummary processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff)
      Process a block of bytes from in putting the result into out.
      Parameters:
      in - the input byte array.
      inOff - the offset into the in array where the data to be processed starts.
      inLen - the number of bytes to be processed.
      out - the output buffer the processed bytes go into.
      outOff - the offset into the output byte array the processed data starts at.
      Returns:
      the number of bytes written to out and the number of bytes parsed.
    • doFinal

      int doFinal(byte[] out, int outOff)
      Finish processing of the bytes.
      Parameters:
      out - the output buffer for copying any remaining output data.
      outOff - offset into out to start copying the output data.
      Returns:
      number of bytes written into out.
    • estimateOutputSize

      int estimateOutputSize(int inLen)
      Return the size of the output buffer required for a processBytes(byte[], int, int, byte[], int) plus a doFinal(byte[], int) call with an input of inLen bytes.

      Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.

      Parameters:
      inLen - the length of the input.
      Returns:
      the space required to accommodate a call to processBytes and doFinal(byte[], int) with an input of size inLen bytes.
    • estimatePartialOutputSize

      int estimatePartialOutputSize(int inLen)
      Return the size of the output buffer required for a call to processBytes(byte[], int, int, byte[], int).

      Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.

      Parameters:
      inLen - the length of the input.
      Returns:
      the space required to accommodate a call to processBytes(byte[], int, int, byte[], int) with an input of size inLen bytes.
    • estimateFinalOutputSize

      int estimateFinalOutputSize()
      Return the size of the output buffer required for a call to doFinal(byte[], int).

      Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.

      Returns:
      the space required to accomodate a call to doFinal(byte[], int)
    • isComplete

      boolean isComplete()
      For decrypt and parsing flows returns true when this has handled as many bytes as it can. This usually means that it has reached the end of an object, file, or other delimited stream.