Class CipherMetaDataHolder

java.lang.Object
org.wso2.carbon.crypto.api.CipherMetaDataHolder

public class CipherMetaDataHolder extends Object
This the POJO class to hold metadata of the cipher.
  • Constructor Details

    • CipherMetaDataHolder

      public CipherMetaDataHolder()
  • Method Details

    • getTransformation

      public String getTransformation()
    • setTransformation

      public void setTransformation(String transformation)
    • getCipherText

      public String getCipherText()
    • getCipherBase64Decoded

      public byte[] getCipherBase64Decoded()
    • setCipherText

      public void setCipherText(String cipher)
    • getThumbPrint

      public String getThumbPrint()
    • setThumbPrint

      public void setThumbPrint(String tp)
    • getThumbprintDigest

      public String getThumbprintDigest()
    • setThumbprintDigest

      public void setThumbprintDigest(String digest)
    • setKeyId

      public void setKeyId(String kid)
    • getKeyId

      public String getKeyId()
    • getIv

      public String getIv()
      Method to return the initialization vector in AES/GCM/NoPadding transformation.
      Returns:
      initialization vector value in String format.
    • setIv

      public void setIv(String iv)
      Method to set the initialization vector in AES/GCM/NoPadding transformation.
      Parameters:
      iv - initialization vector value in String format
    • getIvBase64Decoded

      public byte[] getIvBase64Decoded()
      Method to return initialization vector as a byte array
      Returns:
      byte array
    • setCipherBase64Encoded

      public void setCipherBase64Encoded(byte[] cipher)
      Function to base64 encode ciphertext and set ciphertext
      Parameters:
      cipher -
    • setThumbPrint

      public void setThumbPrint(String tp, String digest)
      Function to set thumbprint
      Parameters:
      tp - thumb print
      digest - digest (hash algorithm) used for to create thumb print
    • getSelfContainedCiphertextWithIv

      public byte[] getSelfContainedCiphertextWithIv(byte[] originalCipher, byte[] iv)
      Combines the original ciphertext and initialization vector (IV) into a single JSON string with metadata and returns it as a byte array.
      Parameters:
      originalCipher - The original ciphertext as a byte array.
      iv - The initialization vector (IV) as a byte array.
      Returns:
      A byte array representing the JSON containing the Base64 encoded ciphertext and IV.
    • getSelfContainedCiphertextWithIv

      public byte[] getSelfContainedCiphertextWithIv(byte[] originalCipher, byte[] iv, String kid)
      Combines the original ciphertext, initialization vector (IV), and key identifier (KID) into a single JSON string with metadata and returns it as a byte array.
      Parameters:
      originalCipher - The original ciphertext as a byte array.
      iv - The initialization vector (IV) as a byte array.
      kid - The key identifier as a string.
      Returns:
      A byte array representing the JSON containing the Base64 encoded ciphertext, IV, and KID.
    • setIvAndOriginalCipherText

      public void setIvAndOriginalCipherText(byte[] cipherTextBytes)
      This method extracts the initialization vector, original ciphertext, and key ID from the input ciphertext and sets them to metadata in the CipherMetaDataHolder object.
      Parameters:
      cipherTextBytes - This input ciphertext contains the original cipher, initialization vector, and key ID.
    • toString

      public String toString()
      Overrides:
      toString in class Object