Key purposes and algorithms

Each Cloud KMS key has a purpose, which defines the cryptographic capabilities of the key. The purpose also determines which algorithms are supported for the key's versions. Each algorithm defines what parameters must be used for each cryptographic operation. Each key also has a protection level that indicates whether cryptographic operations are performed in software or in a Hardware Security Module (HSM).

Key purposes

Cloud KMS provides key purposes for the following scenarios:

Scenario Key purpose Supported methods
Symmetric encryption ENCRYPT_DECRYPT cryptoKeys.encrypt, cryptoKeys.decrypt
Asymmetric signing (Beta) ASYMMETRIC_SIGN cryptoKeys.asymmetricSign, cryptoKeyVersions.getPublicKey
Asymmetric encryption (Beta) ASYMMETRIC_DECRYPT cryptoKeyVersions.asymmetricDecrypt, cryptoKeyVersions.getPublicKey

When you create a key, you define the purpose and the algorithm of that key. You can change the algorithm when you create new key versions, subject to the scope of its purpose. The purpose cannot be changed.

Two keys with the same purpose may use different underlying algorithms, but they must support the same set of cryptographic operations.

Symmetric encryption algorithms

The ENCRYPT_DECRYPT key purpose enables symmetric encryption. All keys with key purpose ENCRYPT_DECRYPT use the GOOGLE_SYMMETRIC_ENCRYPTION algorithm. No parameters are used with this algorithm. This algorithm uses 256-bit Advanced Encryption Standard (AES-256) keys in Galois Counter Mode (GCM), padded with Cloud KMS-internal metadata.

Asymmetric signing algorithms (Beta)

The ASYMMETRIC_SIGN key purpose enables asymmetric signing. Keys with key purpose ASYMMETRIC_SIGN use different algorithms, depending on whether the key supports elliptic curve signing or RSA signing.

For a key that has purpose ASYMMETRIC_SIGN, you can switch between different size keys and different signature schemes via the algorithm.

Elliptic curve signing algorithms (Beta)

The format of an elliptic curve signing algorithm is

EC_SIGN_[ELLIPTIC_CURVE]_[DIGEST_ALGORITHM]

where

  • [ELLIPTIC_CURVE] is the elliptic curve
  • [DIGEST_ALGORITHM] is the digest algorithm

The following table lists the possible algorithms for elliptic curve keys with purpose ASYMMETRIC_SIGN.

Algorithm Description
EC_SIGN_P256_SHA256 (recommended) ECDSA on the P-256 Curve with a SHA-256 digest
EC_SIGN_P384_SHA384 ECDSA on the P-384 Curve with a SHA-384 digest

RSA signing algorithms (Beta)

The format of an RSA signing algorithm is

RSA_SIGN_[PADDING_ALGORITHM]_[MODULUS_BIT_LENGTH]_[DIGEST_ALGORITHM]

where

  • [PADDING_ALGORITHM] is the padding algorithm
  • [MODULUS_BIT_LENGTH] is the bit length of the key
  • [DIGEST_ALGORITHM] is the digest algorithm

The following table lists the possible algorithms for RSA keys with purpose ASYMMETRIC_SIGN.

Algorithm Description
RSA_SIGN_PSS_2048_SHA256 RSASSA-PSS 2048 bit key with a SHA-256 digest
RSA_SIGN_PSS_3072_SHA256 (recommended) RSASSA-PSS 3072 bit key with a SHA-256 digest
RSA_SIGN_PSS_4096_SHA256 RSASSA-PSS 4096 bit key with a SHA-256 digest
RSA_SIGN_PSS_4096_SHA512 RSASSA-PSS 4096 bit key with a SHA-512 digest
RSA_SIGN_PKCS1_2048_SHA256 RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA-256 digest
RSA_SIGN_PKCS1_3072_SHA256 RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA-256 digest
RSA_SIGN_PKCS1_4096_SHA256 RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA-256 digest
RSA_SIGN_PKCS1_4096_SHA512 RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA-512 digest

For Probabilistic Signature Scheme (PSS), the salt length used is equal to the length of the digest algorithm. For example, RSA_SIGN_PSS_2048_SHA256 will use PSS with a salt length of 256 bits. In addition, for PSS the digest algorithm specified in the algorithm name is used for the mask generation function (MGF1) as well. For example, if you are using RSA_SIGN_PSS_2048_SHA256, you will submit a SHA-256 hash of the data to be signed, and Cloud KMS will internally use SHA-256 as the hash algorithm for MGF1 when computing the signature.

Asymmetric encryption algorithms (Beta)

The ASYMMETRIC_DECRYPT key purpose enables RSA encryption. The format of an ASYMMETRIC_DECRYPT algorithm is

RSA_DECRYPT_[PADDING_ALGORITHM]_[MODULUS_BIT_LENGTH]_[DIGEST_ALGORITHM]

where

  • [PADDING_ALGORITHM] is the padding algorithm
  • [MODULUS_BIT_LENGTH] is the bit length of the key
  • [DIGEST_ALGORITHM] is the digest algorithm

The following table lists the possible algorithms for RSA keys with purpose ASYMMETRIC_DECRYPT.

Algorithm Description
RSA_DECRYPT_OAEP_2048_SHA256 RSAES-OAEP 2048 bit key with a SHA-256 digest
RSA_DECRYPT_OAEP_3072_SHA256 (recommended) RSAES-OAEP 3072 bit key with a SHA-256 digest
RSA_DECRYPT_OAEP_4096_SHA256 RSAES-OAEP 4096 bit key with a SHA-256 digest
RSA_DECRYPT_OAEP_4096_SHA512 RSAES-OAEP 4096 bit key with a SHA-512 digest

All of these algorithms use Optimal Asymmetric Encryption Padding (OAEP) with the mask generation function MGF1. MGF1 requires a digest algorithm. In Cloud KMS, the digest function to be used with MGF1 is specified as part of the key algorithm name. For example, if you are using the RSA_DECRYPT_OAEP_3072_SHA256 algorithm, you should use SHA-256 with MGF1 when encrypting data.

Algorithm recommendations

For digital signing, the recommendation is to use elliptic curve signing algorithms. EC_SIGN_P256_SHA256 is the recommended elliptic curve algorithm. If you are going to use RSA signing algorithms, the recommended RSA signing algorithm is RSA_SIGN_PSS_3072_SHA256.

For asymmetric encryption, RSA_DECRYPT_OAEP_3072_SHA256 is the recommended algorithm.

Protection levels

The protection level indicates how cryptographic operations are performed. After you create a key, you cannot change the protection level.

Protection level Description
SOFTWARE Cryptographic operations are performed in software
HSM (Beta) Cryptographic operations are performed in a Hardware Security Module

All key purposes are supported for both SOFTWARE and HSM protection levels.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud KMS Documentation