Interface InternalCryptoProvider


public interface InternalCryptoProvider
The service contract for internal crypto providers. An internal crypto provider is used for crypto needs related to internal operations. One example is encrypting sensitive tokens before persisting inside a data store. A symmetric key based implementation which reads the secret from a file, is a sample implementation of this contract.

As per the design decisions, the contract should never be amended in a way that the secret keys are returned to the caller.

  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decrypt(byte[] ciphertext, String algorithm, String javaSecurityAPIProvider)
    Computes and returns the cleartext of the given ciphertext.
    default byte[]
    decrypt(byte[] ciphertext, String algorithm, String javaSecurityAPIProvider, Object... params)
    Computes and returns the cleartext of the given ciphertext.
    byte[]
    encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider)
    Computes and returns the ciphertext of the given cleartext.
    default byte[]
    encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider, boolean returnSelfContainedCipherText)
    Computes and returns the ciphertext of the given cleartext.
    default byte[]
    encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider, boolean returnSelfContainedCipherText, Object... params)
    Computes and returns the ciphertext of the given cleartext.
  • Method Details

    • encrypt

      byte[] encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider) throws CryptoException
      Computes and returns the ciphertext of the given cleartext.
      Parameters:
      cleartext - The cleartext to be encrypted.
      algorithm - The encryption / decryption algorithm
      javaSecurityAPIProvider -
      Returns:
      The ciphertext
      Throws:
      CryptoException - If something unexpected happens during the encryption operation.
    • decrypt

      byte[] decrypt(byte[] ciphertext, String algorithm, String javaSecurityAPIProvider) throws CryptoException
      Computes and returns the cleartext of the given ciphertext.
      Parameters:
      ciphertext - The ciphertext to be decrypted.
      algorithm - The encryption / decryption algorithm
      javaSecurityAPIProvider -
      Returns:
      The cleartext
      Throws:
      CryptoException - If something unexpected happens during the decryption operation.
    • encrypt

      default byte[] encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider, boolean returnSelfContainedCipherText) throws CryptoException
      Computes and returns the ciphertext of the given cleartext.
      Parameters:
      cleartext - The cleartext to be encrypted.
      algorithm - The encryption / decryption algorithm
      javaSecurityAPIProvider - The Java Security API provider.
      returnSelfContainedCipherText - Whether cipher text need to be self contained.
      Returns:
      The ciphertext
      Throws:
      CryptoException
    • encrypt

      default byte[] encrypt(byte[] cleartext, String algorithm, String javaSecurityAPIProvider, boolean returnSelfContainedCipherText, Object... params) throws CryptoException
      Computes and returns the ciphertext of the given cleartext.
      Parameters:
      cleartext - The cleartext to be encrypted.
      algorithm - The encryption / decryption algorithm
      javaSecurityAPIProvider - The Java Security API provider.
      returnSelfContainedCipherText - Whether cipher text need to be self contained.
      params - The parameters required for the encryption operation.
      Returns:
      The ciphertext
      Throws:
      CryptoException - If something unexpected happens during the encryption operation.
    • decrypt

      default byte[] decrypt(byte[] ciphertext, String algorithm, String javaSecurityAPIProvider, Object... params) throws CryptoException
      Computes and returns the cleartext of the given ciphertext.
      Parameters:
      ciphertext - The ciphertext to be decrypted.
      algorithm - The encryption / decryption algorithm
      javaSecurityAPIProvider - The Java Security API provider.
      params - The parameters required for the decryption operation.
      Returns:
      The cleartext
      Throws:
      CryptoException - If something unexpected happens during the decryption operation.