Class CipherBlockHeaders

java.lang.Object
com.amazonaws.encryptionsdk.model.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 Summary

    Constructors
    Constructor
    Description
    Default constructor.
    CipherBlockHeaders​(byte[] nonce, long contentLen)
    Construct the single block headers using the provided nonce and length of content.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    deserialize​(byte[] b, int off)
    Deserialize the provided bytes starting at the specified offset to construct an instance of this class.
    long
    Return the content length set in the single block header.
    byte[]
    Return the nonce set in the single block header.
    boolean
    Check if this object has all the header fields populated and available for reading.
    void
    setNonceLength​(short nonceLength)
    Set the length of the nonce used in the encryption of the content stored in the single block.
    byte[]
    Serialize the header into a byte array.

    Methods inherited from class java.lang.Object

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

    • 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 Details

    • 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.