import type { MetadataBearer as __MetadataBearer } from "@smithy/types"; import type { GetPublicKeyRequest, GetPublicKeyResponse } from "../models/models_0"; /** * @public */ export type { __MetadataBearer }; /** * @public * * The input for {@link GetPublicKeyCommand}. */ export interface GetPublicKeyCommandInput extends GetPublicKeyRequest { } /** * @public * * The output of {@link GetPublicKeyCommand}. */ export interface GetPublicKeyCommandOutput extends GetPublicKeyResponse, __MetadataBearer { } declare const GetPublicKeyCommand_base: { new (input: GetPublicKeyCommandInput): import("@smithy/core/client").CommandImpl; new (input: GetPublicKeyCommandInput): import("@smithy/core/client").CommandImpl; getEndpointParameterInstructions(): import("@smithy/types").EndpointParameterInstructions; }; /** *

Returns the public key of an asymmetric KMS key. Unlike the private key of a asymmetric * KMS key, which never leaves KMS unencrypted, callers with kms:GetPublicKey * permission can download the public key of an asymmetric KMS key. You can share the public key * to allow others to encrypt messages and verify signatures outside of KMS. * For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide.

*

You do not need to download the public key. Instead, you can use the public key within * KMS by calling the Encrypt, ReEncrypt, or Verify operations with the identifier of an asymmetric KMS key. When you use the * public key within KMS, you benefit from the authentication, authorization, and logging that * are part of every KMS operation. You also reduce of risk of encrypting data that cannot be * decrypted. These features are not effective outside of KMS.

*

To help you use the public key safely outside of KMS, GetPublicKey returns * important information about the public key in the response, including:

* *

Although KMS cannot enforce these restrictions on external operations, it is crucial * that you use this information to prevent the public key from being used improperly. For * example, you can prevent a public signing key from being used encrypt data, or prevent a * public key from being used with an encryption algorithm that is not supported by KMS. You * can also avoid errors, such as using the wrong signing algorithm in a verification * operation.

*

To verify a signature outside of KMS with an SM2 public key (China Regions only), you * must specify the distinguishing ID. By default, KMS uses 1234567812345678 as * the distinguishing ID. For more information, see Offline * verification with SM2 key pairs.

*

The KMS key that you use for this operation must be in a compatible key state. For * details, see Key states of KMS keys in the Key Management Service Developer Guide.

*

* Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify * the key ARN or alias ARN in the value of the KeyId parameter.

*

* Required permissions: kms:GetPublicKey (key policy)

*

* Related operations: CreateKey *

*

* Eventual consistency: The KMS API follows an eventual consistency model. * For more information, see KMS eventual consistency.

* @example * Use a bare-bones client and the command you need to make an API call. * ```javascript * import { KMSClient, GetPublicKeyCommand } from "@aws-sdk/client-kms"; // ES Modules import * // const { KMSClient, GetPublicKeyCommand } = require("@aws-sdk/client-kms"); // CommonJS import * // import type { KMSClientConfig } from "@aws-sdk/client-kms"; * const config = {}; // type is KMSClientConfig * const client = new KMSClient(config); * const input = { // GetPublicKeyRequest * KeyId: "STRING_VALUE", // required * GrantTokens: [ // GrantTokenList * "STRING_VALUE", * ], * }; * const command = new GetPublicKeyCommand(input); * const response = await client.send(command); * // { // GetPublicKeyResponse * // KeyId: "STRING_VALUE", * // PublicKey: new Uint8Array(), * // CustomerMasterKeySpec: "RSA_2048" || "RSA_3072" || "RSA_4096" || "ECC_NIST_P256" || "ECC_NIST_P384" || "ECC_NIST_P521" || "ECC_SECG_P256K1" || "SYMMETRIC_DEFAULT" || "HMAC_224" || "HMAC_256" || "HMAC_384" || "HMAC_512" || "SM2", * // KeySpec: "RSA_2048" || "RSA_3072" || "RSA_4096" || "ECC_NIST_P256" || "ECC_NIST_P384" || "ECC_NIST_P521" || "ECC_SECG_P256K1" || "SYMMETRIC_DEFAULT" || "HMAC_224" || "HMAC_256" || "HMAC_384" || "HMAC_512" || "SM2" || "ML_DSA_44" || "ML_DSA_65" || "ML_DSA_87" || "ECC_NIST_EDWARDS25519" || "ML_KEM_512" || "ML_KEM_768" || "ML_KEM_1024", * // KeyUsage: "SIGN_VERIFY" || "ENCRYPT_DECRYPT" || "GENERATE_VERIFY_MAC" || "KEY_AGREEMENT" || "ENCAPSULATE_DECAPSULATE", * // EncryptionAlgorithms: [ // EncryptionAlgorithmSpecList * // "SYMMETRIC_DEFAULT" || "RSAES_OAEP_SHA_1" || "RSAES_OAEP_SHA_256" || "SM2PKE", * // ], * // SigningAlgorithms: [ // SigningAlgorithmSpecList * // "RSASSA_PSS_SHA_256" || "RSASSA_PSS_SHA_384" || "RSASSA_PSS_SHA_512" || "RSASSA_PKCS1_V1_5_SHA_256" || "RSASSA_PKCS1_V1_5_SHA_384" || "RSASSA_PKCS1_V1_5_SHA_512" || "ECDSA_SHA_256" || "ECDSA_SHA_384" || "ECDSA_SHA_512" || "SM2DSA" || "ML_DSA_SHAKE_256" || "ED25519_SHA_512" || "ED25519_PH_SHA_512", * // ], * // KeyAgreementAlgorithms: [ // KeyAgreementAlgorithmSpecList * // "ECDH", * // ], * // EncapsulationAlgorithms: [ // EncapsulationAlgorithmSpecList * // "ML_KEM", * // ], * // }; * * ``` * * @param GetPublicKeyCommandInput - {@link GetPublicKeyCommandInput} * @returns {@link GetPublicKeyCommandOutput} * @see {@link GetPublicKeyCommandInput} for command's `input` shape. * @see {@link GetPublicKeyCommandOutput} for command's `response` shape. * @see {@link KMSClientResolvedConfig | config} for KMSClient's `config` shape. * * @throws {@link DependencyTimeoutException} (server fault) *

The system timed out while trying to fulfill the request. You can retry the * request.

* * @throws {@link DisabledException} (client fault) *

The request was rejected because the specified KMS key is not enabled.

* * @throws {@link InvalidArnException} (client fault) *

The request was rejected because a specified ARN, or an ARN in a key policy, is not * valid.

* * @throws {@link InvalidGrantTokenException} (client fault) *

The request was rejected because the specified grant token is not valid.

* * @throws {@link InvalidKeyUsageException} (client fault) *

The request was rejected for one of the following reasons:

* *

For encrypting, decrypting, re-encrypting, and generating data keys, the * KeyUsage must be ENCRYPT_DECRYPT. For signing and verifying * messages, the KeyUsage must be SIGN_VERIFY. For generating and * verifying message authentication codes (MACs), the KeyUsage must be * GENERATE_VERIFY_MAC. For deriving key agreement secrets, the * KeyUsage must be KEY_AGREEMENT. For encapsulating and decapsulating * shared secrets, the KeyUsage must be ENCAPSULATE_DECAPSULATE. To find * the KeyUsage of a KMS key, use the DescribeKey operation.

*

To find the encryption or signing algorithms supported for a particular KMS key, use the * DescribeKey operation.

* * @throws {@link KeyUnavailableException} (server fault) *

The request was rejected because the specified KMS key was not available. You can retry * the request.

* * @throws {@link KMSInternalException} (server fault) *

The request was rejected because an internal exception occurred. The request can be * retried.

* * @throws {@link KMSInvalidStateException} (client fault) *

The request was rejected because the state of the specified resource is not valid for this * request.

*

This exceptions means one of the following:

* * * @throws {@link NotFoundException} (client fault) *

The request was rejected because the specified entity or resource could not be * found.

* * @throws {@link UnsupportedOperationException} (client fault) *

The request was rejected because a specified parameter is not supported or a specified * resource is not valid for this operation.

* * @throws {@link KMSServiceException} *

Base exception class for all service exceptions from KMS service.

* * * @example To download the public key of an asymmetric KMS key * ```javascript * // This example gets the public key of an asymmetric RSA KMS key used for encryption and decryption. The operation returns the key spec, key usage, and encryption or signing algorithms to help you use the public key correctly outside of AWS KMS. * const input = { * KeyId: "arn:aws:kms:us-west-2:111122223333:key/0987dcba-09fe-87dc-65ba-ab0987654321" * }; * const command = new GetPublicKeyCommand(input); * const response = await client.send(command); * /* response is * { * CustomerMasterKeySpec: "RSA_4096", * EncryptionAlgorithms: [ * "RSAES_OAEP_SHA_1", * "RSAES_OAEP_SHA_256" * ], * KeyId: "arn:aws:kms:us-west-2:111122223333:key/0987dcba-09fe-87dc-65ba-ab0987654321", * KeyUsage: "ENCRYPT_DECRYPT", * PublicKey: "" * } * *\/ * ``` * * @public */ export declare class GetPublicKeyCommand extends GetPublicKeyCommand_base { /** @internal type navigation helper, not in runtime. */ protected static __types: { api: { input: GetPublicKeyRequest; output: GetPublicKeyResponse; }; sdk: { input: GetPublicKeyCommandInput; output: GetPublicKeyCommandOutput; }; }; }