public class CiphertextHeaders extends Object
KeyBlob
containing the key provider, key provider
info, encrypted key, and their lengths for each data keyIt is important to note that the header fields 1 through 12 are checked for their integrity during decryption using AES-GCM with the nonce and MAC tag values supplied in fields 13 and 14 respectively.
Constructor and Description |
---|
CiphertextHeaders()
Default constructor.
|
CiphertextHeaders(byte version,
CiphertextType type,
CryptoAlgorithm cryptoAlgo,
byte[] encryptionContext,
List<KeyBlob> keyBlobs,
ContentType contentType,
int frameSize)
Construct the ciphertext headers using the provided values.
|
Modifier and Type | Method and Description |
---|---|
int |
deserialize(byte[] b,
int off)
Deserialize the provided bytes starting at the specified offset to
construct an instance of this class.
|
ContentType |
getContentType()
Return the content type set in the header.
|
CryptoAlgorithm |
getCryptoAlgoId()
Return the crypto algorithm identifier set in the header.
|
int |
getEncryptedKeyBlobCount()
Return the count of the encrypted key blobs set in the header.
|
List<KeyBlob> |
getEncryptedKeyBlobs()
Return the encrypted key blobs set in the header.
|
byte[] |
getEncryptionContext()
Return the encryption context set in the header.
|
int |
getEncryptionContextLen()
Return the length of the encryption context set in the header.
|
Map<String,String> |
getEncryptionContextMap() |
int |
getFrameLength()
Return the length of the frame set in the header.
|
byte[] |
getHeaderNonce()
Return the header nonce set in the header.
|
byte[] |
getHeaderTag()
Return the header tag set in the header.
|
byte[] |
getMessageId()
Return the message identifier set in the header.
|
short |
getNonceLength()
Return the length of the nonce set in the header.
|
CiphertextType |
getType()
Return the type set in the header.
|
byte |
getVersion()
Return the version set in the header.
|
Boolean |
isComplete()
Check if this object has all the header fields populated and available
for reading.
|
byte[] |
serializeAuthenticatedFields()
Serialize the header fields into a byte array.
|
void |
setHeaderNonce(byte[] headerNonce)
Set the header nonce to use for authenticating the header data.
|
void |
setHeaderTag(byte[] headerTag)
Set the header tag to use for authenticating the header data.
|
byte[] |
toByteArray()
Serialize the header fields into a byte array.
|
public CiphertextHeaders()
public CiphertextHeaders(byte version, CiphertextType type, CryptoAlgorithm cryptoAlgo, byte[] encryptionContext, List<KeyBlob> keyBlobs, ContentType contentType, int frameSize)
version
- the version to set in the header.type
- the type to set in the header.cryptoAlgo
- the CryptoAlgorithm enum to encode in the header.encryptionContext
- the bytes containing the encryption context to set in the
header.keyBlob
- the keyBlob object containing the key provider id, key
provider info, and encrypted data key to encode in the header.contentType
- the content type to set in the header.frameSize
- the frame payload size to set in the header.public Boolean isComplete()
public int deserialize(byte[] b, int off) throws ParseException
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.
b
- the byte array to deserialize.off
- the offset in the byte array to use for deserialization.ParseException
public byte[] serializeAuthenticatedFields()
public byte[] toByteArray()
public byte getVersion()
public CiphertextType getType()
public CryptoAlgorithm getCryptoAlgoId()
public int getEncryptionContextLen()
public byte[] getEncryptionContext()
public int getEncryptedKeyBlobCount()
public List<KeyBlob> getEncryptedKeyBlobs()
public ContentType getContentType()
public byte[] getMessageId()
public short getNonceLength()
public int getFrameLength()
public byte[] getHeaderNonce()
public byte[] getHeaderTag()
public void setHeaderNonce(byte[] headerNonce)
headerNonce
- the header nonce to use.public void setHeaderTag(byte[] headerTag)
headerTag
- the header tag to use.Copyright © 2016. All rights reserved.