amazonka-kms-1.6.1: Amazon Key Management Service SDK.

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

Network.AWS.KMS.Encrypt

Contents

Description

Encrypts plaintext into ciphertext by using a customer master key (CMK). The Encrypt operation has two primary use cases:

  • You can encrypt up to 4 kilobytes (4096 bytes) of arbitrary data such as an RSA key, a database password, or other sensitive information.
  • To move encrypted data from one AWS region to another, you can use this operation to encrypt in the new region the plaintext data key that was used to encrypt the data in the original region. This provides you with an encrypted copy of the data key that can be decrypted in the new region and used there to decrypt the encrypted data.

To perform this operation on a CMK in a different AWS account, specify the key ARN or alias ARN in the value of the KeyId parameter.

Unless you are moving encrypted data from one region to another, you don't use this operation to encrypt a generated data key within a region. To get data keys that are already encrypted, call the GenerateDataKey or GenerateDataKeyWithoutPlaintext operation. Data keys don't need to be encrypted again by calling Encrypt .

To encrypt data locally in your application, use the GenerateDataKey operation to return a plaintext data encryption key and a copy of the key encrypted under the CMK of your choosing.

Synopsis

Creating a Request

encrypt Source #

Creates a value of Encrypt with the minimum fields required to make a request.

Use one of the following lenses to modify other fields as desired:

  • eEncryptionContext - Name-value pair that specifies the encryption context to be used for authenticated encryption. If used here, the same value must be supplied to the Decrypt API or decryption will fail. For more information, see Encryption Context .
  • eGrantTokens - A list of grant tokens. For more information, see Grant Tokens in the AWS Key Management Service Developer Guide .
  • eKeyId - A unique identifier for the customer master key (CMK). To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias". To specify a CMK in a different AWS 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:key1234abcd-12ab-34cd-56ef-1234567890ab * Alias name: aliasExampleAlias * Alias ARN: arn:aws:kms:us-east-2:111122223333:aliasExampleAlias@ To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey . To get the alias name and alias ARN, use ListAliases .
  • ePlaintext - Data to be encrypted.-- 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.

data Encrypt Source #

See: encrypt smart constructor.

Instances
Eq Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

(==) :: Encrypt -> Encrypt -> Bool #

(/=) :: Encrypt -> Encrypt -> Bool #

Data Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Encrypt -> c Encrypt #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Encrypt #

toConstr :: Encrypt -> Constr #

dataTypeOf :: Encrypt -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Encrypt) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Encrypt) #

gmapT :: (forall b. Data b => b -> b) -> Encrypt -> Encrypt #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Encrypt -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Encrypt -> r #

gmapQ :: (forall d. Data d => d -> u) -> Encrypt -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Encrypt -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Encrypt -> m Encrypt #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Encrypt -> m Encrypt #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Encrypt -> m Encrypt #

Show Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Generic Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Associated Types

type Rep Encrypt :: Type -> Type #

Methods

from :: Encrypt -> Rep Encrypt x #

to :: Rep Encrypt x -> Encrypt #

Hashable Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

hashWithSalt :: Int -> Encrypt -> Int #

hash :: Encrypt -> Int #

ToJSON Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

AWSRequest Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Associated Types

type Rs Encrypt :: Type #

ToHeaders Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

toHeaders :: Encrypt -> [Header] #

ToPath Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

toPath :: Encrypt -> ByteString #

ToQuery Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

NFData Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

rnf :: Encrypt -> () #

type Rep Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

type Rep Encrypt = D1 (MetaData "Encrypt" "Network.AWS.KMS.Encrypt" "amazonka-kms-1.6.1-1UDljZYfeha1jjHbbMax4v" False) (C1 (MetaCons "Encrypt'" PrefixI True) ((S1 (MetaSel (Just "_eEncryptionContext") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe (Map Text Text))) :*: S1 (MetaSel (Just "_eGrantTokens") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe [Text]))) :*: (S1 (MetaSel (Just "_eKeyId") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text) :*: S1 (MetaSel (Just "_ePlaintext") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Sensitive Base64)))))
type Rs Encrypt Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Request Lenses

eEncryptionContext :: Lens' Encrypt (HashMap Text Text) Source #

Name-value pair that specifies the encryption context to be used for authenticated encryption. If used here, the same value must be supplied to the Decrypt API or decryption will fail. For more information, see Encryption Context .

eGrantTokens :: Lens' Encrypt [Text] Source #

A list of grant tokens. For more information, see Grant Tokens in the AWS Key Management Service Developer Guide .

eKeyId :: Lens' Encrypt Text Source #

A unique identifier for the customer master key (CMK). To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias". To specify a CMK in a different AWS 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:key1234abcd-12ab-34cd-56ef-1234567890ab * Alias name: aliasExampleAlias * Alias ARN: arn:aws:kms:us-east-2:111122223333:aliasExampleAlias@ To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey . To get the alias name and alias ARN, use ListAliases .

ePlaintext :: Lens' Encrypt ByteString Source #

Data to be encrypted.-- 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.

Destructuring the Response

encryptResponse Source #

Creates a value of EncryptResponse with the minimum fields required to make a request.

Use one of the following lenses to modify other fields as desired:

  • ersKeyId - The ID of the key used during encryption.
  • ersCiphertextBlob - The encrypted plaintext. When you use the HTTP API or the AWS CLI, the value is Base64-encoded. Otherwise, it is not 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.
  • ersResponseStatus - -- | The response status code.

data EncryptResponse Source #

See: encryptResponse smart constructor.

Instances
Eq EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Data EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> EncryptResponse -> c EncryptResponse #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c EncryptResponse #

toConstr :: EncryptResponse -> Constr #

dataTypeOf :: EncryptResponse -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c EncryptResponse) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EncryptResponse) #

gmapT :: (forall b. Data b => b -> b) -> EncryptResponse -> EncryptResponse #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EncryptResponse -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EncryptResponse -> r #

gmapQ :: (forall d. Data d => d -> u) -> EncryptResponse -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> EncryptResponse -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> EncryptResponse -> m EncryptResponse #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> EncryptResponse -> m EncryptResponse #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> EncryptResponse -> m EncryptResponse #

Read EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Show EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Generic EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Associated Types

type Rep EncryptResponse :: Type -> Type #

NFData EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

Methods

rnf :: EncryptResponse -> () #

type Rep EncryptResponse Source # 
Instance details

Defined in Network.AWS.KMS.Encrypt

type Rep EncryptResponse = D1 (MetaData "EncryptResponse" "Network.AWS.KMS.Encrypt" "amazonka-kms-1.6.1-1UDljZYfeha1jjHbbMax4v" False) (C1 (MetaCons "EncryptResponse'" PrefixI True) (S1 (MetaSel (Just "_ersKeyId") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Text)) :*: (S1 (MetaSel (Just "_ersCiphertextBlob") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Base64)) :*: S1 (MetaSel (Just "_ersResponseStatus") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))))

Response Lenses

ersKeyId :: Lens' EncryptResponse (Maybe Text) Source #

The ID of the key used during encryption.

ersCiphertextBlob :: Lens' EncryptResponse (Maybe ByteString) Source #

The encrypted plaintext. When you use the HTTP API or the AWS CLI, the value is Base64-encoded. Otherwise, it is not 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.

ersResponseStatus :: Lens' EncryptResponse Int Source #

  • - | The response status code.