tessl install tessl/golang-cloud-google-com--go--kms@1.24.0Go Client Library for Google Cloud Key Management Service (KMS) API for managing cryptographic keys and performing cryptographic operations
This document provides a comprehensive reference for all request and response message types in the Cloud KMS Go client library. These types are used with client methods to perform KMS operations.
Package: cloud.google.com/go/kms/apiv1/kmspb and cloud.google.com/go/kms/inventory/apiv1/inventorypb
All types implement protocol buffer interfaces: ProtoMessage, ProtoReflect, Descriptor, Reset, and String.
type CreateKeyRingRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
KeyRingId string // Required: Must be unique within location
KeyRing *KeyRing // Required: KeyRing with initial field values
}Used with: KeyManagementClient.CreateKeyRing()
type GetKeyRingRequest struct {
Name string // Required: "projects/{project}/locations/{location}/keyRings/{keyRing}"
}Used with: KeyManagementClient.GetKeyRing()
type ListKeyRingsRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
PageSize int32 // Optional: Maximum number of items to return
PageToken string // Optional: Token from previous ListKeyRingsResponse
Filter string // Optional: Filter expression
OrderBy string // Optional: Ordering specification
}Used with: KeyManagementClient.ListKeyRings()
type ListKeyRingsResponse struct {
KeyRings []*KeyRing // The list of KeyRings
NextPageToken string // Token for next page
TotalSize int32 // Total number of KeyRings (may be estimate)
}type CreateCryptoKeyRequest struct {
Parent string // Required: KeyRing name
CryptoKeyId string // Required: CryptoKey ID
CryptoKey *CryptoKey // Required: Initial field values
SkipInitialVersionCreation bool // Optional: Skip creating initial version
}Used with: KeyManagementClient.CreateCryptoKey()
type GetCryptoKeyRequest struct {
Name string // Required: CryptoKey resource name
}Used with: KeyManagementClient.GetCryptoKey()
type ListCryptoKeysRequest struct {
Parent string // Required: KeyRing name
PageSize int32 // Optional: Max items per page
PageToken string // Optional: Pagination token
VersionView CryptoKeyVersion_CryptoKeyVersionView // Optional: View for versions
Filter string // Optional: Filter expression
OrderBy string // Optional: Ordering specification
}Used with: KeyManagementClient.ListCryptoKeys(), KeyDashboardClient.ListCryptoKeys()
type ListCryptoKeysResponse struct {
CryptoKeys []*CryptoKey // The list of CryptoKeys
NextPageToken string // Token for next page
TotalSize int32 // Total number of CryptoKeys
}type UpdateCryptoKeyRequest struct {
CryptoKey *CryptoKey // Required: CryptoKey with updated values
UpdateMask *fieldmaskpb.FieldMask // Required: Fields to update
}Used with: KeyManagementClient.UpdateCryptoKey()
Common UpdateMask Paths:
"labels""rotation_period""next_rotation_time""version_template.algorithm""version_template.protection_level"type UpdateCryptoKeyPrimaryVersionRequest struct {
Name string // Required: CryptoKey resource name
CryptoKeyVersionId string // Required: ID of version to make primary
}Used with: KeyManagementClient.UpdateCryptoKeyPrimaryVersion()
type CreateCryptoKeyVersionRequest struct {
Parent string // Required: CryptoKey name
CryptoKeyVersion *CryptoKeyVersion // Required: Initial field values
}Used with: KeyManagementClient.CreateCryptoKeyVersion()
type GetCryptoKeyVersionRequest struct {
Name string // Required: CryptoKeyVersion resource name
}Used with: KeyManagementClient.GetCryptoKeyVersion()
type ListCryptoKeyVersionsRequest struct {
Parent string // Required: CryptoKey name
PageSize int32 // Optional: Max items per page
PageToken string // Optional: Pagination token
View CryptoKeyVersion_CryptoKeyVersionView // Optional: View specification
Filter string // Optional: Filter expression
OrderBy string // Optional: Ordering specification
}Used with: KeyManagementClient.ListCryptoKeyVersions()
type ListCryptoKeyVersionsResponse struct {
CryptoKeyVersions []*CryptoKeyVersion // The list of CryptoKeyVersions
NextPageToken string // Token for next page
TotalSize int32 // Total number of versions
}type UpdateCryptoKeyVersionRequest struct {
CryptoKeyVersion *CryptoKeyVersion // Required: Updated values
UpdateMask *fieldmaskpb.FieldMask // Required: Fields to update
}Used with: KeyManagementClient.UpdateCryptoKeyVersion()
Common UpdateMask Paths:
"state" - Change between ENABLED and DISABLED"external_protection_level_options.external_key_uri"type DestroyCryptoKeyVersionRequest struct {
Name string // Required: CryptoKeyVersion resource name
}Used with: KeyManagementClient.DestroyCryptoKeyVersion()
type RestoreCryptoKeyVersionRequest struct {
Name string // Required: CryptoKeyVersion resource name
}Used with: KeyManagementClient.RestoreCryptoKeyVersion()
type GetPublicKeyRequest struct {
Name string // Required: CryptoKeyVersion name
}Used with: KeyManagementClient.GetPublicKey()
type EncryptRequest struct {
Name string // Required: CryptoKey or CryptoKeyVersion name
Plaintext []byte // Required: Data to encrypt (≤64KiB)
AdditionalAuthenticatedData []byte // Optional: AAD for AEAD ciphers
PlaintextCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
AdditionalAuthenticatedDataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.Encrypt()
type EncryptResponse struct {
Name string // CryptoKeyVersion used
Ciphertext []byte // Encrypted data
CiphertextCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedPlaintextCrc32C bool // Whether plaintext CRC32C was verified
VerifiedAdditionalAuthenticatedDataCrc32C bool // Whether AAD CRC32C was verified
ProtectionLevel ProtectionLevel // Protection level used
}type DecryptRequest struct {
Name string // Required: CryptoKey name
Ciphertext []byte // Required: Encrypted data from Encrypt
AdditionalAuthenticatedData []byte // Optional: AAD (must match Encrypt)
CiphertextCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
AdditionalAuthenticatedDataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.Decrypt()
type DecryptResponse struct {
Plaintext []byte // Decrypted data
PlaintextCrc32C *wrapperspb.Int64Value // Integrity verification
UsedPrimary bool // Whether primary version was used
ProtectionLevel ProtectionLevel // Protection level used
}type RawEncryptRequest struct {
Name string // Required: CryptoKeyVersion name
Plaintext []byte // Required: ≤64KiB for AES-GCM, ≤8KiB for AES-CBC/CTR
AdditionalAuthenticatedData []byte // Optional: AAD (AES-GCM only)
PlaintextCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
AdditionalAuthenticatedDataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
InitializationVector []byte // Optional: IV (AES-CBC/CTR, exactly 16 bytes)
InitializationVectorCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.RawEncrypt()
type RawEncryptResponse struct {
Ciphertext []byte // Encrypted data
InitializationVector []byte // IV used
TagLength int32 // AEAD tag length
CiphertextCrc32C *wrapperspb.Int64Value // Integrity verification
InitializationVectorCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedPlaintextCrc32C bool // Whether verified
VerifiedAdditionalAuthenticatedDataCrc32C bool // Whether verified
VerifiedInitializationVectorCrc32C bool // Whether verified
Name string // CryptoKeyVersion used
ProtectionLevel ProtectionLevel // Protection level
}type RawDecryptRequest struct {
Name string // Required: CryptoKeyVersion name
Ciphertext []byte // Required: Encrypted data from RawEncrypt
AdditionalAuthenticatedData []byte // Optional: AAD (AES-GCM only)
InitializationVector []byte // Required: IV (AES-CBC/CTR)
TagLength int32 // Required: Auth tag length (AES-GCM)
CiphertextCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
AdditionalAuthenticatedDataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
InitializationVectorCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.RawDecrypt()
type RawDecryptResponse struct {
Plaintext []byte // Decrypted data
PlaintextCrc32C *wrapperspb.Int64Value // Integrity verification
ProtectionLevel ProtectionLevel // Protection level
VerifiedCiphertextCrc32C bool // Whether verified
VerifiedAdditionalAuthenticatedDataCrc32C bool // Whether verified
VerifiedInitializationVectorCrc32C bool // Whether verified
}type AsymmetricSignRequest struct {
Name string // Required: CryptoKeyVersion name
Digest *Digest // Optional: Digest of data to sign
DigestCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum of digest
Data []byte // Optional: Raw data to sign (Raw PKCS#1 only)
DataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum of data
}Used with: KeyManagementClient.AsymmetricSign()
type Digest struct {
Sha256 []byte // SHA-256 hash (exactly 32 bytes)
Sha384 []byte // SHA-384 hash (exactly 48 bytes)
Sha512 []byte // SHA-512 hash (exactly 64 bytes)
}A Digest holds a cryptographic message digest. The digest field is a oneof, so only one hash algorithm field should be set.
Nested Types:
type Digest_Sha256 struct {
Sha256 []byte // A message digest produced with the SHA-256 algorithm
}
type Digest_Sha384 struct {
Sha384 []byte // A message digest produced with the SHA-384 algorithm
}
type Digest_Sha512 struct {
Sha512 []byte // A message digest produced with the SHA-512 algorithm
}These types implement the isDigest_Digest interface for the protobuf oneof field.
type AsymmetricSignResponse struct {
Signature []byte // Created signature
SignatureCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedDigestCrc32C bool // Whether digest CRC32C was verified
VerifiedDataCrc32C bool // Whether data CRC32C was verified
Name string // CryptoKeyVersion used
ProtectionLevel ProtectionLevel // Protection level
}type AsymmetricDecryptRequest struct {
Name string // Required: CryptoKeyVersion name
Ciphertext []byte // Required: Data encrypted with public key
CiphertextCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.AsymmetricDecrypt()
type AsymmetricDecryptResponse struct {
Plaintext []byte // Decrypted data
PlaintextCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedCiphertextCrc32C bool // Whether ciphertext CRC32C was verified
ProtectionLevel ProtectionLevel // Protection level
}type MacSignRequest struct {
Name string // Required: CryptoKeyVersion name
Data []byte // Required: Data to sign (≤64KiB)
DataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.MacSign()
type MacSignResponse struct {
Name string // CryptoKeyVersion used
Mac []byte // Generated signature
MacCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedDataCrc32C bool // Whether data CRC32C was verified
ProtectionLevel ProtectionLevel // Protection level
}type MacVerifyRequest struct {
Name string // Required: CryptoKeyVersion name
Data []byte // Required: Data used to generate MAC
DataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
Mac []byte // Required: Signature to verify
MacCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.MacVerify()
type MacVerifyResponse struct {
Name string // CryptoKeyVersion used
Success bool // Whether MAC is valid
VerifiedDataCrc32C bool // Whether data CRC32C was verified
VerifiedMacCrc32C bool // Whether MAC CRC32C was verified
VerifiedSuccessIntegrity bool // Whether success integrity was verified
ProtectionLevel ProtectionLevel // Protection level
}type DecapsulateRequest struct {
Name string // Required: CryptoKeyVersion name
CiphertextDataCrc32C *wrapperspb.Int64Value // Optional: CRC32C checksum
}Used with: KeyManagementClient.Decapsulate()
type DecapsulateResponse struct {
Plaintext []byte // Decrypted data
PlaintextCrc32C *wrapperspb.Int64Value // Integrity verification
VerifiedCiphertextCrc32C bool // Whether ciphertext CRC32C was verified
ProtectionLevel ProtectionLevel // Protection level
}type GenerateRandomBytesRequest struct {
Location string // Required: Project or organization location
LengthBytes int32 // Required: Number of bytes (≥1, ≤1024)
ProtectionLevel ProtectionLevel // Required: Protection level to use
}Used with: KeyManagementClient.GenerateRandomBytes()
type GenerateRandomBytesResponse struct {
Data []byte // Generated random bytes
DataCrc32C *wrapperspb.Int64Value // Integrity verification
}type CreateImportJobRequest struct {
Parent string // Required: KeyRing name
ImportJobId string // Required: ImportJob ID
ImportJob *ImportJob // Required: Initial field values
}Used with: KeyManagementClient.CreateImportJob()
type GetImportJobRequest struct {
Name string // Required: ImportJob resource name
}Used with: KeyManagementClient.GetImportJob()
type ListImportJobsRequest struct {
Parent string // Required: KeyRing name
PageSize int32 // Optional: Max items per page
PageToken string // Optional: Pagination token
Filter string // Optional: Filter expression
OrderBy string // Optional: Ordering specification
}Used with: KeyManagementClient.ListImportJobs()
type ListImportJobsResponse struct {
ImportJobs []*ImportJob // The list of ImportJobs
NextPageToken string // Token for next page
TotalSize int32 // Total number of ImportJobs
}type ImportCryptoKeyVersionRequest struct {
Parent string // Required: CryptoKey name
CryptoKeyVersion string // Optional: Version name (for reimport)
Algorithm CryptoKeyVersion_CryptoKeyVersionAlgorithm // Required: Algorithm of key being imported
ImportJob string // Required: ImportJob name
WrappedKey []byte // Optional: Wrapped key material
RsaAesWrappedKey []byte // Optional: RSA/AES wrapped key material
}Used with: KeyManagementClient.ImportCryptoKeyVersion()
Nested Types:
type ImportCryptoKeyVersionRequest_RsaAesWrappedKey struct {
RsaAesWrappedKey []byte // RSA/AES wrapped key material
}This nested type implements the isImportCryptoKeyVersionRequest_WrappedKeyMaterial interface for the protobuf oneof field. Prefer using the WrappedKey field in the main request struct in new work.
type CreateKeyHandleRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
KeyHandleId string // Optional: ID for the KeyHandle
KeyHandle *KeyHandle // Required: KeyHandle with initial field values
}Used with: AutokeyClient.CreateKeyHandle()
type GetKeyHandleRequest struct {
Name string // Required: KeyHandle resource name
}Used with: AutokeyClient.GetKeyHandle()
type ListKeyHandlesRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
PageSize int32 // Optional: Max 1000, default 500
PageToken string // Optional: Pagination token
Filter string // Optional: Filter expression
}Used with: AutokeyClient.ListKeyHandles()
type ListKeyHandlesResponse struct {
KeyHandles []*KeyHandle // Resulting list of KeyHandles
}type CreateKeyHandleMetadata struct {
// Empty message - metadata for CreateKeyHandle long-running operation
}type UpdateAutokeyConfigRequest struct {
AutokeyConfig *AutokeyConfig // Required: AutokeyConfig with updated values
UpdateMask *fieldmaskpb.FieldMask // Required: Fields to update
}Used with: AutokeyAdminClient.UpdateAutokeyConfig()
type GetAutokeyConfigRequest struct {
Name string // Required: "folders/{folder}/autokeyConfig"
}Used with: AutokeyAdminClient.GetAutokeyConfig()
type ShowEffectiveAutokeyConfigRequest struct {
Parent string // Required: "projects/{PROJECT_ID}" or "projects/{PROJECT_NUMBER}"
}Used with: AutokeyAdminClient.ShowEffectiveAutokeyConfig()
type ShowEffectiveAutokeyConfigResponse struct {
KeyProject string // Name of key project configured in folder ancestry
}type ListEkmConnectionsRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
PageSize int32 // Optional: Max items per page
PageToken string // Optional: Pagination token
Filter string // Optional: Filter expression
OrderBy string // Optional: Ordering specification
}Used with: EkmClient.ListEkmConnections()
type ListEkmConnectionsResponse struct {
EkmConnections []*EkmConnection // The list of EkmConnections
NextPageToken string // Token for next page
TotalSize int32 // Total number of EkmConnections
}type GetEkmConnectionRequest struct {
Name string // Required: EkmConnection resource name
}Used with: EkmClient.GetEkmConnection()
type CreateEkmConnectionRequest struct {
Parent string // Required: "projects/{project}/locations/{location}"
EkmConnectionId string // Required: EkmConnection ID
EkmConnection *EkmConnection // Required: Initial field values
}Used with: EkmClient.CreateEkmConnection()
type UpdateEkmConnectionRequest struct {
EkmConnection *EkmConnection // Required: Updated values
UpdateMask *fieldmaskpb.FieldMask // Required: Fields to update
}Used with: EkmClient.UpdateEkmConnection()
type GetEkmConfigRequest struct {
Name string // Required: "projects/{project}/locations/{location}/ekmConfig"
}Used with: EkmClient.GetEkmConfig()
type UpdateEkmConfigRequest struct {
EkmConfig *EkmConfig // Required: Updated values
UpdateMask *fieldmaskpb.FieldMask // Required: Fields to update
}Used with: EkmClient.UpdateEkmConfig()
type VerifyConnectivityRequest struct {
Name string // Required: EkmConnection resource name
}Used with: EkmClient.VerifyConnectivity()
type VerifyConnectivityResponse struct {
// Empty message - successful verification
}type ListCryptoKeysRequest struct {
Parent string // Required: "projects/{project}"
PageSize int32 // Optional: Max 1000
PageToken string // Optional: Pagination token
}Used with: KeyDashboardClient.ListCryptoKeys()
type ListCryptoKeysResponse struct {
CryptoKeys []*kmspb.CryptoKey // The list of CryptoKeys
NextPageToken string // Token for next page
}type GetProtectedResourcesSummaryRequest struct {
Name string // Required: "projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}/protectedResourcesSummary"
}Used with: KeyTrackingClient.GetProtectedResourcesSummary()
type SearchProtectedResourcesRequest struct {
Scope string // Required: "organizations/{organization}"
CryptoKey string // Required: CryptoKey name
PageSize int32 // Optional: Max 500
PageToken string // Optional: Pagination token
ResourceTypes []string // Optional: Filter by resource types
}Used with: KeyTrackingClient.SearchProtectedResources()
type SearchProtectedResourcesResponse struct {
ProtectedResources []*ProtectedResource // The list of protected resources
NextPageToken string // Token for next page
}The following are low-level gRPC service client interfaces generated from protocol buffer definitions. Most users should use the higher-level client wrappers (KeyManagementClient, AutokeyClient, etc.) from cloud.google.com/go/kms/apiv1 instead.
type KeyManagementServiceClient interface {
// Methods for KeyRing operations
ListKeyRings(ctx context.Context, in *ListKeyRingsRequest, opts ...grpc.CallOption) (*ListKeyRingsResponse, error)
GetKeyRing(ctx context.Context, in *GetKeyRingRequest, opts ...grpc.CallOption) (*KeyRing, error)
CreateKeyRing(ctx context.Context, in *CreateKeyRingRequest, opts ...grpc.CallOption) (*KeyRing, error)
// Methods for CryptoKey and CryptoKeyVersion operations
ListCryptoKeys(ctx context.Context, in *ListCryptoKeysRequest, opts ...grpc.CallOption) (*ListCryptoKeysResponse, error)
GetCryptoKey(ctx context.Context, in *GetCryptoKeyRequest, opts ...grpc.CallOption) (*CryptoKey, error)
CreateCryptoKey(ctx context.Context, in *CreateCryptoKeyRequest, opts ...grpc.CallOption) (*CryptoKey, error)
// ... and many more methods
}Constructor: NewKeyManagementServiceClient(cc grpc.ClientConnInterface) KeyManagementServiceClient
type EkmServiceClient interface {
ListEkmConnections(ctx context.Context, in *ListEkmConnectionsRequest, opts ...grpc.CallOption) (*ListEkmConnectionsResponse, error)
GetEkmConnection(ctx context.Context, in *GetEkmConnectionRequest, opts ...grpc.CallOption) (*EkmConnection, error)
CreateEkmConnection(ctx context.Context, in *CreateEkmConnectionRequest, opts ...grpc.CallOption) (*EkmConnection, error)
UpdateEkmConnection(ctx context.Context, in *UpdateEkmConnectionRequest, opts ...grpc.CallOption) (*EkmConnection, error)
GetEkmConfig(ctx context.Context, in *GetEkmConfigRequest, opts ...grpc.CallOption) (*EkmConfig, error)
UpdateEkmConfig(ctx context.Context, in *UpdateEkmConfigRequest, opts ...grpc.CallOption) (*EkmConfig, error)
VerifyConnectivity(ctx context.Context, in *VerifyConnectivityRequest, opts ...grpc.CallOption) (*VerifyConnectivityResponse, error)
}Constructor: NewEkmServiceClient(cc grpc.ClientConnInterface) EkmServiceClient
type KeyDashboardServiceClient interface {
ListCryptoKeys(ctx context.Context, in *ListCryptoKeysRequest, opts ...grpc.CallOption) (*ListCryptoKeysResponse, error)
}Constructor: NewKeyDashboardServiceClient(cc grpc.ClientConnInterface) KeyDashboardServiceClient
type KeyTrackingServiceClient interface {
GetProtectedResourcesSummary(ctx context.Context, in *GetProtectedResourcesSummaryRequest, opts ...grpc.CallOption) (*ProtectedResourcesSummary, error)
SearchProtectedResources(ctx context.Context, in *SearchProtectedResourcesRequest, opts ...grpc.CallOption) (*SearchProtectedResourcesResponse, error)
}Constructor: NewKeyTrackingServiceClient(cc grpc.ClientConnInterface) KeyTrackingServiceClient
Note: These interfaces are primarily for advanced use cases. Most applications should use the high-level clients:
kms.NewKeyManagementClient() instead of NewKeyManagementServiceClient()kms.NewEkmClient() instead of NewEkmServiceClient()inventory.NewKeyDashboardClient() instead of NewKeyDashboardServiceClient()inventory.NewKeyTrackingClient() instead of NewKeyTrackingServiceClient()