[vault] Licences: the domi-licence key, the strict payload parser, the licence grant (0.21.0)
The key that signs Domi licences and revocation lists (Fundamentum docs/LICENCE.md, licence v1): Ed25519 under the reserved id domi-licence, no scope, refused by every other signing path, signing plain Ed25519 over the exact payload. The payload is parsed first, as the spec's strict parser does (section 2.4 steps 1-4 and 7, section 4.1), and a malformed one is refused with the spec's code and no card. The licence grant (Mark's click) signs a licence from licence-issue whose apps are on the allowlist, within 50 a day, without a card; anything else that is well formed asks on a card, a revocation list always. Refused outright: a licence dated more than a day from this clock, a licence id signed before (replay), a seq not above the highest signed (rollback), any other caller. The grant and the log live in signing.licence, which older cores ignore; the key is an ordinary Ed25519 entry every core reads. Not compiled or tested yet: the PC is over Mark's 90 % rule.
This commit is contained in:
@@ -302,6 +302,77 @@ Never covered by the grant: another kind, the server runner, a pipeline other th
|
||||
matches, a key that is not the repository's app key, a request without a run, anything while *Sign only with a card*
|
||||
is ticked.
|
||||
|
||||
## Domi licences (core 0.21.0)
|
||||
|
||||
A Domi licence is a small text file the Atrium Domi service checks before it unlocks a paid app. Its byte format,
|
||||
the paste code, the revocation list and the service's own checks are Fundamentum's `docs/LICENCE.md` (licence v1);
|
||||
this core is the one that **signs**, and it parses what it signs exactly as that spec's strict parser does. The code
|
||||
is `crates/custos-vault/src/licence.rs`.
|
||||
|
||||
### The key
|
||||
|
||||
- One key per vault, **`domi-licence`**: Ed25519, made in the vault by Mark's click (`licence_key_create`), never
|
||||
exported. Only its 32-byte public key leaves (`licence_public`); the service ships it.
|
||||
- It is stored as an ordinary Ed25519 entry (release, **no scope**, no minisign key id), so every core reads the vault
|
||||
as before. An empty scope is never in scope, so no older core can sign with it either.
|
||||
- It signs **only** the two payload kinds below, as a plain Ed25519 signature over the exact payload bytes (no
|
||||
prehash, no digest; `custos_sign::ed25519_plain`). `signing_check` refuses it for every other kind, its scope
|
||||
cannot be set, no Android key can take its id, and no other key signs these payloads.
|
||||
|
||||
### What it signs
|
||||
|
||||
| Payload | Starts with | Cap (bytes) | Parser |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| a licence | `domi-licence-v1
|
||||
` | 4004 | LICENCE.md §2.4 steps 1–4 and 7 |
|
||||
| a revocation list | `domi-revocations-v1
|
||||
` | 61 348 | LICENCE.md §4.1 |
|
||||
|
||||
The caps are the spec's file caps (4096 and 61 440) less the `sig:` line (92 bytes), so every file signed here also
|
||||
passes the service's size check. A malformed payload is refused with the spec's error code (§8: `too_large`,
|
||||
`crlf`, `bad_byte`, `bad_prefix`, `truncated`, `bad_line`, `unknown_field`, `duplicate_field`, `field_order`,
|
||||
`missing_field`, `bad_id`, `bad_issued`, `bad_nickname`, `bad_bundle`, `bad_scope`, `bad_seats`,
|
||||
`seats_with_household`, `seats_missing`, `bad_apps`, `apps_unsorted`, `apps_duplicate`, `too_many_apps`,
|
||||
`bad_seq`, `revoked_unsorted`, `revoked_duplicate`) and **never reaches a card**. A payload never contains a `sig:`
|
||||
line: one is an `unknown_field`.
|
||||
|
||||
### The licence grant
|
||||
|
||||
One grant per vault, in `signing.licence.grant`, given by Mark's click (`licence_grant_set`, `standing-granted`) and
|
||||
removed the same way (`licence_grant_revoke`, `standing-revoked`):
|
||||
|
||||
```json
|
||||
"licence": { "grant": { "allow": ["calenda", "fiscus", "medicus", "tabula"], "granted": 1795896907000,
|
||||
"lastUsed": 1795896990000, "uses": 4 },
|
||||
"log": [ { "at": 1795896990000, "by": "grant", "licence": "k3Jx0Qm1T9yZpW2bA7cD4e",
|
||||
"apps": ["calenda", "tabula"] },
|
||||
{ "at": 1795897000000, "by": "card", "seq": 7, "revoked": 3 } ] }
|
||||
```
|
||||
|
||||
`licence_ask(payload, caller, now)` decides, and changes nothing:
|
||||
|
||||
| | Result |
|
||||
| :-- | :-- |
|
||||
| malformed | refused, the spec's code |
|
||||
| no `domi-licence` key | refused, `no_key` |
|
||||
| a caller whose Canalis app id is not `licence-issue` | refused, `not_allowed` |
|
||||
| the log holds 20 000 signatures | refused, `log_full` (it never forgets what replay and rollback need) |
|
||||
| a licence whose `issued` is more than 24 h from this clock, either way | refused, `clock` |
|
||||
| a licence id this key signed before | refused, `replay` |
|
||||
| a revocation list whose `seq` is not higher than every `seq` this key signed | refused, `rollback` |
|
||||
| a revocation list | **a card, always** |
|
||||
| a licence, and any of: no grant; a caller program not signed with Domi's certificate; *Sign only with a card* ticked; an app not on `allow`; 50 licences signed in the last 24 h | a card, with each reason |
|
||||
| a licence and none of those | signed by the grant, no card |
|
||||
|
||||
`licence_sign(payload, caller, by, now)` checks again, refuses `needs_card` when `by` is `grant` and the grant does
|
||||
not cover it, signs, returns the signature in base64url without padding (86 characters), logs it (when, how, the
|
||||
licence id and its apps, or the list's `seq` and how many ids it revokes: never the signature, the payload or the
|
||||
nickname) and counts the grant's use.
|
||||
|
||||
Cores before 0.21.0 ignore `signing.licence` and drop it if they save the vault: the grant is then gone, so every
|
||||
licence asks again, and the key stays. Replay and rollback are then only as good as what is left; the service keeps
|
||||
its own anti-rollback check (LICENCE.md §4.2), which a restored or rewritten vault cannot get past.
|
||||
|
||||
## The audit log
|
||||
|
||||
`audit` is append-only: there is no function that edits or removes an entry. Every request a key is named in gets
|
||||
@@ -361,6 +432,13 @@ Vault::android_grant_set(repos, o, c, now) -> Result<AndroidGrant,
|
||||
Vault::android_grant_revoke(now) -> bool
|
||||
Vault::android_grant_fits(req, now) -> bool
|
||||
Vault::android_grant_make_key(repo, pipeline, via, now) -> Result<String, Error>
|
||||
licence::parse_payload(bytes) -> Payload | LicenceRefusal (core 0.21.0)
|
||||
Vault::licence_key_create(now) -> [u8; 32] // the public key, never the secret
|
||||
Vault::licence_public() -> Option<[u8; 32]>
|
||||
Vault::licence_grant() / licence_grant_set(allow, now) / licence_grant_revoke(now)
|
||||
Vault::licence_ask(payload, Caller { app, domi_signed }, now) -> LicenceAsk { payload, card: [CardReason] }
|
||||
Vault::licence_sign(payload, caller, LicenceBy::{Grant, Card}, now) -> base64url signature
|
||||
Vault::licence_log() -> [LicenceEntry]
|
||||
```
|
||||
|
||||
No function returns a `secret`. The views and the audit entries print and serialise without one; there is a test.
|
||||
|
||||
Reference in New Issue
Block a user