The raw symmetric encryption lets you encrypt and decrypt your data locally
on-premises or using Cloud KMS, and move encrypted data between
different libraries and service providers without having to decrypt it first.
This functionality depends on the ability to access the key at the point of
operation. If you want to use the ciphertexts outside of Google Cloud, you must
use an imported key because keys generated in Cloud KMS can't be
exported.
These encryption algorithms generate standard ciphertexts that can be decrypted
by any standard decryption service. We support the following raw symmetric
encryption algorithms:
AES-128-GCM
AES-256-GCM
AES-128-CBC
AES-256-CBC
AES-128-CTR
AES-256-CTR
Note the following points about these raw encryption algorithms:
AES-GCM provides authentication based on the additional
authenticated data (AAD) and generates an authentication tag, and is the recommended encryption algorithm to use. Data encrypted using AES-GCM algorithms can't be decrypted without the provided AAD.
AES-CBC requires the size of the plaintext to be a multiple of the block
size (16 bytes). If the plaintext is not a multiple of the block size,
pad the plaintext before encrypting it; otherwise, the operation will fail
with an error indicating the issue.
AES-CBC and AES-CTR are not authenticated encryption schemes, which
means that they can carry greater risk of accidental misuse. They are
offered to support legacy and interoperability needs, and should be used
with caution. To prevent casual misuse, using these encryption algorithms
requires the following IAM permissions:
cloudkms.cryptoKeyVersions.manageRawAesCbcKeys for AES-CBC.
cloudkms.cryptoKeyVersions.manageRawAesCtrKeys for AES-CTR.
Required roles
To get the permissions that
you need to use raw encryption,
ask your administrator to grant you the
following IAM roles on your key:
PROJECT_ID: the ID of the project that contains the key ring.
LOCATION: the Cloud KMS location of the key ring.
KEY_RING: the name of the key ring that contains the key.
KEY_NAME: the name of the key to use for encryption.
KEY_VERSION: the ID of the key version to use for encryption.
BASE64_ENCODED_INPUT: the base64-encoded plaintext
data that you want to encrypt.
BASE64_ENCODED_AAD: the base64-encoded additional
authenticated data that is used to provide integrity and authenticity
assurances. This field only applies for the AES-GCM algorithms.
The output is a JSON object containing the encrypted ciphertext and the associated initialization vector as base64-encoded strings.
PROJECT_ID: the ID of the project that contains the key ring.
LOCATION: the Cloud KMS location of the key ring.
KEY_RING: the name of the key ring that contains the key.
KEY_NAME: the name of the key to use for decryption.
KEY_VERSION: the ID of the key version to use for decryption.
BASE64_ENCODED_DATA: the base64-encoded ciphertext
that you want to decrypt.
BASE64_ENCODED_AAD: the base64-encoded additional
authenticated data that was used when the data was encrypted. This field
only applies for the AES-GCM algorithms.
BASE64_ENCODED_IV: the base64-encoded initialization
vector that was used when the data was encrypted.
The output is a JSON object containing the decrypted plaintext as a
base64-encoded string.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-09 UTC."],[],[]]