Class KeyBlob
java.lang.Object
com.amazonaws.encryptionsdk.model.KeyBlob
- All Implemented Interfaces:
EncryptedDataKey
This class implements the format of the key blob. The format contains the following fields in
order:
- length of key provider
- key provider
- length of key provider info
- key provider info
- length of encrypted key
- encrypted key
-
Constructor Summary
ConstructorsConstructorDescriptionKeyBlob()
Default constructor.KeyBlob(EncryptedDataKey edk)
Construct a key blob using the provided key, key provider identifier, and key provider information. -
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.byte[]
Return the encrypted data key set in the header.int
Return the length of the encrypted data key set in the header.int
Return the length of the key provider identifier set in the header.int
Return the length of the key provider info set in the header.Return the key provider identifier set in the header.byte[]
Return the information on the key provider set in the header.boolean
Check if this object has all the header fields populated and available for reading.void
setEncryptedDataKey(byte[] encryptedDataKey)
Set the encrypted data key.void
setKeyProviderId(String keyProviderId)
Set the key provider identifier.void
setKeyProviderInfo(byte[] keyProviderInfo)
Set the information on the key provider identifier.byte[]
Serialize an instance of this class to a byte array.
-
Constructor Details
-
KeyBlob
public KeyBlob()Default constructor. -
KeyBlob
Construct a key blob using the provided key, key provider identifier, and key provider information.- Parameters:
keyProviderId
- the key provider identifier string.keyProviderInfo
- the bytes containing the key provider info.encryptedDataKey
- the encrypted bytes of the data key.
-
KeyBlob
-
-
Method Details
-
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.
-
toByteArray
public byte[] toByteArray()Serialize an instance of this class to a byte array.- Returns:
- the serialized bytes of the instance.
-
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.
-
getKeyProviderIdLen
public int getKeyProviderIdLen()Return the length of the key provider identifier set in the header.- Returns:
- the length of the key provider identifier.
-
getProviderId
Return the key provider identifier set in the header.- Specified by:
getProviderId
in interfaceEncryptedDataKey
- Returns:
- the string containing the key provider identifier.
-
getKeyProviderInfoLen
public int getKeyProviderInfoLen()Return the length of the key provider info set in the header.- Returns:
- the length of the key provider info.
-
getProviderInformation
public byte[] getProviderInformation()Return the information on the key provider set in the header.- Specified by:
getProviderInformation
in interfaceEncryptedDataKey
- Returns:
- the bytes containing information on the key provider.
-
getEncryptedDataKeyLen
public int getEncryptedDataKeyLen()Return the length of the encrypted data key set in the header.- Returns:
- the length of the encrypted data key.
-
getEncryptedDataKey
public byte[] getEncryptedDataKey()Return the encrypted data key set in the header.- Specified by:
getEncryptedDataKey
in interfaceEncryptedDataKey
- Returns:
- the bytes containing the encrypted data key.
-
setKeyProviderId
Set the key provider identifier.- Parameters:
keyProviderId
- the key provider identifier.
-
setKeyProviderInfo
public void setKeyProviderInfo(byte[] keyProviderInfo)Set the information on the key provider identifier.- Parameters:
keyProviderInfo
- the bytes containing information on the key provider identifier.
-
setEncryptedDataKey
public void setEncryptedDataKey(byte[] encryptedDataKey)Set the encrypted data key.- Parameters:
encryptedDataKey
- the bytes containing the encrypted data key.
-