Updated on 2024-10-24 GMT+08:00

Server-Side Encryption

You can use server-side encryption to encrypt data uploaded to OBS to improve storage security and compliance. With server-side encryption, the OBS server encrypts the objects uploaded from the client before storing them. When the objects are accessed, the OBS server decrypts the objects and then returns them to the client.

OBS supports three encryption methods: server-side encryption with KMS-managed keys (SSE-KMS), server-side encryption with OBS-managed keys (SSE-OBS), and server-side encryption with customer-provided keys (SSE-C).

Table 1 Three server-side encryption methods

Comparison Dimension

SSE-KMS

SSE-OBS

SSE-C

Scenarios

Scenarios that require high compliance and security. Keys are generated by third-party validated HSMs. Access to keys is controlled and all operations involving keys are traceable by logs.

Scenarios that require basic encryption and batch processing. OBS does not need to interact with KMS. SSE-OBS features lower access latency and better performance than SSE-KMS

Scenarios that users need to store and manage keys by themself

Key management

KMS generates and keeps keys, and OBS uses the keys to encrypt objects.

OBS generates and keeps keys, and uses the keys to encrypt objects.

A user generates and keeps keys, and OBS uses the keys to encrypt objects.

Encryption algorithm

AES-256 and SM4

AES-256

AES-256

Encryption scope

Bucket level and object level

Bucket level and object level

Object level

Details

SSE-KMS

SSE-OBS

SSE-C

  • You can refer to the regions that support SSE-KMS on the console If you want to use the SM4 encryption algorithm when enabling SSE-KMS, choose the CN North-Ulanqab1 region.
  • SSE-OBS is available on the entire Huawei Cloud Chinese Mainland website.
  • SSE-C is available in the regions where the SSE-C API is supported.

Bucket-level and Object-level Server-Side Encryption

The following table compares bucket-level and object-level server-side encryption.

Table 2 Comparison between bucket-level and object-level server-side encryption

Item

Bucket-level Encryption

Object-level Encryption

Scenarios

You need to encrypt all objects when they are uploaded to a bucket.

You need to encrypt only some objects or select an encryption method and key each time you upload an object.

Encryption methods

SSE-KMS and SSE-OBS

SSE-KMS, SSE-OBS, and SSE-C

Configuration

You can change your encryption configuration at any time.

You can configure encryption during object upload and the configuration cannot be changed after the upload.

Impacts

  • If encryption is not enabled for a bucket, you can separately configure encryption when uploading objects to the bucket.
  • If encryption is enabled for a bucket, OBS only encrypts the objects uploaded after encryption is enabled, and does not encrypt those uploaded before. When you upload objects to this bucket, they will inherit the bucket's encryption by default, but you can change the configuration if needed.
  • If you change the encryption configuration for a bucket, only the objects uploaded after the change will inherit the new configuration. Objects uploaded before the change will retain the original configuration.
  • Disabling encryption for a bucket does not change the encryption status of existing objects in the bucket. However, objects uploaded later will not be forcibly encrypted. If necessary, you can manually encrypt subsequent objects when you upload them to the bucket.

Constraints

  • Only one encryption method can be used each time an object is uploaded. The encryption configuration of an uploaded object cannot be changed.
  • To use SSE-KMS to encrypt a bucket or the objects in it, you must have kms:cmk:get, kms:cmk:list, kms:cmk:create, kms:dek:create, and kms:dek:crypto permissions granted by using IAM, so that you can upload objects to or download objects from this bucket.
  • If server-side encryption is disabled for a bucket, the encrypted objects can only be accessed over HTTPS.
  • A key in use cannot be deleted, or the object encrypted with this key cannot be downloaded.

SSE-KMS

Figure 1 SSE-KMS encryption process

During the encryption in Figure 1, SSE-KMS supports envelope encryption. Customer master keys hosted by KMS are not directly used to encrypt data. Instead, data keys derived from them are used to encrypt data in OBS. OBS stores the encrypted objects and data keys.

Figure 2 SSE-KMS decryption process

During the decryption in Figure 2, KMS decrypts the data keys, uses them to decrypt the objects, and returns the objects to users.

KMS uses Hardware Secure Modules (HSMs) to ensure key security, enabling users to easily create and manage encryption keys. Keys are not displayed in plaintext outside HSMs, which prevents key disclosure. All operations performed on keys are controlled and logged, and usage of all keys is recorded, meeting regulatory compliance requirements.

Table 3 APIs that support SSE-KMS encryption

Resource

API

Header

Bucket

