Keyring file
keys is the keyring file. It sits at the root of the store with mode 0600 and holds the data keys. It is sealed directly by the master key from the key hierarchy, with its own layout rather than the seal trailer.
Layout
Section titled “Layout”| Offset | Size | Type | Meaning |
|---|---|---|---|
| 0 | 4 | ascii | magic "STKR" |
| 4 | 2 | u16 LE | version, 1 |
| 6 | 12 | bytes | nonce, random, fresh on every rewrite |
| 18 | n + 16 | bytes | AES-256-GCM(master key, nonce, AAD = "strata-keyring-v1") of the body, tag appended |
A version above 1 is NewerFormat("keyring"). A version below 1 is Corrupt. See Error classes.
The plaintext body is all u32 LE.
| Field | Encoding | Meaning |
|---|---|---|
epoch |
u32 LE | nonce epoch last handed out |
next_id |
u32 LE | next data-key id |
current |
u32 LE | id of the data key used for new seals; must be present below |
count |
u32 LE | number of keys |
| keys | count times (id u32 ‖ 32-byte key) |
data keys, written in ascending id order |
A keyring with one key is 18 + 16 + 36 + 16 = 86 bytes. A worked example of the 86-byte file is The keyring.
Rewrite
Section titled “Rewrite”The file is written to keys.tmp (mode 0600), fsynced, renamed over keys, and the directory is fsynced. The nonce is fresh on every rewrite. A wrong master key fails authentication (BadMasterKey).
The epoch field is the persisted counter described in Nonces and epochs.