A developer is implementing a secure file upload utility in a Python application using the AWS SDK (Boto3). The utility must encrypt sensitive medical imaging files, each approximately in size, client-side before uploading them to an Amazon S3 bucket. The application must use envelope encryption with a customer managed key (CMK) in AWS KMS to manage the encryption keys. Which programmatic workflow should the developer implement to encrypt each file while minimizing AWS KMS API calls and network overhead?
- Call the generate_data_key API method passing the CMK identifier and specifying the AES_256 key spec. Use the returned plaintext data key to encrypt the file locally. Upload the encrypted file and the returned ciphertext data key to Amazon S3, then purge the plaintext data key from memory.Cevap
- BCall the generate_data_key_without_plaintext API method passing the CMK identifier. Call the decrypt API method passing the returned ciphertext data key to retrieve the plaintext data key. Use the plaintext data key to encrypt the file locally, then upload the encrypted file and the ciphertext data key to Amazon S3.
- CCall the encrypt API method passing the CMK identifier and the file contents in chunks. Concatenate the returned ciphertexts and upload the final consolidated file to Amazon S3.
- DCall the generate_data_key API method to retrieve a plaintext data key and a ciphertext data key. Call the encrypt API method passing the plaintext data key to encrypt it again with the CMK. Use the newly encrypted data key to encrypt the file, and upload the file to Amazon S3.
Cevap
Call the generate_data_key API method passing the CMK identifier and specifying the AES_256 key spec. Use the returned plaintext data key to encrypt the file locally. Upload the encrypted file and the returned ciphertext data key to Amazon S3, then purge the plaintext data key from memory.
The correct workflow is to call the generate_data_key API method, which returns both the plaintext data key (to immediately encrypt the file locally) and the ciphertext data key (to be uploaded to S3 along with the encrypted file). This ensures the envelope encryption is completed in a single KMS API call and local resources do not retain the plaintext key in memory after encryption.
Adım Adım Çözüm
Anahtar Kavram
AWS KMS client-side envelope encryption workflow utilizing generate_data_key.