Creating a Bucket

  • x-obs-server-side-encryption: Encryption method of a bucket
  • x-obs-server-side-data-encryption: Encryption algorithm for server-side encryption
  • x-obs-server-side-encryption-kms-key-id: KMS master key. If this header is not provided, the default master key will be used.
  • x-obs-sse-kms-key-project-id: ID of the project that the KMS master key belongs to

Configuring Bucket Encryption

The encryption configuration is in the body. For details, see Configuring Bucket Encryption.

Object

Uploading Objects - PUT

  • x-obs-server-side-data-encryption: Encryption algorithm for server-side encryption
  • x-obs-server-side-encryption-kms-key-id: KMS master key. If this header is not provided, the default master key will be used.
  • x-obs-sse-kms-key-project-id: ID of the project that the KMS master key belongs to

Uploading Objects - POST

Initiating a Multipart Upload

Copying Objects

You can configure a bucket policy to limit the server-side encryption for a specific bucket to a specified method. For example, if you want people to use PUT to upload objects to bucket ExampleBucket and encrypt them with SSE-KMS, you can use the following bucket policy to deny any upload requests that do not contain the x-obs-server-side-encryption:"kms" header:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
    "Statement": [
        {
            "Sid": "DenyUnEncryptedObjectUploads",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "PutObject",
            "Resource": "ExampleBucket/*",
            "Condition": {
                "StringNotEquals": {
                    "x-obs-server-side-encryption": "kms"
                }
            }
        }
    ]
}

SSE-OBS

SSE-OBS uses a data key derived from the OBS root key to encrypt and decrypt data. APIs related to SSE-OBS encryption

Table 4 APIs related to SSE-OBS encryption

Resource

API

Header

Bucket

Creating a Bucket

x-obs-server-side-encryption: Encryption method of a bucket

Configuring Bucket Encryption

The encryption configuration is in the body. For details, see Configuring Bucket Encryption.

Object

Uploading Objects - PUT

x-obs-server-side-encryption: Encryption method of a bucket

Uploading Objects - POST

Initiating a Multipart Upload

Copying Objects

You can configure a bucket policy to restrict the request headers for a specified bucket. For example, if you require that object upload requests do not contain header x-obs-server-side-encryption:"AES256", you can use the following bucket policy:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{ 
    "Statement": [ 
        { 
            "Sid": "DenyUnEncryptedObjectUploads", 
            "Effect": "Deny", 
            "Principal": "*", 
            "Action": "PutObject", 
            "Resource": "YourBucket/*", 
            "Condition": { 
                "StringNotEquals": { 
                    "x-obs-server-side-encryption": "AES256" 
                } 
            } 
        } 
    ] 
}

SSE-C

With SSE-C, OBS uses the keys and MD5 values provided by customers for server-side encryption.

Table 5 APIs that support SSE-C encryption

Resource

API

Header

Object level

Uploading Objects - PUT

  • x-obs-server-side-encryption-customer-algorithm: Algorithm used to encrypt an object
  • x-obs-server-side-encryption-customer-key: Key used to encrypt an object. The header value is a 256-bit, base64-encoded key.
  • x-obs-server-side-encryption-customer-key-MD5: MD5 value of the key used for encrypting an object

Uploading Objects - POST

Initiating a Multipart Upload

Multipart Upload

Querying Object Metadata

Downloading Objects

Uploading a Part of an Object - Copy

  • If the source part or object is not encrypted but you want to encrypt their copy, use the following three headers:
  • x-obs-server-side-encryption-customer-algorithm: Algorithm used to encrypt an object
  • x-obs-server-side-encryption-customer-key: Key used to encrypt an object. The header value is a 256-bit, base64-encoded key.
  • x-obs-server-side-encryption-customer-key-MD5: MD5 value of the key used for encrypting an object

If the source part or object has been encrypted and their copy also requires encryption, use the following headers to decrypt the source:

  • x-obs-copy-source-server-side-encryption-customer-algorithm: Algorithm used to decrypt the source object
  • x-obs-copy-source-server-side-encryption-customer-key: Key used to decrypt the source object. The header value is a 256-bit, base64-encoded key.
  • x-obs-copy-source-server-side-encryption-customer-key-MD5: MD5 value of the key used for decrypting the source object

Copying Objects

Enabling and Configuring Server-Side Encryption for a Bucket

You can use OBS Console, APIs, or SDKs to configure Server-Side Encryption for a bucket.

Configuring Object-Level Server-Side Encryption

You can use OBS Console, APIs, or SDKs to encrypt objects to be uploaded.