Class KeyBlob

java.lang.Object
com.amazonaws.encryptionsdk.model.KeyBlob
All Implemented Interfaces:
EncryptedDataKey

public final class KeyBlob extends Object implements EncryptedDataKey
This class implements the format of the key blob. The format contains the following fields in order:
  1. length of key provider
  2. key provider
  3. length of key provider info
  4. key provider info
  5. length of encrypted key
  6. encrypted key
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
     
    KeyBlob​(String keyProviderId, byte[] keyProviderInfo, byte[] encryptedDataKey)
    Construct a key blob using the provided key, key provider identifier, and key provider information.
  • 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.
    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.

    Methods inherited from class java.lang.Object

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

    • KeyBlob

      public KeyBlob()
      Default constructor.
    • KeyBlob

      public KeyBlob(String keyProviderId, byte[] keyProviderInfo, byte[] encryptedDataKey)
      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

      public KeyBlob(EncryptedDataKey edk)
  • 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

      public String getProviderId()
      Return the key provider identifier set in the header.
      Specified by:
      getProviderId in interface EncryptedDataKey
      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 interface EncryptedDataKey
      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 interface EncryptedDataKey
      Returns:
      the bytes containing the encrypted data key.
    • setKeyProviderId

      public void setKeyProviderId(String keyProviderId)
      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.