Server-side encryption is about protecting data at rest. Server-side encryption encrypts only the object data, not the object metadata. By using server-side encryption with customer-provided keys (SSE-C), you can store your data encrypted with your own encryption keys. With the encryption key that you provide as part of your request, Amazon S3 manages data encryption as it writes to disks and data decryption when you access your objects. Therefore, you don't need to maintain any code to perform data encryption and decryption. The only thing that you need to do is manage the encryption keys that you provide.
When you upload an object, Amazon S3 uses the encryption key that you provide to apply AES-256 encryption to your data. Amazon S3 then removes the encryption key from memory. When you retrieve an object, you must provide the same encryption key as part of your request. Amazon S3 first verifies that the encryption key that you provided matches, and then it decrypts the object before returning the object data to you.
There are no additional charges for using SSE-C. However, requests to configure and use SSE-C
incur standard Amazon S3 request charges. For information about pricing, see Amazon S3 pricing
Note
Amazon S3 does not store the encryption key that you provide. Instead, it stores a randomly salted Hash-based Message Authentication Code (HMAC) value of the encryption key to validate future requests. The salted HMAC value cannot be used to derive the value of the encryption key or to decrypt the contents of the encrypted object. That means if you lose the encryption key, you lose the object.
S3 Replication supports objects that are encrypted with SSE-C. For more information about replicating encrypted objects, see Replicating encrypted objects (SSE-S3, SSE-KMS, DSSE-KMS, SSE-C).
For more information about SSE-C, see the following topics.
Topics
SSE-C overview
This section provides an overview of SSE-C. When using SSE-C, keep the following considerations in mind.
-
You must use HTTPS.
Important
Amazon S3 rejects any requests made over HTTP when using SSE-C. For security considerations, we recommend that you consider any key that you erroneously send over HTTP to be compromised. Discard the key and rotate as appropriate.
-
The entity tag (ETag) in the response is not the MD5 hash of the object data.
-
You manage a mapping of which encryption key was used to encrypt which object. Amazon S3 does not store encryption keys. You are responsible for tracking which encryption key you provided for which object.
-
If your bucket is versioning-enabled, each object version that you upload by using this feature can have its own encryption key. You are responsible for tracking which encryption key was used for which object version.
-
Because you manage encryption keys on the client side, you manage any additional safeguards, such as key rotation, on the client side.
Warning
If you lose the encryption key, any
GET
request for an object without its encryption key fails, and you lose the object. -
Requiring and restricting SSE-C
To require SSE-C for all objects in a particular Amazon S3 bucket, you can use a bucket policy.
For example, the following bucket policy denies upload object
(s3:PutObject
) permissions for all requests that don't include the
x-amz-server-side-encryption-customer-algorithm
header requesting
SSE-C.
{
"Version": "2012-10-17",
"Id": "PutObjectPolicy",
"Statement": [
{
"Sid": "RequireSSECObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/*",
"Condition": {
"Null": {
"s3:x-amz-server-side-encryption-customer-algorithm": "true"
}
}
}
]
}
You can also use a policy to restrict server-side encryption of all objects in a particular
Amazon S3 bucket. For example, the following bucket policy denies the upload object
(s3:PutObject
) permission to everyone if the request includes the
x-amz-server-side-encryption-customer-algorithm
header requesting
SSE-C.
{
"Version": "2012-10-17",
"Id": "PutObjectPolicy",
"Statement": [
{
"Sid": "RestrictSSECObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket
/*",
"Condition": {
"Null": {
"s3:x-amz-server-side-encryption-customer-algorithm": "false"
}
}
}
]
}
Important
If you use a bucket policy to require SSE-C on s3:PutObject
, you
must include the x-amz-server-side-encryption-customer-algorithm
header
in all multipart upload requests (CreateMultipartUpload, UploadPart, and
CompleteMultipartUpload).
Presigned URLs and SSE-C
You can generate a presigned URL that can be used for operations such as uploading a new object, retrieving an existing object, or retrieving object metadata. Presigned URLs support SSE-C as follows:
-
When creating a presigned URL, you must specify the algorithm by using the
x-amz-server-side-encryption-customer-algorithm
header in the signature calculation. -
When using the presigned URL to upload a new object, retrieve an existing object, or retrieve only object metadata, you must provide all the encryption headers in your client application's request.
Note
For non-SSE-C objects, you can generate a presigned URL and directly paste that URL into a browser to access the data.
However, you cannot do this for SSE-C objects, because in addition to the presigned URL, you also must include HTTP headers that are specific to SSE-C objects. Therefore, you can use presigned URLs for SSE-C objects only programmatically.
For more information about presigned URLs, see Download and upload objects with presigned URLs.
Specifying server-side encryption with
customer-provided keys (SSE-C)
At the time of object creation with the REST API, you can specify server-side encryption with customer-provided keys (SSE-C). When you use SSE-C, you must provide encryption key information using the following request headers.
Name | Description |
---|---|
x-amz-server-side-encryption-customer-algorithm
|
Use this header to specify the encryption algorithm. The header value must be
|
x-amz-server-side-encryption-customer-key
|
Use this header to provide the 256-bit, base64-encoded encryption key for Amazon S3 to use to encrypt or decrypt your data. |
x-amz-server-side-encryption-customer-key-MD5
|
Use this header to provide the base64-encoded 128-bit MD5
digest of the encryption key according to RFC 1321 |
You can use AWS SDK wrapper libraries to add these headers to your request. If you need to, you can make the Amazon S3 REST API calls directly in your application.
Note
You cannot use the Amazon S3 console to upload an object and request SSE-C. You also cannot use the console to update (for example, change the storage class or add metadata) an existing object stored using SSE-C.
Amazon S3 rest APIs that support SSE-C
The following Amazon S3 APIs support server-side encryption with customer-provided encryption keys (SSE-C).
-
GET operation – When retrieving objects using the GET API (see GET Object), you can specify the request headers.
-
HEAD operation – To retrieve object metadata using the HEAD API (see HEAD Object), you can specify these request headers.
-
PUT operation – When uploading data using the PUT Object API (see PUT Object), you can specify these request headers.
-
Multipart Upload – When uploading large objects using the multipart upload API, you can specify these headers. You specify these headers in the initiate request (see Initiate Multipart Upload) and each subsequent part upload request (see Upload Part or Upload Part - Copy). For each part upload request, the encryption information must be the same as what you provided in the initiate multipart upload request.
-
POST operation – When using a POST operation to upload an object (see POST Object), instead of the request headers, you provide the same information in the form fields.
-
Copy operation – When you copy an object (see PUT Object - Copy), you have both a source object and a target object:
-
If you want the target object encrypted using server-side encryption with AWS managed keys, you must provide the
x-amz-server-side-encryption
request header. -
If you want the target object encrypted using SSE-C, you must provide encryption information using the three headers described in the preceding table.
-
If the source object is encrypted using SSE-C, you must provide encryption key information using the following headers so that Amazon S3 can decrypt the object for copying.
Name Description x-amz-copy-source-server-side-encryption-customer-algorithm
Include this header to specify the algorithm Amazon S3 should use to decrypt the source object. This value must be
AES256
.x-amz-copy-source-server-side-encryption-customer-key
Include this header to provide the base64-encoded encryption key for Amazon S3 to use to decrypt the source object. This encryption key must be the one that you provided Amazon S3 when you created the source object. Otherwise, Amazon S3 cannot decrypt the object.
x-amz-copy-source-server-side-encryption-customer-key-MD5
Include this header to provide the base64-encoded 128-bit MD5 digest of the encryption key according to RFC 1321
.
-
The following examples show how to request server-side encryption with customer-provided keys (SSE-C) for objects. The examples perform the following operations. Each operation shows how to specify SSE-C-related headers in the request:
-
Put object – Uploads an object and requests server-side encryption using a customer-provided encryption key.
-
Get object – Downloads the object uploaded in the previous step. In the request, you provide the same encryption information you provided when you uploaded the object. Amazon S3 needs this information to decrypt the object so that it can return it to you.
-
Get object metadata – Retrieves the object's metadata. You provide the same encryption information used when the object was created.
-
Copy object – Makes a copy of the previously-uploaded object. Because the source object is stored using SSE-C, you must provide its encryption information in your copy request. By default, Amazon S3 encrypts the copy of the object only if you explicitly request it. This example directs Amazon S3 to store an encrypted copy of the object.
The example in the preceding section shows how to request server-side encryption with customer-provided key (SSE-C) in the PUT, GET, Head, and Copy operations. This section describes other Amazon S3 APIs that support SSE-C.