Interface KmsOperations

All Known Implementing Classes:
KmsTemplate

public interface KmsOperations
Describes supported operations that one can perform on the KMS API.

For the methods you need specify the secret from GCP KMS by resource string. The following secret resource syntax is supported:

1. Shortest form - specify the key by key ring ID, and key ID. Project is derived through GcpProjectIdProvider. The location is assumed to be `global`. {key-ring-id}/{key-id}

2. Short form - specify location ID, key ring ID, and key ID. Project is derived through GcpProjectIdProvider. {location-id}/{key-ring-id}/{key-id}

3. Full form - specify project ID, location ID, key ring ID, and key ID {project-id}/{location-id}/{key-ring-id}/{key-id}

4. Long form - specify project ID, location ID, key ring ID, and key ID (full resource name) projects/{project-id}/locations/{location-id}/keyRings/{key-ring-id}/cryptoKeys/{key-id}

  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decryptBytes(String cryptoKey, byte[] cipherText)
    Decrypt the text using the specified KMS resource string cryptoKey
    decryptText(String cryptoKey, byte[] cipherText)
    Decrypt the text using the specified KMS resource string cryptoKey
    byte[]
    encryptBytes(String cryptoKey, byte[] bytes)
    Encrypt the bytes using the specified KMS resource string cryptoKey.
    byte[]
    encryptText(String cryptoKey, String text)
    Encrypt the text using the specified KMS resource string cryptoKey.
  • Method Details

    • encryptText

      byte[] encryptText(String cryptoKey, String text)
      Encrypt the text using the specified KMS resource string cryptoKey.

      An encryption request will be issued using GCP KMS.

      Parameters:
      cryptoKey - The KMS resource string
      text - UTF-8 encoded text to encrypt
      Returns:
      The encrypted bytes
    • encryptBytes

      byte[] encryptBytes(String cryptoKey, byte[] bytes)
      Encrypt the bytes using the specified KMS resource string cryptoKey.

      An encryption request will be issued using GCP KMS.

      Parameters:
      cryptoKey - The KMS resource string
      bytes - The bytes to encrypt
      Returns:
      The encrypted bytes
    • decryptBytes

      byte[] decryptBytes(String cryptoKey, byte[] cipherText)
      Decrypt the text using the specified KMS resource string cryptoKey

      A decryption request will be issued using GCP KMS.

      Parameters:
      cryptoKey - The KMS resource string
      cipherText - The encrypted bytes
      Returns:
      The decrypted bytes
    • decryptText

      String decryptText(String cryptoKey, byte[] cipherText)
      Decrypt the text using the specified KMS resource string cryptoKey

      A decryption request will be issued using GCP KMS.

      Parameters:
      cryptoKey - The KMS resource string
      cipherText - The encrypted bytes
      Returns:
      The decrypted bytes UTF-8 encoded