Package org.wso2.carbon.crypto.api
Class CipherMetaDataHolder
java.lang.Object
org.wso2.carbon.crypto.api.CipherMetaDataHolder
This the POJO class to hold metadata of the cipher.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getIv()Method to return the initialization vector in AES/GCM/NoPadding transformation.byte[]Method to return initialization vector as a byte arraygetKeyId()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.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.voidsetCipherBase64Encoded(byte[] cipher) Function to base64 encode ciphertext and set ciphertextvoidsetCipherText(String cipher) voidMethod to set the initialization vector in AES/GCM/NoPadding transformation.voidsetIvAndOriginalCipherText(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.voidvoidsetThumbPrint(String tp) voidsetThumbPrint(String tp, String digest) Function to set thumbprintvoidsetThumbprintDigest(String digest) voidsetTransformation(String transformation) toString()
-
Constructor Details
-
CipherMetaDataHolder
public CipherMetaDataHolder()
-
-
Method Details
-
getTransformation
-
setTransformation
-
getCipherText
-
getCipherBase64Decoded
public byte[] getCipherBase64Decoded() -
setCipherText
-
getThumbPrint
-
setThumbPrint
-
getThumbprintDigest
-
setThumbprintDigest
-
setKeyId
-
getKeyId
-
getIv
Method to return the initialization vector in AES/GCM/NoPadding transformation.- Returns:
- initialization vector value in String format.
-
setIv
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
Function to set thumbprint- Parameters:
tp- thumb printdigest- 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
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
-