Expand description
Keys and the encryption that protects every stored body.
Structs§
- Column
Context - Where a sealed value belongs. The tenant is
REGISTRYfor 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). - Column
Keys - 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.
- Open
Error - 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.
- Wrap
Limit - Whether a key that has already wrapped
wrapskeys 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
parentprotects: 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 infovcon-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_dumpableset 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
sealwith 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_columnmade 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
oldtonew, 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
plaintextunderdata_key, bound toctx, with a random nonce. The blob is the format byte, the nonce, the ciphertext and the tag. - seal_
column - Seals
plaintextfor the placectxnames, with a random nonce. The blob is the format byte, the nonce, the ciphertext and the tag. - unwrap
- Unwraps a key made by
wrapwith 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_keymade 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
keyunderwrapping, bound toctx: a blob likeseal’s, whose plaintext is the key. - wrap_
key - Seals
keyas the column value of the placectxnames: a blob likeseal_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.