Copyright | (c) 2013-2016 Brendan Hay |
---|---|
License | Mozilla Public License, v. 2.0. |
Maintainer | Brendan Hay <brendan.g.hay@gmail.com> |
Stability | auto-generated |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Encrypts plaintext into ciphertext by using a customer master key. The Encrypt
function has two primary use cases:
- You can encrypt up to 4 KB of arbitrary data such as an RSA key, a database password, or other sensitive customer information.
- If you are moving encrypted data from one region to another, you can use this API 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.
Unless you are moving encrypted data from one region to another, you don't use this function to encrypt a generated data key within a region. You retrieve data keys already encrypted by calling the GenerateDataKey
or GenerateDataKeyWithoutPlaintext
function. Data keys don't need to be encrypted again by calling Encrypt
.
If you want to encrypt data locally in your application, you can use the GenerateDataKey
function to return a plaintext data encryption key and a copy of the key encrypted under the customer master key (CMK) of your choosing.
- encrypt :: Text -> ByteString -> Encrypt
- data Encrypt
- eEncryptionContext :: Lens' Encrypt (HashMap Text Text)
- eGrantTokens :: Lens' Encrypt [Text]
- eKeyId :: Lens' Encrypt Text
- ePlaintext :: Lens' Encrypt ByteString
- encryptResponse :: Int -> EncryptResponse
- data EncryptResponse
- ersKeyId :: Lens' EncryptResponse (Maybe Text)
- ersCiphertextBlob :: Lens' EncryptResponse (Maybe ByteString)
- ersResponseStatus :: Lens' EncryptResponse Int
Creating a Request
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 theDecrypt
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. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias". * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key12345678-1234-1234-1234-123456789012 * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:aliasMyAliasName * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012 * Alias Name Example - aliasMyAliasNameePlaintext
- Data to be encrypted.-- Note: ThisLens
automatically encodes and decodes Base64 data. The underlying isomorphism will encode to Base64 representation during serialisation, and decode from Base64 representation during deserialisation. ThisLens
accepts and returns only raw unencoded data.
See: encrypt
smart constructor.
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. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias". * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key12345678-1234-1234-1234-123456789012 * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:aliasMyAliasName * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012 * Alias Name Example - aliasMyAliasName
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
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. If you are using the CLI, the value is Base64 encoded. Otherwise, it is not encoded.-- Note: ThisLens
automatically encodes and decodes Base64 data. The underlying isomorphism will encode to Base64 representation during serialisation, and decode from Base64 representation during deserialisation. ThisLens
accepts and returns only raw unencoded data.ersResponseStatus
- -- | The response status code.
data EncryptResponse Source #
See: encryptResponse
smart constructor.
Response Lenses
ersCiphertextBlob :: Lens' EncryptResponse (Maybe ByteString) Source #
The encrypted plaintext. If you are using the 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.