Skip to main content

Module envelope

Module envelope 

Source
Expand description

Keys and the encryption that protects every stored body.

Structs§

ColumnContext
Where a sealed value belongs. The tenant is REGISTRY for a registry column, the table and column are the SQL names, and the row key is what identifies the row within its tenant (such as a version id, or a uuid’s MAC).
ColumnKeys
The two keys derived from a catalog key at open, held in locked pages and never stored.
Key
A 256-bit key. Its bytes live only in a page of their own that is locked in memory, so they never reach swap, and that core dumps leave out; they are zeroed when the key is dropped. A key cannot be copied, and Debug shows only its id.
OpenError
A sealed body or wrapped key did not open. It carries no detail, so a caller cannot tell which part was wrong.

Enums§

Context
What a sealed or wrapped value belongs to. It is bound into the encryption, so a value moved to another tenant, uuid or version does not open.
KeyError
Why a key could not be made.
WrapLimit
Whether a key that has already wrapped wraps keys may wrap another.

Constants§

REGISTRY
The tenant field of a registry column: the registry belongs to no tenant, and no tenant id is all zeros (ids are random, 128 bits).
SEALED_COLUMN_OVERHEAD
How many bytes a sealed column value holds beyond its plaintext: the format byte, the nonce and the tag.

Functions§

catalog_key
The key of the catalog that parent protects: the master key’s for server.sqlite, a tenant key’s for that tenant’s catalog. It is HKDF-SHA256 of the parent with no salt and the info vcon-server/v1 catalog, made in a locked page of its own and never stored.
disable_core_dumps
Stops this process from writing core dumps: the core size limit is set to zero and the process is marked not dumpable, which also stops other processes of the same user from reading its memory. Neither is enough on its own: the limit is not enforced when core dumps are piped to a program, and a host with suid_dumpable set to 2 still dumps processes that are not dumpable. Each key’s page is left out of core dumps as well.
lock_all_memory
Locks every page of this process in memory, now and as it grows, so nothing it holds can reach swap: not AWS-LC’s expanded keys, which live in its own allocations for the length of one call, and not plaintext bodies. It fails if the lock limit is too low; the operator then raises it (for example LimitMEMLOCK=infinity under systemd).
mac
HMAC-SHA256 of value’s fixed bytes under the index key: equal values give equal MACs, which SQL needs to find them, and which is all a MAC shows.
open
Decrypts a blob made by seal with the same key and context. Any change to the blob, the context or the key is an error, never partial plaintext.
open_column
Opens a value seal_column made for the same keys and context; any change to the blob, the keys or the context is an error, never partial plaintext.
rewrap
Moves a wrapped key from old to new, keeping its context: the rotation step. The plain key exists only in its own locked page in between, and what it protects is never re-encrypted.
seal
Encrypts plaintext under data_key, bound to ctx, with a random nonce. The blob is the format byte, the nonce, the ciphertext and the tag.
seal_column
Seals plaintext for the place ctx names, with a random nonce. The blob is the format byte, the nonce, the ciphertext and the tag.
unwrap
Unwraps a key made by wrap with the same wrapping key and context. It is opened straight into the new key’s own locked page, so the plain key is never anywhere else; on any error that page is dropped, and so zeroed.
unwrap_key
Opens a key wrap_key made for the same keys and context. It is opened straight into the new key’s own locked page, so the plain key is never anywhere else; on any error that page is dropped, and so zeroed.
wrap
Wraps key under wrapping, bound to ctx: a blob like seal’s, whose plaintext is the key.
wrap_key
Seals key as the column value of the place ctx names: a blob like seal_column’s, whose plaintext is the key.
wrap_limit
The wrap-count limit for one wrapping key. Each wrap uses a random nonce, and NIST SP 800-38D 8.3 allows at most 2^32 such encryptions under one key, so a key that has made 2^32 wraps makes no more. The warning starts at half that.