The newest version of theÂ AWS SDK for Java has a very convenient client-side encryption feature. Once enabled, the SDK will automatically encrypt data before sending it toÂ Amazon S3, and decrypt it before returning it to your application. You have full control of the keys used to encrypt and decrypt your data and the keys are never transmitted over the wire.
This feature is implemented using a technique known as envelope encryption. Here’s a diagram that should help to illustrate the concept:
Your calls to the AWS SDK for Java include a Master Key. This key is used to encrypt an envelope key that is generated within the SDK.Â The envelope key is used to encrypt the master key and the data before it leaves the client. The encrypted envelope key is stored alongside the encrypted data along with a description of the master key.
On retrieval, the encrypted envelope key is compared to the description of the master key. If they do not match, the client application is asked to supply the original master key. You can use this feature to integrate your application with an existing private key management system.
This functionality is implemented within theÂ AmazonS3EncryptionClient class. This class is a subclass of the originalÂ AmazonS3Client with additional parameters and methods to control the encryption and decryption process.
The SDK provides a number of configurable options, including the ability to use either asymmetric or symmetric encryption. You can also choose to store the encrypted envelope key as S3 object metadata or as a separate S3 object.
This feature is available now and you can start using it today. We’ve created a new article,Â AWS SDK for Java and Amazon S3 Encryption, with complete information, including code.