libZSservicesZSamazonka-kmsZSamazonka-kms
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.KMS.GetPublicKey

Description

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 symmetric and asymmetric KMS keys, see Using Symmetric and 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. For details, see Special Considerations for Downloading Public Keys.

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

  • KeySpec: The type of key material in the public key, such as RSA_4096 or ECC_NIST_P521.
  • KeyUsage: Whether the key is used for encryption or signing.
  • EncryptionAlgorithms or SigningAlgorithms: A list of the encryption algorithms or the signing algorithms for the key.

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.

The KMS key that you use for this operation must be in a compatible key state. For details, see Key state: Effect on your KMS key 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

Synopsis

Creating a Request

data GetPublicKey Source #

See: newGetPublicKey smart constructor.

Constructors

GetPublicKey' 

Fields

  • grantTokens :: Maybe [Text]

    A list of grant tokens.

    Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide.

  • keyId :: Text

    Identifies the asymmetric KMS key that includes the public key.

    To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.

    For example:

    • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
    • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
    • Alias name: alias/ExampleAlias
    • Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias

    To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.

Instances

Instances details
Eq GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Read GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Show GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Generic GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Associated Types

type Rep GetPublicKey :: Type -> Type #

NFData GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Methods

rnf :: GetPublicKey -> () #

Hashable GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

ToJSON GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

AWSRequest GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Associated Types

type AWSResponse GetPublicKey #

ToHeaders GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

ToPath GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

ToQuery GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

type Rep GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

type Rep GetPublicKey = D1 ('MetaData "GetPublicKey" "Amazonka.KMS.GetPublicKey" "libZSservicesZSamazonka-kmsZSamazonka-kms" 'False) (C1 ('MetaCons "GetPublicKey'" 'PrefixI 'True) (S1 ('MetaSel ('Just "grantTokens") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Just "keyId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)))
type AWSResponse GetPublicKey Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

newGetPublicKey Source #

Create a value of GetPublicKey with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:grantTokens:GetPublicKey', getPublicKey_grantTokens - A list of grant tokens.

Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide.

$sel:keyId:GetPublicKey', getPublicKey_keyId - Identifies the asymmetric KMS key that includes the public key.

To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
  • Alias name: alias/ExampleAlias
  • Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.

Request Lenses

getPublicKey_grantTokens :: Lens' GetPublicKey (Maybe [Text]) Source #

A list of grant tokens.

Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide.

getPublicKey_keyId :: Lens' GetPublicKey Text Source #

Identifies the asymmetric KMS key that includes the public key.

To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
  • Alias name: alias/ExampleAlias
  • Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.

Destructuring the Response

data GetPublicKeyResponse Source #

See: newGetPublicKeyResponse smart constructor.

Constructors

GetPublicKeyResponse' 

Fields

  • keySpec :: Maybe KeySpec

    The type of the of the public key that was downloaded.

  • keyId :: Maybe Text

    The Amazon Resource Name (key ARN) of the asymmetric KMS key from which the public key was downloaded.

  • customerMasterKeySpec :: Maybe CustomerMasterKeySpec

    Instead, use the KeySpec field in the GetPublicKey response.

    The KeySpec and CustomerMasterKeySpec fields have the same value. We recommend that you use the KeySpec field in your code. However, to avoid breaking changes, KMS will support both fields.

  • encryptionAlgorithms :: Maybe [EncryptionAlgorithmSpec]

    The encryption algorithms that KMS supports for this key.

    This information is critical. If a public key encrypts data outside of KMS by using an unsupported encryption algorithm, the ciphertext cannot be decrypted.

    This field appears in the response only when the KeyUsage of the public key is ENCRYPT_DECRYPT.

  • publicKey :: Maybe Base64

    The exported public key.

    The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.

  • signingAlgorithms :: Maybe [SigningAlgorithmSpec]

    The signing algorithms that KMS supports for this key.

    This field appears in the response only when the KeyUsage of the public key is SIGN_VERIFY.

  • keyUsage :: Maybe KeyUsageType

    The permitted use of the public key. Valid values are ENCRYPT_DECRYPT or SIGN_VERIFY.

    This information is critical. If a public key with SIGN_VERIFY key usage encrypts data outside of KMS, the ciphertext cannot be decrypted.

  • httpStatus :: Int

    The response's http status code.

Instances

Instances details
Eq GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Read GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Show GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Generic GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Associated Types

