Skip to content

Commit d66cf0a

Browse files
author
marc
committed
Improve background section
1 parent 20912bd commit d66cf0a

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

v2.1/encryption.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,32 @@ Encryption At Rest provides transparent encryption for node data on local disk.
99

1010
<div id="toc"></div>
1111

12-
## Terminology
12+
## Background
1313

14-
* store key: user-provided key, used to encrypt data keys
15-
* data key: automatically-generated key, used to encrypt data
16-
TODO(mberhault): add more
14+
Encryption at rest allows encryption of all files on disk using AES in counter mode, with all key
15+
sizes allowed.
1716

18-
## Background
17+
Encryption is performed in the [storage layer](architecture/storage-layer.html) and configured per store.
18+
All files used by the store, regarless of contents, are encrypted with the desired algorithm.
19+
20+
To allow arbitrary rotation schedules and ensure security of the keys, we use two layers of keys:
21+
22+
| Level | Description |
23+
|-|-|
24+
| Store keys | Provided by the user in a file. They are used to encrypt the list of data keys (see below).<br><br>This is known as a **key encryption key**: it's only purpose is to encrypt other keys.<br><br>Store keys are never persisted by CockroachDB.<br><br>Since very little data is encrypted using this key, it can have a very long lifetime without risk of reuse. |
25+
| Data keys | Automatically generated by CockroachDB. They are used to encrypt all files on disk.<br><br> This is known as a **data encryption key**.<br><br>Data keys are persisted in a key registry file, encrypted using the store key.<br><br>The key has a short lifetime to avoid key/IV reuse. |
26+
27+
Store keys are specified by passing a path to a locally readable file. The file must contain 32 bytes (the key ID)
28+
followed by the key (16, 24, or 32 bytes). The size of the key dictates the version of AES to use (AES-128, AES-192, or AES-256).
29+
30+
At startup, CockroachDB uses a data key with the same length as the store key. If encryption has just been enabled,
31+
the key size has changed, or the data key is too old (default lifetime is one week), CockroachDB generates a new data key.
32+
33+
Any new file created by the store uses the currently-active data key. All data keys (both active and previous) are stored in a key registry file and encrypted with the active store key.
34+
35+
CockroachDB does not currently force re-encryption of older files but instead relies on normal RocksDB churn to slowly rewrite all files with the desired encryption.
1936

20-
TODO(mberhault): explain store vs data keys, rotation, etc...
37+
TODO(mberhault): flesh out key rotation description.
2138

2239
## Example
2340

0 commit comments

Comments
 (0)