Encrypt Data at Rest
This document explains how to encrypt data at rest in ScalarDB.
Overview​
ScalarDB can encrypt data stored through it. The encryption feature is similar to transparent data encryption (TDE) in major database systems; therefore, it is transparent to applications. ScalarDB encrypts data before writing it to the backend databases and decrypts it when reading from them.
Currently, ScalarDB supports column-level encryption, allowing specific columns in a table to be encrypted.
Configurations​
To enable the encryption feature, you need to configure scalar.db.cluster.encryption.enabled to true in the ScalarDB Cluster node configuration file.
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.enabled | Whether ScalarDB encrypts data at rest. | false |
Since encryption is transparent to the client, you don't need to change the client configuration.
If you enable the encryption feature, you will also need to set scalar.db.cross_partition_scan.enabled to true for the system namespace (scalardb by default) because it performs cross-partition scans internally.
The other configurations depend on the encryption implementation you choose. Currently, ScalarDB supports the following encryption implementations:
- HashiCorp Vault encryption
- Self-encryption
The following sections explain how to configure each encryption implementation.
HashiCorp Vault encryption​
In HashiCorp Vault encryption, ScalarDB uses the encryption as a service of HashiCorp Vault to encrypt and decrypt data. In this implementation, ScalarDB delegates the management of encryption keys, as well as the encryption and decryption of data, to HashiCorp Vault.
To use HashiCorp Vault encryption, you need to set the property scalar.db.cluster.encryption.type to vault in the ScalarDB Cluster node configuration file:
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.type | Should be set to vault to use HashiCorp Vault encryption. |
You also need to configure the following properties:
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.vault.key_type | The key type. Currently, aes128-gcm96, aes256-gcm96, and chacha20-poly1305 are supported. For details about the key types, see Key types. | aes128-gcm96 |
scalar.db.cluster.encryption.vault.associated_data_required | Whether associated data is required for AEAD encryption. | false |
scalar.db.cluster.encryption.vault.address | The address of the HashiCorp Vault server. | |
scalar.db.cluster.encryption.vault.token | The token to authenticate with HashiCorp Vault. | |
scalar.db.cluster.encryption.vault.namespace | The namespace of the HashiCorp Vault. This configuration is optional. | |
scalar.db.cluster.encryption.vault.transit_secrets_engine_path | The path of the transit secrets engine. | transit |
scalar.db.cluster.encryption.vault.column_batch_size | The number of columns to be included in a single request to the HashiCorp Vault server. | 64 |
Currently, ScalarDB supports only the token auth method. There are plans to implement additional, more secure auth methods, such as AppRole, OIDC, and Kubernetes auth, in the future.
Self-encryption​
In self-encryption, ScalarDB manages data encryption keys (DEKs) and performs encryption and decryption. ScalarDB generates a DEK for each table when creating the table and stores it in Kubernetes Secrets.
To use self-encryption, you need to set the property scalar.db.cluster.encryption.type to self in the ScalarDB Cluster node configuration file:
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.type | Should be set to self to use self-encryption. |
You also need to configure the following properties:
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.self.key_type | The key type. Currently, AES128_GCM, AES256_GCM, AES128_EAX, AES256_EAX, AES128_CTR_HMAC_SHA256, AES256_CTR_HMAC_SHA256, CHACHA20_POLY1305, and XCHACHA20_POLY1305 are supported. For details about the key types, see Choose a key type. | AES128_GCM |
scalar.db.cluster.encryption.self.associated_data_required | Whether associated data is required for AEAD encryption. | false |
scalar.db.cluster.encryption.self.kubernetes.secret.namespace_name | The namespace name of the Kubernetes Secrets. | default |
scalar.db.cluster.encryption.self.data_encryption_key_cache_expiration_time | The expiration time of the DEK cache in milliseconds. | 60000 (60 seconds) |
Delete the DEK when dropping a table​
By default, ScalarDB does not delete the data encryption key (DEK) associated with a table when the table is dropped. However, you can configure ScalarDB to delete the DEK when dropping a table. To enable this, set the property scalar.db.cluster.encryption.delete_data_encryption_key_on_drop_table.enabled to true in the ScalarDB Cluster node configuration file:
| Name | Description | Default |
|---|---|---|
scalar.db.cluster.encryption.delete_data_encryption_key_on_drop_table.enabled | Whether to delete the DEK when dropping a table. | false |
Limitations​
There are some limitations to the encryption feature:
- Primary-key columns (partition-key columns and clustering-key columns) cannot be encrypted.
- Secondary-index columns cannot be encrypted.
- Encrypted columns cannot be specified in the WHERE clauses or ORDER BY clauses.
- Encrypted columns are stored in the underlying database as the BLOB type, so encrypted columns that are larger than the maximum size of the BLOB type cannot be stored. To see if the database you're using has a maximum size for the BLOB type, see Database Adapters.
Wire encryption​
If you enable the encryption feature, enabling wire encryption to protect your data is strongly recommended, especially in production environments. For details about wire encryption, see Encrypt Wire Communications.
Tutorial - Encrypt data by configuring HashiCorp Vault encryption​
This tutorial explains how to encrypt data stored through ScalarDB by using HashiCorp Vault encryption.
Prerequisites​
- One of the following Java Development Kits (JDKs):
- Oracle JDK: 8, 11, 17, or 21 (LTS versions)
- OpenJDK distribution (Eclipse Temurin, Amazon Corretto, or Microsoft Build of OpenJDK): 8, 11, 17, or 21 (LTS versions)
- Docker 20.10 or later with Docker Compose V2 or later
You need to have a license key (trial license or commercial license) to use ScalarDB Cluster. If you don't have a license key, please contact us.