type Rep GetPublicKeyResponse :: Type -> Type #

NFData GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

Methods

rnf :: GetPublicKeyResponse -> () #

type Rep GetPublicKeyResponse Source # 
Instance details

Defined in Amazonka.KMS.GetPublicKey

newGetPublicKeyResponse Source #

Create a value of GetPublicKeyResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:keySpec:GetPublicKeyResponse', getPublicKeyResponse_keySpec - The type of the of the public key that was downloaded.

$sel:keyId:GetPublicKey', getPublicKeyResponse_keyId - The Amazon Resource Name (key ARN) of the asymmetric KMS key from which the public key was downloaded.

$sel:customerMasterKeySpec:GetPublicKeyResponse', getPublicKeyResponse_customerMasterKeySpec - Instead, use the KeySpec field in the GetPublicKey response.

The KeySpec and CustomerMasterKeySpec fields have the same value. We recommend that you use the KeySpec field in your code. However, to avoid breaking changes, KMS will support both fields.

$sel:encryptionAlgorithms:GetPublicKeyResponse', getPublicKeyResponse_encryptionAlgorithms - The encryption algorithms that KMS supports for this key.

This information is critical. If a public key encrypts data outside of KMS by using an unsupported encryption algorithm, the ciphertext cannot be decrypted.

This field appears in the response only when the KeyUsage of the public key is ENCRYPT_DECRYPT.

$sel:publicKey:GetPublicKeyResponse', getPublicKeyResponse_publicKey - The exported public key.

The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

$sel:signingAlgorithms:GetPublicKeyResponse', getPublicKeyResponse_signingAlgorithms - The signing algorithms that KMS supports for this key.

This field appears in the response only when the KeyUsage of the public key is SIGN_VERIFY.

$sel:keyUsage:GetPublicKeyResponse', getPublicKeyResponse_keyUsage - The permitted use of the public key. Valid values are ENCRYPT_DECRYPT or SIGN_VERIFY.

This information is critical. If a public key with SIGN_VERIFY key usage encrypts data outside of KMS, the ciphertext cannot be decrypted.

$sel:httpStatus:GetPublicKeyResponse', getPublicKeyResponse_httpStatus - The response's http status code.

Response Lenses

getPublicKeyResponse_keySpec :: Lens' GetPublicKeyResponse (Maybe KeySpec) Source #

The type of the of the public key that was downloaded.

getPublicKeyResponse_keyId :: Lens' GetPublicKeyResponse (Maybe Text) Source #

The Amazon Resource Name (key ARN) of the asymmetric KMS key from which the public key was downloaded.

getPublicKeyResponse_customerMasterKeySpec :: Lens' GetPublicKeyResponse (Maybe CustomerMasterKeySpec) Source #

Instead, use the KeySpec field in the GetPublicKey response.

The KeySpec and CustomerMasterKeySpec fields have the same value. We recommend that you use the KeySpec field in your code. However, to avoid breaking changes, KMS will support both fields.

getPublicKeyResponse_encryptionAlgorithms :: Lens' GetPublicKeyResponse (Maybe [EncryptionAlgorithmSpec]) Source #

The encryption algorithms that KMS supports for this key.

This information is critical. If a public key encrypts data outside of KMS by using an unsupported encryption algorithm, the ciphertext cannot be decrypted.

This field appears in the response only when the KeyUsage of the public key is ENCRYPT_DECRYPT.

getPublicKeyResponse_publicKey :: Lens' GetPublicKeyResponse (Maybe ByteString) Source #

The exported public key.

The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded.-- -- Note: This Lens automatically encodes and decodes Base64 data. -- The underlying isomorphism will encode to Base64 representation during -- serialisation, and decode from Base64 representation during deserialisation. -- This Lens accepts and returns only raw unencoded data.

getPublicKeyResponse_signingAlgorithms :: Lens' GetPublicKeyResponse (Maybe [SigningAlgorithmSpec]) Source #

The signing algorithms that KMS supports for this key.

This field appears in the response only when the KeyUsage of the public key is SIGN_VERIFY.

getPublicKeyResponse_keyUsage :: Lens' GetPublicKeyResponse (Maybe KeyUsageType) Source #

The permitted use of the public key. Valid values are ENCRYPT_DECRYPT or SIGN_VERIFY.

This information is critical. If a public key with SIGN_VERIFY key usage encrypts data outside of KMS, the ciphertext cannot be decrypted.