Class CipherBlockHeaders


  • public final class CipherBlockHeaders
    extends Object
    This class implements the headers for the encrypted content stored in a single block. These headers are parsed and used when the encrypted content in the single block is decrypted.

    It contains the following fields in order:

    1. nonce
    2. length of content
    • Constructor Detail

      • CipherBlockHeaders

        public CipherBlockHeaders()
        Default constructor.
      • CipherBlockHeaders

        public CipherBlockHeaders​(byte[] nonce,
                                  long contentLen)
        Construct the single block headers using the provided nonce and length of content.
        Parameters:
        nonce - the bytes containing the nonce.
        contentLen - the length of the content in the block.
    • Method Detail

      • toByteArray

        public byte[] toByteArray()
        Serialize the header into a byte array.
        Returns:
        the serialized bytes of the header.
      • deserialize

        public int deserialize​(byte[] b,
                               int off)
        Deserialize the provided bytes starting at the specified offset to construct an instance of this class.

        This method parses the provided bytes for the individual fields in this class. This methods also supports partial parsing where not all the bytes required for parsing the fields successfully are available.

        Parameters:
        b - the byte array to deserialize.
        off - the offset in the byte array to use for deserialization.
        Returns:
        the number of bytes consumed in deserialization.
      • isComplete

        public boolean isComplete()
        Check if this object has all the header fields populated and available for reading.
        Returns:
        true if this object containing the single block header fields is complete; false otherwise.
      • getNonce

        public byte[] getNonce()
        Return the nonce set in the single block header.
        Returns:
        the bytes containing the nonce set in the single block header.
      • getContentLength

        public long getContentLength()
        Return the content length set in the single block header.
        Returns:
        the content length set in the single block header.
      • setNonceLength

        public void setNonceLength​(short nonceLength)
        Set the length of the nonce used in the encryption of the content stored in the single block.
        Parameters:
        nonceLength - the length of the nonce used in the encryption of the content stored in the single block.