Skip to main content

GetPublicKey

Downloads the public key of an asymmetric KMS key.

Description

The `GetPublicKey` operation returns the public key from an asymmetric KMS key. The KMS key must be an asymmetric key and the key state must be `Enabled`. You can use the public key to encrypt data or verify signatures outside of QKMS.

note
  • The KMS key must be asymmetric.
  • The key state must be `Enabled`.
  • The public key is returned in plaintext.
  • You can use the public key outside of QKMS for encryption or signature verification.

Request Syntax

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.GetPublicKey
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab" }
Values in italics indicate user input and should be replaced with actual values.

Request Parameters

Headers

NameDescriptionRequiredType
Content-TypeMust be "application/x-amz-json-1.1"Yesstring
X-Amz-TargetMust be "TrentService.GetPublicKey"Yesstring

Request Body

NameDescriptionRequiredType
KeyIdIdentifies the asymmetric KMS key that contains the public key. The value can be the ID or ARN of a KMS key.Yesstring
GrantTokensA list of grant tokens. Use grant tokens when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency.Noarray

Examples

Example 1: Get the public key of an RSA KMS key

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.GetPublicKey
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab" }
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "arn:verenc:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "PublicKey": "Base64-encoded public key", "CustomerMasterKeySpec": "RSA_2048", "KeyUsage": "ENCRYPT_DECRYPT", "EncryptionAlgorithms": [ "RSAES_OAEP_SHA_1", "RSAES_OAEP_SHA_256" ] }
Values in italics indicate variable response values.

Example 2: Get the public key of an ECC signing key

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.GetPublicKey
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab" }
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "arn:verenc:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "PublicKey": "Base64-encoded public key", "CustomerMasterKeySpec": "ECC_NIST_P256", "KeyUsage": "SIGN_VERIFY", "SigningAlgorithms": [ "ECDSA_SHA_256" ] }
Values in italics indicate variable response values.

Response Syntax

HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "string", "PublicKey": "blob", "CustomerMasterKeySpec": "string", "KeyUsage": "string", "EncryptionAlgorithms": [ "string" ], "SigningAlgorithms": [ "string" ] }
Values in italics indicate variable response values.

Response Elements

NameDescriptionRequiredType
KeyIdThe Amazon Resource Name (ARN) of the asymmetric KMS key from which the public key was downloaded.NoString
PublicKeyThe public key (plaintext).NoString
CustomerMasterKeySpecThe type of the asymmetric KMS key (e.g., RSA_2048, RSA_3072, RSA_4096, ECC_NIST_P256, etc.).NoString
KeyUsageThe permitted use of the public key. Valid values are ENCRYPT_DECRYPT or SIGN_VERIFY.NoString
EncryptionAlgorithmsThe encryption algorithms that QKMS supports for this key. Present only for asymmetric KMS keys with KeyUsage of ENCRYPT_DECRYPT.NoString
SigningAlgorithmsThe signing algorithms that QKMS supports for this key. Present only for asymmetric KMS keys with KeyUsage of SIGN_VERIFY.NoString

Special Errors

Error CodeDescription
DependencyTimeoutExceptionThe system timed out while trying to fulfill the request.
DisabledExceptionThe request was rejected because the specified KMS key is disabled.
InvalidKeyUsageExceptionThe request was rejected because the specified KeyId value cannot be used for this operation.
KeyUnavailableExceptionThe request was rejected because the specified KMS key was not available.
KMSInternalExceptionThe request was rejected because an internal error occurred.
KMSInvalidStateExceptionThe request was rejected because the key state is not valid for this operation.
NotFoundExceptionThe request was rejected because the specified entity or resource could not be found.
UnsupportedOperationExceptionThe request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.

Permissions

To use the `GetPublicKey` operation, you must have the following permissions:

  • `kms:GetPublicKey` on the KMS key (specified in the policy)

Try It Out

Test GetPublicKey

Download the public key of an asymmetric KMS key.

Coming Soon

This feature is currently under development and will be available soon.