crypto_keys
Creates, updates, deletes, gets or lists a crypto_keys
resource.
Overview
Name | crypto_keys |
Type | Resource |
Id | google.cloudkms.crypto_keys |
Fields
The following fields are returned by SELECT
queries:
- get
- list
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/* . |
createTime | string (google-datetime) | Output only. The time at which this CryptoKey was created. |
cryptoKeyBackend | string | Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/* . Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future. |
destroyScheduledDuration | string (google-duration) | Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days. |
importOnly | boolean | Immutable. Whether this key may contain imported versions only. |
keyAccessJustificationsPolicy | object | Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed. (id: KeyAccessJustificationsPolicy) |
labels | object | Labels with user-defined metadata. For more information, see Labeling Keys. |
nextRotationTime | string (google-datetime) | At next_rotation_time, the Key Management Service will automatically: 1. Create a new version of this CryptoKey. 2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted. |
primary | object | Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name. The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted. (id: CryptoKeyVersion) |
purpose | string | Immutable. The immutable purpose of this CryptoKey. |
rotationPeriod | string (google-duration) | next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted. |
versionTemplate | object | A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template. (id: CryptoKeyVersionTemplate) |
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/* . |
createTime | string (google-datetime) | Output only. The time at which this CryptoKey was created. |
cryptoKeyBackend | string | Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/* . Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future. |
destroyScheduledDuration | string (google-duration) | Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days. |
importOnly | boolean | Immutable. Whether this key may contain imported versions only. |
keyAccessJustificationsPolicy | object | Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed. (id: KeyAccessJustificationsPolicy) |
labels | object | Labels with user-defined metadata. For more information, see Labeling Keys. |
nextRotationTime | string (google-datetime) | At next_rotation_time, the Key Management Service will automatically: 1. Create a new version of this CryptoKey. 2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted. |
primary | object | Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name. The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted. (id: CryptoKeyVersion) |
purpose | string | Immutable. The immutable purpose of this CryptoKey. |
rotationPeriod | string (google-duration) | next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted. |
versionTemplate | object | A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template. (id: CryptoKeyVersionTemplate) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get | select | projectsId , locationsId , keyRingsId , cryptoKeysId | Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion. | |
list | select | projectsId , locationsId , keyRingsId | pageSize , pageToken , versionView , filter , orderBy | Lists CryptoKeys. |
create | insert | projectsId , locationsId , keyRingsId | cryptoKeyId , skipInitialVersionCreation | Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required. |
patch | update | projectsId , locationsId , keyRingsId , cryptoKeysId | updateMask | Update a CryptoKey. |
update_primary_version | exec | projectsId , locationsId , keyRingsId , cryptoKeysId | Update the version of a CryptoKey that will be used in Encrypt. Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT. | |
encrypt | exec | projectsId , locationsId , keyRingsId , cryptoKeysId | Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT. | |
decrypt | exec | projectsId , locationsId , keyRingsId , cryptoKeysId | Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
cryptoKeysId | string | |
keyRingsId | string | |
locationsId | string | |
projectsId | string | |
cryptoKeyId | string | |
filter | string | |
orderBy | string | |
pageSize | integer (int32) | |
pageToken | string | |
skipInitialVersionCreation | boolean | |
updateMask | string (google-fieldmask) | |
versionView | string |
SELECT
examples
- get
- list
Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
SELECT
name,
createTime,
cryptoKeyBackend,
destroyScheduledDuration,
importOnly,
keyAccessJustificationsPolicy,
labels,
nextRotationTime,
primary,
purpose,
rotationPeriod,
versionTemplate
FROM google.cloudkms.crypto_keys
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND keyRingsId = '{{ keyRingsId }}' -- required
AND cryptoKeysId = '{{ cryptoKeysId }}' -- required;
Lists CryptoKeys.
SELECT
name,
createTime,
cryptoKeyBackend,
destroyScheduledDuration,
importOnly,
keyAccessJustificationsPolicy,
labels,
nextRotationTime,
primary,
purpose,
rotationPeriod,
versionTemplate
FROM google.cloudkms.crypto_keys
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND keyRingsId = '{{ keyRingsId }}' -- required
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}'
AND versionView = '{{ versionView }}'
AND filter = '{{ filter }}'
AND orderBy = '{{ orderBy }}';
INSERT
examples
- create
- Manifest
Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required.
INSERT INTO google.cloudkms.crypto_keys (
data__purpose,
data__nextRotationTime,
data__rotationPeriod,
data__versionTemplate,
data__labels,
data__importOnly,
data__destroyScheduledDuration,
data__cryptoKeyBackend,
data__keyAccessJustificationsPolicy,
projectsId,
locationsId,
keyRingsId,
cryptoKeyId,
skipInitialVersionCreation
)
SELECT
'{{ purpose }}',
'{{ nextRotationTime }}',
'{{ rotationPeriod }}',
'{{ versionTemplate }}',
'{{ labels }}',
{{ importOnly }},
'{{ destroyScheduledDuration }}',
'{{ cryptoKeyBackend }}',
'{{ keyAccessJustificationsPolicy }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ keyRingsId }}',
'{{ cryptoKeyId }}',
'{{ skipInitialVersionCreation }}'
RETURNING
name,
createTime,
cryptoKeyBackend,
destroyScheduledDuration,
importOnly,
keyAccessJustificationsPolicy,
labels,
nextRotationTime,
primary,
purpose,
rotationPeriod,
versionTemplate
;
# Description fields are for documentation purposes
- name: crypto_keys
props:
- name: projectsId
value: string
description: Required parameter for the crypto_keys resource.
- name: locationsId
value: string
description: Required parameter for the crypto_keys resource.
- name: keyRingsId
value: string
description: Required parameter for the crypto_keys resource.
- name: purpose
value: string
description: >
Immutable. The immutable purpose of this CryptoKey.
valid_values: ['CRYPTO_KEY_PURPOSE_UNSPECIFIED', 'ENCRYPT_DECRYPT', 'ASYMMETRIC_SIGN', 'ASYMMETRIC_DECRYPT', 'RAW_ENCRYPT_DECRYPT', 'MAC', 'KEY_ENCAPSULATION']
- name: nextRotationTime
value: string
description: >
At next_rotation_time, the Key Management Service will automatically: 1. Create a new version of this CryptoKey. 2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.
- name: rotationPeriod
value: string
description: >
next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.
- name: versionTemplate
value: object
description: >
A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.
- name: labels
value: object
description: >
Labels with user-defined metadata. For more information, see [Labeling Keys](https://cloud.google.com/kms/docs/labeling-keys).
- name: importOnly
value: boolean
description: >
Immutable. Whether this key may contain imported versions only.
- name: destroyScheduledDuration
value: string
description: >
Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days.
- name: cryptoKeyBackend
value: string
description: >
Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format `projects/*/locations/*/ekmConnections/*`. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.
- name: keyAccessJustificationsPolicy
value: object
description: >
Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed.
- name: cryptoKeyId
value: string
- name: skipInitialVersionCreation
value: boolean
UPDATE
examples
- patch
Update a CryptoKey.
UPDATE google.cloudkms.crypto_keys
SET
data__purpose = '{{ purpose }}',
data__nextRotationTime = '{{ nextRotationTime }}',
data__rotationPeriod = '{{ rotationPeriod }}',
data__versionTemplate = '{{ versionTemplate }}',
data__labels = '{{ labels }}',
data__importOnly = {{ importOnly }},
data__destroyScheduledDuration = '{{ destroyScheduledDuration }}',
data__cryptoKeyBackend = '{{ cryptoKeyBackend }}',
data__keyAccessJustificationsPolicy = '{{ keyAccessJustificationsPolicy }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND keyRingsId = '{{ keyRingsId }}' --required
AND cryptoKeysId = '{{ cryptoKeysId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
createTime,
cryptoKeyBackend,
destroyScheduledDuration,
importOnly,
keyAccessJustificationsPolicy,
labels,
nextRotationTime,
primary,
purpose,
rotationPeriod,
versionTemplate;
Lifecycle Methods
- update_primary_version
- encrypt
- decrypt
Update the version of a CryptoKey that will be used in Encrypt. Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT.
EXEC google.cloudkms.crypto_keys.update_primary_version
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@keyRingsId='{{ keyRingsId }}' --required,
@cryptoKeysId='{{ cryptoKeysId }}' --required
@@json=
'{
"cryptoKeyVersionId": "{{ cryptoKeyVersionId }}"
}';
Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
EXEC google.cloudkms.crypto_keys.encrypt
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@keyRingsId='{{ keyRingsId }}' --required,
@cryptoKeysId='{{ cryptoKeysId }}' --required
@@json=
'{
"plaintext": "{{ plaintext }}",
"additionalAuthenticatedData": "{{ additionalAuthenticatedData }}",
"plaintextCrc32c": "{{ plaintextCrc32c }}",
"additionalAuthenticatedDataCrc32c": "{{ additionalAuthenticatedDataCrc32c }}"
}';
Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
EXEC google.cloudkms.crypto_keys.decrypt
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@keyRingsId='{{ keyRingsId }}' --required,
@cryptoKeysId='{{ cryptoKeysId }}' --required
@@json=
'{
"ciphertext": "{{ ciphertext }}",
"additionalAuthenticatedData": "{{ additionalAuthenticatedData }}",
"ciphertextCrc32c": "{{ ciphertextCrc32c }}",
"additionalAuthenticatedDataCrc32c": "{{ additionalAuthenticatedDataCrc32c }}"
}';