Class CipherFrameHeaders
java.lang.Object
com.amazonaws.encryptionsdk.model.CipherFrameHeaders
This class implements the headers for the encrypted content stored in a frame. These headers are
parsed and used when the encrypted content in the frame is decrypted.
It contains the following fields in order:
- final sequence number marker if final frame
- sequence number
- nonce
- length of content in frame
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.CipherFrameHeaders(int sequenceNumber, byte[] nonce, int frameContentLen, boolean isFinal)
Construct the frame headers using the provided sequence number, nonce, length of content, and boolean value indicating if it is the final frame. -
Method Summary
Modifier and TypeMethodDescriptionint
deserialize(byte[] b, int off)
Deserialize the provided bytes starting at the specified offset to construct an instance of this class.int
Return the frame content length set in the frame header.byte[]
getNonce()
Return the nonce set in the frame header.int
Return the frame sequence number set in the frame header.void
includeFrameSize(boolean value)
Set the flag to specify whether the frame length needs to be included or parsed in the header.boolean
Check if this object has all the header fields populated and available for reading.boolean
Return if the frame is a final frame.void
setNonceLength(short nonceLength)
Set the length of the nonce used in the encryption of the content in the frame.byte[]
Serialize the header into a byte array.
-
Constructor Details
-
CipherFrameHeaders
public CipherFrameHeaders()Default constructor. -
CipherFrameHeaders
public CipherFrameHeaders(int sequenceNumber, byte[] nonce, int frameContentLen, boolean isFinal)Construct the frame headers using the provided sequence number, nonce, length of content, and boolean value indicating if it is the final frame.- Parameters:
sequenceNumber
- the sequence number of the framenonce
- the bytes containing the nonce.frameContentLen
- the length of the content in the frame.isFinal
- boolean value indicating if it is the final frame.
-
-
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.
-
isFinalFrame
public boolean isFinalFrame()Return if the frame is a final frame. The final frame is identified as the frame containing the final sequence number marker.- Returns:
- true if final frame; false otherwise.
-
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 frame header.- Returns:
- the bytes containing the nonce set in the frame header.
-
getFrameContentLength
public int getFrameContentLength()Return the frame content length set in the frame header.- Returns:
- the frame content length set in the frame header.
-
getSequenceNumber
public int getSequenceNumber()Return the frame sequence number set in the frame header.- Returns:
- the frame sequence number set in the frame header.
-
setNonceLength
public void setNonceLength(short nonceLength)Set the length of the nonce used in the encryption of the content in the frame.- Parameters:
nonceLength
- the length of the nonce used in the encryption of the content in the frame.
-
includeFrameSize
public void includeFrameSize(boolean value)Set the flag to specify whether the frame length needs to be included or parsed in the header.- Parameters:
value
- true if the frame length needs to be included or parsed in the header; false otherwise
-