# The Dromas Protocol, version 1

**Status: draft.** Nothing here is final until version 1 is declared stable. The open issues of this repository and of dromas-server must be settled first.

## 1. Introduction

Dromas carries end-to-end encrypted, sender-authenticated messages between programs, through a store-and-forward server.

- A *mailbox* is named by its *address*, which is the hash of the mailbox's identity document. An address authenticates the key that it names, so no directory is needed.
- A sender encrypts a message to the recipient's *prekey*, which the recipient's identity or working key signed. The sender signs the message inside the encryption.
- A mailbox signs with its identity, or with a *working key* that the identity certified to sign in the identity's place. With a working key, the identity can be kept away from daily work (Section 5).
- The server stores ciphertext. The server holds no private key, no plaintext, and no signature over any message.

The keys, and the objects that each key signs (Sections 4 to 6, 10):

```mermaid
flowchart LR
    ID["identity key<br/>the address is the SHA-384<br/>of its identity document"]
    WK["working key"]
    SPM["prekey statements,<br/>passes, messages"]
    REV["revocations"]
    PK["prekey<br/>an age recipient"]
    SND["a sender"]
    ID -->|certifies| WK
    ID -->|signs| SPM
    WK -->|signs, under its certificate| SPM
    ID -->|signs| REV
    SPM -->|a prekey statement names| PK
    SND -->|encrypts to| PK
```

The life of one message (Sections 11.8, 11.10 to 11.13, 12.2, 12.3):

```mermaid
sequenceDiagram
    participant S as Sender
    participant V as Server
    participant R as Recipient
    S->>V: look up the recipient
    V-->>S: identity, prekey statement, revocations
    Note over S: check them, then date, sign and seal the envelope
    S->>V: send the sealed file
    Note over V: stores the ciphertext
    V-->>S: receipt
    R->>V: list
    V-->>R: ids and sizes
    R->>V: fetch each message
    V-->>R: ciphertext
    Note over R: checks 1 to 9: decryption, layout, JSON, identity, signature, envelope, revocation, replay, duplicate
    R->>V: ack
```

The server is not trusted for confidentiality or for authenticity. Clients make every check that protects a message. Section 15 states what a hostile server can and cannot do.

This document specifies the formats, the meaning of each HTTP operation, and the checks that a client and a server make. Alongside this document:

- **`api/openapi.yaml` is normative for the HTTP shapes:** routes, methods, request and answer members with their types, status codes, error codes, and headers. This document says what each operation means, who may call each operation, which checks are made and what each refusal means. Where `api/openapi.yaml` and this document disagree, `api/openapi.yaml` is right about a shape, and this document is right about a meaning.
- **`testdata/vectors/` contains the conformance vectors (Section 16).**
- **`PRECEDENTS.md` sets each design decision beside the published standards and deployed systems that make the same decision.**

A reviewer of the cryptography needs Sections 2.2, 3 to 6, 8 to 10, 12.1, 12.3, 12.4, and 15. The other sections give the sender key types (Section 7), the HTTP API (Section 11), a client's other behavior (the rest of Section 12), what a server stores (Section 13), and compatibility (Section 14).

## 2. Conventions

### 2.1. Requirements language

<!-- vale off -->
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC 2119] [RFC 8174] when, and only when, they appear in all capitals, as shown here.
<!-- vale on -->

### 2.2. Notation

- **Grammar.** Each text's form is given in ABNF (RFC 5234), in the section that defines the text, right after the prose that introduces the text.
  - A string in quotes matches in any ASCII case. A string written `%s"…"` matches exactly (RFC 7405).
  - The grammar uses the core rules by name (RFC 5234 Appendix B: `ALPHA`, `DIGIT`, `DQUOTE`, `LF`, `SP`).
  - The grammar also uses these rules by name: `full-date`, `time-hour` and `time-minute` (RFC 3339 §5.6), `OWS` and `BWS` (RFC 9110 §5.6.3), and `IPv6address` (RFC 3986 §3.2.2).
  - Appendix B collects every rule.
- A *line* ends in LF (0x0A). A text "of N lines" is exactly N lines. Such a text contains no CR, and nothing follows its last LF.
- `‖` is concatenation. `str(x)` is a uint32 big-endian length followed by the bytes of `x` (RFC 4251 §5).
- An **address** is written as `d_` followed by 64 characters of base64url (RFC 4648 §5) without padding: the rule `address` (Section 4.2). An address has this form wherever it appears: a path, a statement, an envelope, a namespace, a certificate's principal.
- A **time** is an RFC 3339 timestamp in UTC, to the second, with no leap second. A text with a second of `60` is not a time. An object that ends at a time is valid while a clock reads before that time. At that second, the object has ended.

  ```abnf
  time     = full-date %s"T" time-hour ":" time-minute ":" time-sec %s"Z"
  time-sec = %x30-35 DIGIT   ; 00 to 59
  ```

- A **serial** is a decimal integer from 1 to 2^53 − 1. The grammar states only a serial's digits. The largest integer that every JSON reader represents exactly is 2^53 − 1 (Section 3.3). A certificate serial, a prekey serial and a revocation serial (Section 2.3) are each a serial.

  ```abnf
  serial = %x31-39 *15DIGIT   ; no leading zero
  ```

- **base64** is standard base64 (RFC 4648 §4) in its one encoding: padded, with the unused bits of the last character zero. In this one encoding, encoding the decoded bytes again gives the same text. Two places differ from this definition, and each says so: the armour of a signature (Section 3.2) and an adopt key (Section 11.16).

  ```abnf
  base64            = *( 4base64-char ) [ base64-final ]
  base64-nonempty   = 1*( 4base64-char ) [ base64-final ] / base64-final
  base64-char       = ALPHA / DIGIT / "+" / "/"
  base64-final      = 2base64-char base64-char-by-4 "="
                    / base64-char base64-char-by-16 "=="
  base64-char-by-4  = %s"A" / %s"E" / %s"I" / %s"M" / %s"Q" / %s"U" / %s"Y"
                    / %s"c" / %s"g" / %s"k" / %s"o" / %s"s" / %s"w"
                    / "0" / "4" / "8"   ; its value a multiple of 4
  base64-char-by-16 = %s"A" / %s"Q" / %s"g" / %s"w"   ; its value a multiple of 16
  ```
- In a namespace or a statement, `<A>` is the address of the signing mailbox.
- In a route, `<A>` is the address of the mailbox that the call is about. The call is either a mailbox's call about itself, or anyone's lookup or revocation call (Sections 11.8, 11.15). `<B>` is the address of a message's recipient. A sender sends to `<B>` (Section 11.10), and the recipient calls the other message routes as itself (Sections 11.11 to 11.14).

### 2.3. Terms

Where this document uses a term below as a defined term, the term has the sense given here.

**Mailboxes and people**

- **Mailbox:** an address, together with the keys and the messages of that address.
- **Owner:** the party that runs a mailbox.
- **Reader:** the party that reads a text the protocol carries (Section 3.3). For a message, the reader is the recipient's client (Section 12.3).
- **Server**, **own server:** the mailbox server at which a mailbox is registered, and which the mailbox calls. The server comprises everything that the server's operator runs to answer at the server's name (Section 11.1).
- **Active**, **revoked**, **unknown:** the states of a mailbox at a server (Section 11.6).
- **Forgotten:** of a mailbox, no longer kept by the mailbox's server, after nothing valid for the mailbox is left (Section 13). A forgotten mailbox is unknown.
- **Identity holder:** the holder of a mailbox's identity key, when the mailbox does not keep that key itself (Section 12.7).

**Keys**

- **Identity key**, **the identity:** a mailbox's long-term signing key (Section 4.1).
- **Identity document `D`:** the two-line text that contains the identity's public key (Section 4.1).
- **Address:** the SHA-384 of the identity document (Section 4.2).
- **Working key:** a key that the identity certifies to sign in the identity's place (Section 5.2).
- **Certificate:** the OpenSSH user certificate by which the identity certifies a working key (Section 5.2). A certificate's **certificate serial** is the certificate's serial field.
- **The protocol's maximum:** the longest that any certificate may run, 45 days and the skew allowance (3,891,600 seconds), measured as `valid before` less `valid after` (Section 5.2).
- **The server's maximum:** the longest that a certificate the server accepts may run, given as the server's `max_certificate_lifetime_seconds` (Section 11.18). The server's maximum is at most the protocol's maximum.
- **Stolen:** of a key or a pass, possessed by a party that the owner did not give the key or pass to (Sections 12.6, 15.5).

**Signers and statements**

- **Statement:** a fixed-form text that a key signs (Section 3.2): a prekey statement (Section 6), a pass (Section 8) or a revocation statement (Section 10).
- **Signer:** the signing key of a prekey statement, a pass or a message, which is either the identity key or a certificate (Section 5). A signer's **rank** is the number that Section 5 gives the signer.
- **Prekey:** a mailbox's age encryption key, which a prekey statement contains (Section 6).
- **Prekey statement:** the statement that contains a prekey (Section 6). A prekey statement's **prekey serial** is the statement's serial, `p`.
- **Later, earlier:** of two prekey statements of one mailbox, their place in `(c, p)` order (Section 5.3).
- **Current statement:** the prekey statement that a server serves for a mailbox now (Section 11.8). The current statement has the **current prekey** as its key and the **current signer** as its signer, and a current signer that is a certificate is the **current certificate**.
- **Retired prekey:** a prekey once the server has accepted a later prekey statement (Section 11.9).
- **Prekey lifetime:** the time from when a client makes a prekey statement to when the statement ends (Sections 6, 12.4).
- **Pass:** a statement that a mailbox signs to prove itself to the mailbox's server on a call (Section 8).

**Revocations**

- **Revocation statement:** the statement that the identity signs to revoke the address (Section 10.1) or certificates (Section 10.2).
- **Revocation of the address:** the revocation statement that revokes an address (Section 10.1).
- **Revocation of certificates:** the revocation statement that revokes certificates through its **revocation serial**, the `through` value (Section 10.2): every certificate of the statement's address whose certificate serial is at or below the revocation serial.
- **Revocation record:** the JSON object that contains an identity's revocations (Section 10.3).
- **No revocation shown:** an answer that shows no revocation that a client can verify (Section 12.5).

**Operations**

- **Registration**, **register:** `PUT /v1/<A>` (Section 11.7).
- **Lookup**, **look up:** `GET /v1/<A>` (Section 11.8). A mailbox **looks itself up** at its own address.
- **Served:** as given by a server in the answer to a lookup (Section 11.8).
- **Renewal**, **renew:** publishing a new prekey statement, either by `PUT /v1/<A>/prekey` (Section 11.9) or, when the server has forgotten the mailbox, as a registration (Section 12.4).
- **Identical retry:** a registration or a renewal whose prekey statement and signature are byte for byte the ones that the server keeps as current. In a registration, the identity document is also byte for byte the one that the server keeps (Sections 11.7, step 5; 11.9).
- **Send:** `POST /v1/<B>/messages` (Section 11.10). A send's **receipt** is the send's `201` answer, or the `200` answer of the send's dedupe (Section 11.10, step 6).
- **List**, **poll:** `GET /v1/<B>/messages`, which answers the oldest page of a mailbox's messages (Section 11.11).
- **Long poll:** a list whose answer the server delays (Section 11.11).
- **Fetch:** `GET /v1/<B>/messages/<id>` (Section 11.12).
- **Fetch budget:** the budget that a mailbox's fetches of messages spend (Section 11.12).
- **Intake budget:** the number of messages that a mailbox accepts from all senders together (Section 11.10, step 8).
- **Ack:** `DELETE /v1/<B>/messages/<id>` (Section 11.13).
- **Set the ACL**, **get the ACL:** `PUT` and `GET /v1/<B>/acl` (Section 11.14).
- **Publish a revocation**, **look up revocations:** `PUT` and `GET /v1/<A>/revocation` (Section 11.15).
- **Join**, **leave:** `PUT` and `DELETE /v1/<A>/account` (Section 11.16). An **adopt key** is the key that a join carries.
- **The server's document:** the document that `GET /v1/` answers (Section 11.18).
- **Version floor:** the lowest version that a server accepts, given as the server's `min_version` (Section 11.17).

**Messages**

- **Envelope:** the signed JSON line that contains a message's metadata and body (Section 9.1).
- **Plaintext:** the bytes that are encrypted: the envelope, the envelope's signature and the padding (Section 9.2).
- **Message id:** the SHA-256 of a message's ciphertext, which is the `id` by which the message's server lists the message (Section 11.10).
- **`msg_id`:** the UUID that a sender gives a message (Section 9.1).
- **Native stanza:** an age recipient stanza of a type that a prekey has, `mlkem768x25519` (Section 9.4).
- **Seal:** pad the envelope and the envelope's signature, and encrypt the result to a prekey (Sections 9.3, 9.4).
- **Outbox entry:** a message that a client keeps to be sent, together with the message's envelope (Section 12.2).
- **Post:** one attempt to send an outbox entry (Section 12.2). A **copy** is the message as delivered by one post.
- **Live:** of a message, stored at the message's server and not yet **gone**. A gone message is one that is acked or expired (Sections 11.12, 11.13).
- **TTL:** 7 days (Sections 12.2; 12.3, check 6; 13).

**Clients**

- **Pinned:** of a peer's identity, kept by a client and used in place of the served identity (Section 12.2).
- **No answer:** the result that a client assigns to a call that failed, or to a call whose answer does not have the form that this document gives the answer (Sections 3.3, 11.1, 11.2, 12.3). No answer says nothing about the question that the call asked.
- **Malformed:** of a text or an answer, not in the form that this document gives it. A malformed answer is no answer.
- **Drain:** a client's run through the messages in the client's mailbox (Section 12.3).
- **Held:** of an accepted message, kept apart because the mailbox has not allowed the message's sender (Section 12.3).
- **Replay set:** the record that a client keeps of each message that the client accepted (Section 12.3, check 8).
- **Deletion time:** the time by which a client deletes a prekey (Section 12.4).
- **The remedy:** the steps of Section 12.6, for a stolen working key.

**Time**

- **Skew allowance:** one hour, which the maker of a time-limited object other than a pass leaves for clocks that differ (Section 3.4).
- **Message margin:** the time that a client leaves before a certificate ends, for what the client signed under that certificate to be read. The message margin is at least the TTL.

## 3. Primitives

### 3.1. Algorithms

| Name | Role | Specification |
|---|---|---|
| age v1 | encryption to a prekey: `mlkem768x25519`, the hybrid ML-KEM-768 + X25519 recipient | C2SP age v1.1.0, read 2026-11-02, whose KEM is MLKEM768-X25519 from draft-ietf-hpke-pq-03 |
| Ed25519 | the identity key of types `ssh-ed25519` and `sk-ssh-ed25519@openssh.com`; a working key of type `ssh-ed25519` | RFC 8032 |
| ECDSA P-256 | the identity key of types `ecdsa-sha2-nistp256` and `sk-ecdsa-sha2-nistp256@openssh.com`; a working key of type `ecdsa-sha2-nistp256` | FIPS 186-5, RFC 5656 |
| OpenSSH security key | the identity key of types `sk-ecdsa-sha2-nistp256@openssh.com` and `sk-ssh-ed25519@openssh.com`: the key's wire form, and what its signature covers | OpenSSH `PROTOCOL.u2f`, read 2026-11-23 |
| SSHSIG | every signature other than a certificate's own: the signer's signature over SHA-512 of the message, in a namespace | OpenSSH 10.6p1 `PROTOCOL.sshsig` |
| SSH public key text | `<key type> <base64 of the wire key>` | RFC 4253 §6.6, RFC 8709, RFC 5656 |
| OpenSSH certificate | the certificate of a working key, with the certificate's own signature | draft-ietf-sshm-cert-03 |
| SHA-384 | the address | FIPS 180-4 |
| SHA-256 | a message id; the hash of a prekey statement that a send names (Section 11.10); in what a security key signs, the hash of the application and of the signed bytes | FIPS 180-4 |
| UUID | an envelope's `msg_id` | RFC 9562 |

The draft that the table names for age's KEM, draft-ietf-hpke-pq-03, is the version that C2SP age v1.1.0 cites. The conformance vectors and C2SP age v1.1.0 fix the KEM's bytes for this protocol (Section 16), whatever a later draft says.

Outside age, the protocol defines no keyed function. The protocol applies plain SHA-384 and SHA-256 only to public inputs: the identity document, a prekey statement, the ciphertext, and what a security key signs.

### 3.2. Signatures

Every signature other than a certificate's own signature is an SSHSIG (`PROTOCOL.sshsig`) in one form: the bytes that `ssh-keygen -Y sign` writes. A certificate's own signature is an OpenSSH certificate signature (Section 5.2). In an SSHSIG, the signing key signs these bytes:

    "SSHSIG" ‖ str(namespace) ‖ str("") ‖ str("sha512") ‖ str(SHA-512(message))

The signature is this blob:

    "SSHSIG" ‖ u32(1) ‖ str(signing key) ‖ str(namespace) ‖ str("") ‖ str("sha512") ‖ str(signature)

The blob is armoured as `ssh-signature`: the blob's base64 (Section 2.2) in lines of 70 characters, with a last line of 1 to 70 characters, between a BEGIN line and an END line.

```abnf
ssh-signature    = %s"-----BEGIN SSH SIGNATURE-----" LF
                   signature-text
                   %s"-----END SSH SIGNATURE-----" LF
signature-text   = *( 2signature-line ) ( signature-even / signature-odd )
                   ; two lines of 70 hold 35 groups of 4
signature-line   = 70base64-char LF
signature-even   = signature-groups LF
signature-odd    = 68base64-char
                   ( 2base64-char LF 2base64-char [ signature-groups ]
                   / 2base64-char LF base64-char-by-4 "="
                   / base64-char base64-char-by-16 LF "==" ) LF
                   ; a group of 4 split across the last two lines
signature-groups = *16( 4base64-char ) ( 4base64-char / base64-final )
```

- **The signing key is the signer (Section 5), in SSH wire form.** When the identity signs, the signing key is the bare identity key: the bytes of the identity document's line 2. When a working key signs, the signing key is the certificate.
- **The signature is of the signing key's type.** For a certificate, the signature's type is the type of the key that the certificate certifies.
  - For `ssh-ed25519`: `str("ssh-ed25519") ‖ str(R ‖ S)`, 64 bytes (RFC 8709 §6).
  - For `ecdsa-sha2-nistp256`: `str("ecdsa-sha2-nistp256") ‖ str(mpint(r) ‖ mpint(s))` (RFC 5656 §3.1.2). Each mpint is as RFC 4251 §5 defines it, with a leading zero byte only where a set high bit needs one.
  - For the two security-key types: the key's own type name, the plain type's signature bytes in their one form, then the flags and the counter that the security key returns (`PROTOCOL.u2f`): `str(type) ‖ str(R ‖ S)` or `str(type) ‖ str(mpint(r) ‖ mpint(s))`, then `byte(flags) ‖ u32(counter)`, and nothing after them. `type` is the key's own type, so a verifier refuses a `webauthn-sk-ecdsa-sha2-nistp256@openssh.com` signature. What the key signs is `SHA-256(application) ‖ byte(flags) ‖ u32(counter) ‖ SHA-256(signed bytes)`, with no extensions: an Ed25519 key signs these bytes, and a P-256 key signs their SHA-256.
- **One form.** A verifier MUST parse the armour and the blob. The verifier MUST write the signature again in this form from the values it parsed. Where the written signature and the received signature differ by any byte, the verifier MUST refuse the signature before verifying the signature. So a verifier refuses every other way of writing a signature, including:
  - another line end or line length;
  - whitespace in the base64;
  - a byte before the BEGIN line or after the last LF;
  - a version other than 1, or a hash other than `sha512`;
  - a non-empty reserved field;
  - a NUL in a string;
  - an integer with an unneeded leading zero byte.
- **ECDSA's two values of s.** If (r, s) is a P-256 signature, (r, n − s) is also a P-256 signature, where n is the group's order (FIPS 186-5), a security key's included. Each of the two is a signature in the one form. A verifier MUST accept both, and a signer may write either. Anyone who has seen one of the two can write the other (Section 5.2). An Ed25519 signature has no second form.
- **User presence.** A verifier MUST refuse a security key's signature whose flags lack user presence, bit `0x01` (`PROTOCOL.u2f`), in an SSHSIG and on a certificate. The verifier reads no other bit of the flags, and never reads the counter (Section 15.4).
- **A bound on size.** A signature is at most 1,101 bytes. That bound is the longest signature in the one form that a mailbox of a key type of Section 4.1 can make, with the mailbox's identity or with a working key of either type under a certificate as `ssh-keygen -s` makes one. The longest is an `sk-ecdsa-sha2-nistp256@openssh.com` identity's prekey statement under a certificate of an `ecdsa-sha2-nistp256` working key, with each r and s in the signature, the identity's on the certificate and the working key's, in 33 bytes. Every verifier MUST refuse a longer signature before reading the signature. In a message, the bound limits the signature block, from the block's BEGIN line through the LF after the block's END line (Section 9.2). A key type added later whose signatures are longer raises the bound with that type (Section 14).
- **Ed25519's S.** In an SSHSIG and on a certificate, an Ed25519 signature's S is below the group order L (RFC 8032 §5.1.7), a security key's included.
- **The Ed25519 equation.** The equation is RFC 8032 §5.1.7's without the cofactor, `[S]B = R + [k]A'`, compared as encodings. So a verifier accepts a neutral R, and refuses R with a point of small order added.

### 3.3. JSON

A server and a client read every JSON text that the protocol carries by the rules below. These texts are a request body, an answer, an envelope (Section 9.1) with the body inside the envelope, a revocation record (Section 10.3), and what a client keeps of one. A reader refuses a text whole if the text fails a rule:

| Text | Refused as |
|---|---|
| a request | `400 invalid_request` |
| an answer | no answer |
| an envelope | `invalid_envelope` |

- **I-JSON (RFC 7493).** The text is UTF-8. In each object, each member name appears at most once, comparing names after their escapes are read. A name or a string contains no surrogate and no Unicode noncharacter, whether written directly or escaped.
- **One object.** The text is one object, and any bytes after the object are whitespace (space, tab, LF, CR). The text has no byte-order mark.
- **Names match exactly, case included.**
- **Numbers.** A number follows JSON's grammar (RFC 8259 §6). A reader refuses a number that rounds to an infinity when read as a binary64, rounding to nearest. A reader accepts a nonzero number too small for binary64.
- **Depth.** The depth is at most 32, with objects and arrays counted together and the outermost counted as one.
- **Types.** A member that the protocol defines is of the type defined for that member. A member that the protocol defines and whose value is null is the same as that member left out, except for the envelope's `body` (Section 9.1). An integer member is written in digits alone, from 0 to 2^53 − 1. For example, `1.0` and `1e0` are not integers.
- **Bytes.** A byte member is base64 (Section 2.2).
- **Unknown members.** An unknown member is a member that the reader does not know. A server MUST refuse an unknown member in anything sent to the server, except in a revocation record. Every other reader MUST ignore an unknown member: a client in an answer, and a mailbox in an envelope. The preceding rules still apply inside an unknown member.
  - **A server MUST ignore an unknown member of a revocation record, as a client does.** A revocation record grows by a statement under a new tag (Section 14), and a record made in advance is published byte for byte (Section 12.5). So a server that refused the record whole would leave a revoked address live. The server still verifies each member that the server knows, or refuses the record.

### 3.4. Clocks

Every check of a time is exact at the clock of the party that makes the check. The check itself adds no time for clocks that differ. Instead, the maker of a time-limited object leaves the **skew allowance**, one hour, for clocks that differ. Each object's section states how the object's maker leaves the allowance:

- a certificate's start, at a verifier (Section 5.2);
- a prekey statement's ceiling, at a server (Section 6);
- a reader's limit on `sent_at` (Section 12.3, check 6);
- when a client renews a prekey (Section 12.4);
- how long a server keeps a message (Section 13).

A pass leaves 5 minutes for clocks that differ, in place of the skew allowance (Section 8).

## 4. Identity and address

### 4.1. The identity document

The identity document `D` is two lines of ASCII: the tag, then one SSH public key written as `<key type> <base64 of the wire key>`, with no comment. For example:

```
dromas-v1
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI<43 characters>
```

A key of a type this section defines MUST be in that type's one encoding, and MUST meet that type's key checks. A reader that does not verify a key type that a later version defines refuses that type as `unsupported_key_type`, not as malformed. The key's one encoding is the wire key that OpenSSH writes back after reading the key. Parsed as the type that line 2 names and written again, the key gives the same bytes. So one key has one document, and one address.

| Key type | Document | What fixes its one encoding | Key checks | Working key |
|---|---|---|---|---|
| `ssh-ed25519` | 91 bytes | the key's length, 32 (RFC 8709 §4) | a canonical point, not of small order | `ssh-ed25519`, `ecdsa-sha2-nistp256` |
| `ecdsa-sha2-nistp256` | 171 bytes | the curve's name, `nistp256`, and an uncompressed point: on the curve, not the point at infinity, each coordinate below the field's size | none | `ssh-ed25519`, `ecdsa-sha2-nistp256` |
| `sk-ecdsa-sha2-nistp256@openssh.com` | 218 bytes | the `ecdsa-sha2-nistp256` row's, then the application, exactly `ssh:` | none | `ssh-ed25519`, `ecdsa-sha2-nistp256` |
| `sk-ssh-ed25519@openssh.com` | 138 bytes | the `ssh-ed25519` row's, then the application, exactly `ssh:` | a canonical point, not of small order | `ssh-ed25519`, `ecdsa-sha2-nistp256` |

- **Every client MUST verify every key type this section defines.**
- **The two security-key types are OpenSSH's (`PROTOCOL.u2f`).** The wire key is `str(type) ‖ str("nistp256") ‖ str(Q) ‖ str(application)` or `str(type) ‖ str(A) ‖ str(application)`, with Q the uncompressed point and A the 32-byte key. A reader MUST refuse any application other than exactly the 4 bytes `ssh:`, a NUL after them included, as a key that fails its key checks. The key carries no attestation, so nothing in the key shows that an authenticator holds it (Section 15.4).
- **A key type defined after this version is OPTIONAL (Section 14).** Each client decides whether to verify such a type, and each server decides whether to register such a type (Section 11.7). Only a mailbox whose client verifies an optional type can write to a mailbox of that type, or hear from one (Section 7). This version defines no optional type.
- **Working key.** The table's Working key column gives the types of the working keys that an identity of the row's type certifies (Section 5). A key type defined later states its own working key types.
- **The form is the same for every key type, defined here or not.** An identity document has the form `identity-document`. In that form, `key-type` is a key type's name as RFC 4251 §6 writes one. The base64 is of an SSH wire key that begins with that same name.

  ```abnf
  identity-document = %s"dromas-v1" LF key-type SP base64-nonempty LF
  key-type          = key-name [ "@" domain ]   ; at most 64 characters
  key-name          = 1*( %x21-2B / %x2D-3F / %x41-7E )   ; printable ASCII, no "," or "@"
  domain            = domain-label 1*( "." domain-label )
  domain-label      = ( ALPHA / DIGIT ) [ *61( ALPHA / DIGIT / "-" ) ( ALPHA / DIGIT ) ]
  ```
- **A reader MUST refuse as `unsupported_key_type`, never as malformed, a well-formed document of a type that the reader does not verify (Section 15.4).**

### 4.2. The address

The address is the SHA-384 of `D`, written in 66 characters: the name of the address's form, `d`, then `_`, then the 48 bytes of the hash in base64url (RFC 4648 §5) without padding. For example, with OpenSSL: `printf d_; openssl dgst -sha384 -binary < identity.doc | openssl base64 -A | tr '+/' '-_'`. Base64url of 48 bytes needs no padding and leaves no unused bit, so each address has one text form:

```abnf
address      = address-form "_" 64base64url-char
address-form = %s"d"   ; the one form this version defines
```

- **SHA-384 is NIST's category 4 for collisions (SHA-256 is category 2).** The address is the one part of a mailbox that never changes. Whatever else of the mailbox is renewed, a second preimage of the address names the mailbox permanently.
- **The text before the first `_` names the address's form.** That first `_` is the delimiter, whatever follows it, because the name of a form never contains `_`. The 64 characters after the delimiter may begin with `-` or `_`. This version defines one form, `d`. A reader MUST refuse an address of any other form as no address.
- **An address begins with the name of its form, so a command line never reads an address as an option.**
- **An address is compared as an exact string, case included.** Two addresses that differ only in case are two addresses.
- An address commits to the identity key alone. Renewing the prekey, or changing the prekey's type, never changes the address.
- An address has no checksum. A mistyped address names no mailbox.
- Line 1 of `D` is the protocol's version. Another deployment uses its own tag, and so its own address space.

### 4.3. The link

An address is shared as the link `https://<server>/to/<address>`.

- A server MUST serve a page at that link for exactly an `address` (Section 4.2), and `404` for any other path. The page consists of fixed text, the address, and the server's own link to the address. The page never contains text that a mailbox supplied. The server sends the page with `Referrer-Policy: no-referrer` and `X-Robots-Tag: noindex`. The server ignores a query on the link.
- A client given a link MUST read the address from the link's path, and MUST NOT request the page.
- A client MUST refuse a link whose scheme or server name (Section 8) is not that of the client's server URL, a link with user information, and an `https` link with a port of 80.

## 5. Signers

Every prekey statement, pass and message that a mailbox signs has an SSHSIG (Section 3.2). The SSHSIG's signing key is the **signer** of that prekey statement, pass, or message. A signer has one of two forms:

| Signer | Rank |
|---|---|
| The identity key, the key of the identity document's line 2, byte for byte | 0 |
| A certificate the identity made of a working key (Section 5.2) | the certificate's certificate serial, 1 to 2^53 − 1 |

- **The identity also signs certificates and revocations (Section 10).** A verifier verifies a certificate's own signature, and a revocation's signature, against the identity key directly. In these two roles the identity key is not a signer, and has no rank.
- **A verifier verifies a signer's signature by Section 5.4.**

### 5.1. What a verifier accepts

- **The identity's own signature.** A verifier accepts the identity's own signature on a prekey statement, a pass or a message, even where the verifier has a revocation of certificates for the address. A revocation of certificates does not cover the identity's signature. Only the revocation of the address ends the identity's signature (Section 10.1).
- **A certificate above the revocation serial.** Where a verifier has a revocation of certificates for the address (Section 10.2), the verifier MUST refuse a signer that is a certificate whose certificate serial is at or below that revocation serial, comparing the two as numbers. A verifier with no revocation of certificates for the address accepts every certificate that meets Section 5.2.
- **Each party applies these rules by the revocations it has:**
  - a reader, at check 7 (revocation) of Section 12.3, and never at check 5 (signature);
  - a sender, when the sender looks up the recipient before every post (Section 12.2);
  - a server, by the server's record of the address (Sections 8, 11.7, 11.9).

### 5.2. Certificates

A certificate is an OpenSSH user certificate. A verifier MUST check every row of this table:

| Field | Rule |
|---|---|
| Type | a user certificate |
| Certified key | the working key: of a type that Section 4.1's table gives for the identity's type, in that type's one encoding and meeting its key checks, and never the identity key |
| Serial | the certificate serial, a serial (Section 2.2) |
| Key id | exactly `dromas-cert-v1` |
| Principals | exactly one: the mailbox's address |
| Validity | `valid after` ≤ now < `valid before`, at the verifier's clock, in whole seconds; each at or before `9999-12-31T23:59:59Z`; and `valid before` less `valid after` at most the protocol's maximum |
| Critical options | none. A verifier MUST refuse a certificate with any critical option (draft-ietf-sshm-cert-03 §2.1.1) |
| Extensions | none. A verifier MUST refuse a certificate with any extension |
| Reserved | empty |
| Nonce | exactly 32 bytes |
| Signed by | the identity key, byte for byte as the key appears in the identity document, with the signature in the one form of the key's type, a security key's with user presence (Section 3.2) |

- **A verifier checks a certificate's dates at the verifier's clock, exactly, as the last of the certificate's checks (Section 5.4, step 4).** A certificate is valid from its `valid after`, and has ended at its `valid before` (Section 2.2). A verifier refuses a certificate with a date past `9999-12-31T23:59:59Z`, including `ssh-keygen`'s `forever`.
- **A verifier refuses a certificate that runs longer than the protocol's maximum.** The protocol's maximum holds at every verifier, whatever any server serves as its own maximum (Section 15.5). A server also refuses a certificate that runs longer than the server's maximum (Section 11.7, step 6).
- **The certified key is never the identity key (Section 15.5).**
- **Every certificate MUST certify a new working key, one that no certificate made before it certified.** No verifier can check this rule. The certificate's maker keeps to the rule (Section 15.5).
- **A maker dates the start of a certificate the skew allowance before the maker makes the certificate (Section 3.4).** The maker makes the certificate run as long as the party that has the identity key chooses, up to the server's maximum (Section 11.18), and never longer than the protocol's maximum. For example, this `ssh-keygen` command makes a certificate of `$DAYS` days and the skew allowance, with `-U` added for an identity in an agent:

      ssh-keygen -s identity -I dromas-cert-v1 -n "$A" -z "$SERIAL" -V "-1h:+${DAYS}d" -O clear work.pub

- **Certificate serials.**
  - The maker gives a certificate the certificate serial that the maker's own clock gives, in seconds since 1970-01-01T00:00:00Z. Where that serial is at or below the highest certificate serial that the maker knows of for the mailbox, the maker gives the certificate one above that highest serial. The highest certificate serial the maker knows of is the highest of these:
    - the current certificate's serial, as served;
    - the serials of the certificates under which the mailbox registered, renewed or signed;
    - the highest certificate serial the identity has revoked (Section 10.2).

    So a certificate serial is always above the address's revocation serial.
  - A verifier MUST NOT read a certificate serial as a time, or bound a certificate serial by the verifier's clock. Of two certificate serials, the higher one ranks higher.
  - Two certificates of one identity can share a certificate serial. A verifier that meets both accepts either one, and keeps only their shared certificate serial.
- **Nothing may depend on a P-256 signature having one set of bytes, a security key's included.** Anyone who has seen (r, s) can write (r, n − s) (Section 3.2). This is true of a certificate that a P-256 identity made, and of the prekey statements, passes, and messages that a P-256 identity or a P-256 working key signs.

### 5.3. Order

- **A mailbox's prekey statements are ordered by `(c, p)`.** Here `c` is the rank of the prekey statement's signer, and `p` is the prekey statement's prekey serial (Section 6). Of two prekey statements, this table gives the later one:

  | Signers | Which is later |
  |---|---|
  | of different rank | the one whose signer has the higher rank, at any prekey serial |
  | the same signer | the one with the higher prekey serial |
  | different certificates of the same certificate serial | neither |

  Once a prekey statement under a certificate is accepted, a prekey statement that the identity signs is earlier than the accepted one. From then on, a server and a sender refuse a prekey statement that the identity signs.
- **Who orders them.** A server orders a mailbox's prekey statements by this table (Section 11.9). A sender orders the prekey statements the sender has seen by `(c, p)` as two numbers, whatever the certificate (Sections 6, 12.2). So the table's row for different certificates of the same certificate serial binds only the server.
- **A signer of a higher rank retires different things at each party:**
  - at the server, every prekey statement by a signer of a lower rank (Section 11.9), and the pass by every certificate other than the current certificate (Section 8). The server still accepts the identity's pass.
  - at a sender, every prekey statement by a signer of a lower rank.
  - at a reader, nothing. A reader accepts a message signed by the sender's identity, or under any certificate of that identity that the reader accepts (Section 5.1) and that is valid when the reader reads the message.

### 5.4. Verifying a signature

To verify the signature on a prekey statement, a pass or a message, a verifier MUST apply the following steps. The inputs are the armoured signature, the signed bytes, the namespace, the identity document of the mailbox that signed, and the verifier's clock. If any step fails, the verifier refuses the signature. A verifier MAY check in another order only where each signature gets the same result, and a refused signature the same reason.

1. Check that the signature is no longer than the bound (Section 3.2).
2. Parse the armour and the blob, and check that the signature is in the one form (Section 3.2).
3. Read the signing key from the blob. If the signing key is the identity key, byte for byte as on line 2 of the identity document, the signer is the identity. Skip to step 5.
4. Otherwise the signing key MUST be a certificate, so a bare working key fails. The signer is the certificate. Check the certificate by every rule of Section 5.2, including the identity's signature on the certificate. Of those rules, check `valid after` ≤ now < `valid before` last.
5. Verify the SSHSIG over the signed bytes, in the namespace, under the identity key or the certified working key (`PROTOCOL.sshsig`, Section 3.2). A security key's signature without user presence fails this step (Section 3.2).

The result is the signer, whose rank Section 5 gives. Each party applies revocations to the signer afterwards (Section 5.1).

## 6. The prekey statement

A prekey statement has the form `prekey-statement`. The mailbox's signer (Section 5) signs the prekey statement in the namespace `dromas-prekey-v1:<A>`, `prekey-namespace`:

```abnf
prekey-statement = %s"dromas-prekey-v1" LF address LF rank LF serial LF
                   age-recipient LF time LF
prekey-namespace = %s"dromas-prekey-v1:" address
rank             = "0" / serial
age-recipient    = %s"age" *bech32-hrp-char "1" 6*bech32-char
bech32-hrp-char  = %x21-40 / %x5B-7E   ; printable ASCII but A-Z
bech32-char      = "0" / %x32-39 / %x61 / %x63-68 / %x6A-6E / %x70-7A
                   ; BIP 173's alphabet: no 1, b, i or o
```

- **Rank:** the rank of the prekey statement's signer (Section 5). The rank is `0` when the identity signs. The rank is the certificate serial when a working key signs under a certificate.
  - A verifier reads the rank of the signer from the signature's signing key (Sections 3.2, 5).
  - A verifier MUST refuse a prekey statement whose rank differs from the rank of that signer. Such a prekey statement is invalid.
- **Serial:** the prekey serial, a serial (Section 2.2). Under one signer, each prekey statement's prekey serial is higher than the previous one's.
- **Key:** an age recipient. The recipient's Bech32 human-readable part, before the last `1`, names the key's type (BIP 173). The key is written as age writes a recipient: of any length, with a valid checksum, and with the data in whole bytes.
  - The one prekey type is `mlkem768x25519`, named `age1pq`.
  - A key whose X25519 half is of small order makes the prekey statement invalid.
  - A prekey type added later is an addition inside v1 (Section 14).
- **`not_after`:** a time.
  - A client signs a prekey statement to end one prekey lifetime after the client makes the prekey statement (Section 12.4).
  - A server accepts a prekey statement that ends at most 8 days and the skew allowance after the time on the server's own clock. The longest prekey lifetime is 8 days (Section 12.4).
- **A sender MUST NOT encrypt to a prekey past the prekey's `not_after`.** There is no grace period.
- **A sender MUST refuse a prekey statement whose `not_after` is more than 8 days and the skew allowance after the sender's clock.** No server accepts such a prekey statement, so this bounds how long a prekey statement that a stolen working key signed stays usable (Section 15.5).
- **A sender MUST keep, for each mailbox, the latest `(c, p)` it has seen on the mailbox's prekey statements.** The sender MUST refuse an earlier prekey statement. The sender compares `(c, p)` as two numbers, whatever the certificate (Section 5.3).
- **A sender MUST check a prekey statement against every other rule before it checks the key's type.** The sender refuses a prekey statement as `unsupported_prekey_type`, never as one that does not verify, when both of these are true:
  - the prekey statement meets every other rule;
  - the key is a well-formed Bech32 string whose human-readable part begins `age` and is not `age1pq` (for example, X25519's `age`).

  The sender seals and posts nothing to such a prekey statement.

## 7. Sender key types

A mailbox declares the optional identity key types its client verifies (Section 4.1), so that a sender of an optional type writes only to a mailbox that can read that sender's messages. Every mailbox accepts senders of every type that Section 4.1 defines.

- **In its registration (Section 11.7) and in each renewal (Section 11.9), a mailbox SHOULD declare in `sender_key_types` every optional key type its client verifies.** The declaration is a list of key type names. A lookup carries the list (Section 11.8).
- **A mailbox MUST NOT list a type that Section 4.1 defines.**
- **A sender whose identity key is of an optional type that the recipient did not list MUST NOT send.** A server refuses such a send with `403 unsupported_sender_key_type` (Section 11.10, step 7).
- **The declaration belongs to the current prekey.** A renewal replaces the declaration with the renewal's own, or with none if the renewal carries none. An identical retry changes nothing (Sections 11.7, step 5; 11.9).
- **The declaration is not signed.** A recipient's client decides which messages to accept by the key types the client verifies (Section 12.3), never by this list.
- **A server keeps the names of the optional types it knows.** The server ignores every other name, including the name of a type that Section 4.1 defines.

## 8. The pass

A mailbox proves itself to its server with a pass that the mailbox signs for itself, on every call that the mailbox makes as itself. The server issues nothing for the pass, and stores nothing.

The pass has the form `pass-statement`. The mailbox's signer (Section 5) signs the pass in the namespace `dromas-pass-v1:<A>`, `pass-namespace`:

```abnf
pass-statement = %s"dromas-pass-v1" LF address LF server-name LF time LF
pass-namespace = %s"dromas-pass-v1:" address
server-name    = server-host [ ":" server-port ]
server-host    = dns-name / "[" IPv6address "]"   ; in lowercase
dns-name       = dns-label *( "." dns-label )   ; at most 253 characters
dns-label      = dns-char [ *61( dns-char / "-" ) dns-char ]
dns-char       = %x61-7A / DIGIT
server-port    = %x31-39 *4DIGIT   ; no leading zero, at most 65535,
                                   ; and neither 80 nor 443
```

- **The server name.** The server name is the host of the mailbox's URL for its server, in lowercase, with no user information, followed by the URL's port as a number. A server name never carries port 80 or port 443.
  - A client drops a port of 443 whatever the scheme. A client drops a port of 80 from an `http` URL, and refuses an `https` URL with a port of 80 (Section 11.1).
  - The server name's host is either a name of DNS labels (RFC 1123 §2.1), including an IPv4 address, or an IPv6 address in brackets.
  - Anything else that RFC 3986's `host` allows is not a server name: IPvFuture, a zone, percent-encoding, or any other character.
  - For example, `https://dromas.dev:443` and `https://dromas.dev` both have the server name `dromas.dev`. `http://127.0.0.1:80` and `http://127.0.0.1` both have the server name `127.0.0.1`. `http://127.0.0.1:8080` has the server name `127.0.0.1:8080`.
- **A server MUST write the `Host` of a request the same way, and drop a port of 443 and a port of 80 alike, so that checking a pass never depends on the scheme of the request.** The server reads the pass's server name from the request's `Host`, written that way.
- **A client writes the pass as the value of one `Authorization` line, in the form `pass-authorization`.** In that value, the signature is the base64 of the armoured signature. A request with two `Authorization` lines carries no pass.

  ```abnf
  pass-authorization = %s"dromas-pass" SP
                       %s"address=" DQUOTE address DQUOTE "," SP
                       %s"not_after=" DQUOTE time DQUOTE "," SP
                       %s"signature=" DQUOTE base64-nonempty DQUOTE
  ```

- **A server reads the value as RFC 9110 §11 lets a recipient read credentials, in the form `pass-credentials`.** The three parameters come in any order, each once, as a list (RFC 9110 §5.6.1). Each value is a token or a quoted-string (RFC 9110 §5.6.2, §5.6.4) that contains no backslash and has that value's form. The server verifies the signature over the pass built from those values, never over the header's text.

  ```abnf
  pass-credentials = pass-scheme 1*SP [ pass-gap ] pass-params [ pass-gap ]
  pass-scheme      = "dromas-pass"
  pass-params      = address-param pass-gap not-after-param pass-gap signature-param
                   / address-param pass-gap signature-param pass-gap not-after-param
                   / not-after-param pass-gap address-param pass-gap signature-param
                   / not-after-param pass-gap signature-param pass-gap address-param
                   / signature-param pass-gap address-param pass-gap not-after-param
                   / signature-param pass-gap not-after-param pass-gap address-param
  pass-gap         = 1*( OWS "," ) OWS   ; empty list elements skipped
  address-param    = "address" BWS "=" BWS ( address / DQUOTE address DQUOTE )
  not-after-param  = "not_after" BWS "=" BWS DQUOTE time DQUOTE
  signature-param  = "signature" BWS "=" BWS
                     ( base64-token / DQUOTE base64-nonempty DQUOTE )
  base64-token     = 1*( 4( ALPHA / DIGIT / "+" ) )   ; base64 that is a token
  ```

- **A server MUST refuse a value that is too long with `401 invalid_pass`, before the server hashes, parses, or verifies the value.** A value is too long when, whitespace included, the value is longer than the form a client writes with a signature as long as the bound (Section 3.2).
- **Lifetime.** A client signs a pass to end at most 10 minutes after signing. A server accepts a pass that has not ended and that ends at most 15 minutes after the time on the server's own clock: the pass's 10 minutes, and 5 minutes for clocks that differ.
- **A client MAY keep a pass, and use the kept pass for its calls until the pass is about to end.** A client MUST NOT use a kept pass with more than 10 minutes left, because the client's clock has then gone back since the client signed the pass. A client MUST NOT send a kept pass to a server whose name is not the one the pass was signed for. It keeps that name beside the pass, and signs a new pass for any other server, which could otherwise replay the kept pass at the server it names.
- **A server MAY remember a pass it has verified, by the pass's values with the signature in the one form (Section 3.2).**
- **Which signer.** A server accepts a pass:
  - by the mailbox's identity, always;
  - by a certificate, only where that certificate is exactly the current certificate, as the bytes the server keeps.

  The exception: on a registration (Section 11.7) and on a renewal (Section 11.9), the server accepts a pass by the certificate of the prekey statement that the call brings, in place of the current certificate.

  A server accepts a pass only where the pass's server name is one of the server's names (Section 11.1). A server reads a pass by the form of the pass's signer (Section 5).
- **A client whose pass a server refuses MAY sign another pass and try once more.** A refusal of that second pass is the call's answer. The client MUST NOT retry at all after a `certificate_revoked` that the client finds final when the mailbox looks itself up (Section 12.5). When a server refuses both passes for their time, the cause is the mailbox's clock (Section 15.7).
- **A lookup (Section 11.8), the link page (Section 4.3), publishing a revocation and looking up revocations (Section 11.15) accept no pass.** A server reads no pass on these calls, whatever `Authorization` they carry.

**Refusals.** Each refusal below is a `401`. `certificate_revoked` comes first, and otherwise this table gives the code:

| Code | When |
|---|---|
| `certificate_revoked` | the call accepts a pass by the current certificate, the identity has revoked that certificate, and the pass does not name the identity's key (Section 11.4, rule 1); or the call brings a prekey statement under a certificate that the identity revoked |
| `pass_expired` | at the server's clock, the pass has ended or ends more than 15 minutes ahead, or the pass's certificate has not begun or has ended |
| `certificate_superseded` | the pass is by any key other than the identity's and the certificate that the call accepts a pass by, or the certificate that the server keeps for the mailbox does not verify |
| `invalid_pass` | there is no pass, or the pass is not this mailbox's, or the pass is not for this server, or the pass does not verify |

A `certificate_superseded` answer names, in `certificate_serial`, the certificate that the call should have used:

| Call | `certificate_serial` |
|---|---|
| any call but a registration or a renewal | the current certificate's |
| a registration or a renewal, refused for its pass | the serial of the certificate under the prekey statement that the call brings |
| a renewal whose prekey statement is signed by a signer of lower rank, or by another certificate with the current certificate's serial (Section 11.9) | the certificate serial that the renewal's prekey statement must be above |

The answer omits the member where the signer in question is the identity.

## 9. Messages

### 9.1. The envelope

The envelope is one line of compact JSON, including the LF that ends the line. The sender signs the envelope. The server never sees the envelope.

| Member | Presence | Value |
|---|---|---|
| `v` | required | the integer `1` |
| `from` | required | the sender's address |
| `to` | required | the recipient's address |
| `sent_at` | required | a time: when the sender posted this copy (Section 12.2) |
| `msg_id` | required | a UUID of any version, written as RFC 9562 §4 writes one, in lowercase: `msg-id`. A client makes a random UUID (version 4) once for each message, and keeps that UUID on every copy |
| `identity` | required | the sender's identity document, in base64. `from` is the hash of the identity document |
| `body` | required | the message's content: any JSON value, carried as that value. A null body is a value |
| `subject` | optional | a string |
| `in_reply_to` | optional | a string: the `msg_id` of the message this message replies to |
| `supersedes` | optional | a string: a `msg_id` from the same sender, naming a message that this message replaces. A stored message is never altered. The recipient decides |
| `group` | optional | an array of addresses: every member of the group that the message is sent to, `from` and `to` among them. A message to one mailbox has no `group` |

```abnf
msg-id    = 8lowhexdig "-" 4lowhexdig "-" 4lowhexdig "-" 4lowhexdig "-"
            12lowhexdig   ; the UUID of [RFC 9562], Section 4, in lowercase
lowhexdig = DIGIT / %x61-66   ; HEXDIG in lowercase
```

- **An empty string in `subject`, `in_reply_to` or `supersedes` is the same as the member left out.** A writer leaves out `subject`, `in_reply_to` or `supersedes` when the member's value would be an empty string.
- **A sender MUST refuse an `in_reply_to` or `supersedes` that is not a `msg_id`.** A reader checks only that each is a string.
- **`in_reply_to` is the sender's claim.** The sender signs `in_reply_to` with the rest of the envelope, but nothing ties it to a message that exists. A reader takes it as what the sender says the message replies to.
- **A sender MUST write `group` with at least two addresses, `from` and `to` among them, each address once, in ascending byte order of the addresses' text.**
- **A reader reads `group` in these steps:**
  1. A value that is not an array of addresses is malformed, as any member of the wrong type is (Section 12.3, check 6).
  2. A `null` value is the member left out (Section 3.3).
  3. An array that lacks `from` or `to` is read as no group, and the message as sent to one mailbox. An empty array and an array of one address are such arrays.
  4. Otherwise the reader reads the array's addresses as a set: sorted in ascending byte order of their text, each address once. A reader accepts an array out of order or with an address twice.
- **The set of addresses is the group.** A group's members never change. A message to another set of addresses is a message to another group. A conversation that goes on with another set names a message of the earlier group in its first message's `in_reply_to`.
- **The line is compact UTF-8 JSON.** The JSON text contains no line feed, so the LF that ends the line is the line's only LF.
- **A sender MUST check the envelope against the rules that the envelope's reader applies:** Section 3.3, and Section 12.3, check 3 (JSON). The body is nested at most 31 deep, so the envelope is nested at most 32 deep.
- **A sender MUST refuse the whole of an envelope that breaks a rule, without repair, before the outbox keeps the envelope.** A sender writes, in compact form, an envelope that meets the rules. The envelope's strings and numbers are the values given.
- **A reader accepts, as the envelope, any JSON text on the line that Section 3.3 accepts, whatever spelling the sender's encoder chose.** The reader MUST read the members from the line exactly as decrypted.
- **`v` changes only for a breaking change.** A reader MUST refuse a `v` that the reader does not know.
- **A reader ignores a member that this version does not define (Section 3.3).** So two clients can agree on members of their own.
  - A member that this protocol defines has a plain name.
  - Any other member SHOULD have a collision-resistant name that contains a domain its writer controls (`example.com/compress`), and never an `x-` prefix (RFC 6648).
  - Such a member adds to a message. Such a member never changes the meaning of a member this protocol defines. Therefore content that two clients transform between themselves goes inside `body`.

### 9.2. The plaintext: envelope, signature, and padding

The sender signs the envelope with its signer (Section 5), in the namespace `dromas-msg-v1:<recipient>`. For example, a sender that signs with its identity can run this command:

    ssh-keygen -q -Y sign -n "dromas-msg-v1:$B" -f identity < P > P.sig

A sender that signs with its working key, under the working key's certificate, uses `-f work-cert.pub` instead.

The plaintext is, in order:

```
{"v":1,"from":"…","to":"…","sent_at":"…","msg_id":"…","identity":"…","body":"…"}
-----BEGIN SSH SIGNATURE-----
U1NIU0lH…
-----END SSH SIGNATURE-----
................
```

1. **Line 1 is the envelope.** The sender signs the bytes of line 1, LF included.
2. **Then the signature.** The signature is as `ssh-keygen` writes it, up to and including its END line.
3. **Then padding.** The padding runs to the end of the plaintext (Section 9.3).

A sender writes the plaintext as `plaintext`, and signs in the namespace `msg-namespace`:

```abnf
plaintext     = envelope-line ssh-signature padding
envelope-line = 1*( %x00-09 / %x0B-FF ) LF   ; the envelope (Section 9.1)
padding       = *"."   ; Section 9.3
msg-namespace = %s"dromas-msg-v1:" address
```

A reader MUST separate the parts by these rules:

1. **The reader verifies the signature over line 1 exactly as decrypted.** The reader reads the envelope's members from those same bytes, never from anything rebuilt.
2. **Each part has one place, and nothing is searched for.**
   - Line 2 MUST be the signature's BEGIN line, ending in LF.
   - The block ends at the first END line, which MUST be followed by LF.
   - If the byte right after the first END line is any byte other than LF, or there is no byte after that END line, the reader refuses the message. The reader does not look for a later END line.
   - The bytes after the LF that follows the first END line are never parsed or shown.
3. **One signature, one identity.** The reader verifies the signature against the identity that the envelope carries. The verdict is the result of that verification alone.

The namespace binds the signature to the message's recipient. A message signed for one mailbox does not verify in another mailbox's namespace.

### 9.3. Padding

A sender pads every message so that the message's ciphertext is a whole number of blocks.

- **Block.** A block is the smallest power of two that is both at least 1/16 of the ciphertext's size and at least 1 KiB.
- **Padding.** The padding is `.` bytes after the signature's END line, up to the end of the plaintext.
  - The sender adds as many padding bytes as make the ciphertext the next whole number of blocks.
  - A ciphertext that is already a whole number of blocks gets no padding.
  - The padding is not signed.
- **Examples.** A ciphertext of 40,000 bytes has a block of 4 KiB, and is padded to 40,960 bytes. A ciphertext of 70,000 bytes has a block of 8 KiB, and is padded to 73,728 bytes.
- **The ciphertext is what is measured.** A sender MUST refuse to send a ciphertext whose size, apart from any stanza that a server ignores (Section 9.4), is not a whole number of blocks. The sender computes the padding from the ciphertext's size before encrypting. For example, an age file (C2SP age) that has one native stanza and no other stanza, for a plaintext of L bytes, has this many bytes:

      H + 16 + L + 16 × max(1, ⌈L / 65,536⌉)

  In order, the terms are: the header, H, which is 1,627 bytes for the file's `mlkem768x25519` stanza; the payload's nonce; the plaintext; and a tag for each 64 KiB chunk.
- **A sender pads a message each time the sender seals the message, for the prekey of that seal.** So a message sealed again is padded again.
- **A server does not check padding.** A size limit that a server sets MUST be a whole number of the limit's own blocks, as every power of two of at least 1 KiB is. So a message fits a limit padded exactly when the message fits the limit unpadded.

### 9.4. Encryption

The sender encrypts the plaintext to the recipient's prekey with age (C2SP age), in the binary format, not armoured. As a shell command: `{ cat P P.sig; padding; } | age -r <recipient> > m.age`. The age file has one `mlkem768x25519` stanza. A sender adds no other stanza, apart from a stanza that a server ignores (Section 11.10, step 7).

## 10. Revocation

### 10.1. Revocation of the address

A mailbox's identity can revoke the mailbox's address permanently. Only the identity can revoke the address.

- **The revocation statement is fixed text, `revocation-of-address`.** The statement has no date, no reason, and no number. A verifier builds the statement from the address. Therefore a copy signed at any time is the same revocation statement.
- **The identity key signs the revocation statement.** The signature is in the namespace `dromas-revoke-v1:<A>`, `revoke-namespace`, with the bare identity key as the signing key. A working key's signature over the same revocation statement, under a certificate of that identity, is not a revocation. When a verifier checks this signature, the verifier's `allowed_signers` line names the identity key with no `cert-authority`.

  ```abnf
  revocation-of-address = %s"dromas-revoke-v1" LF address LF
  revoke-namespace      = %s"dromas-revoke-v1:" address
  ```

- **A revocation of the address reaches back, and nothing undoes it.** After a verifier has verified a revocation of the address, the verifier:
  - accepts nothing signed for that address, whenever it was signed;
  - sends nothing to the address;
  - keeps the revocation permanently. No later answer and no later revocation record undoes the revocation.

### 10.2. Revocation of certificates

The identity revokes every certificate it made through a revocation serial, including that serial, and keeps its address.

- **The revocation statement, `revocation-of-certificates`, carries the address and the revocation serial.**
- **The identity key signs the revocation statement.** The signature is in the namespace `dromas-revoke-certs-v1:<A>`, `revoke-certs-namespace`. As a shell command: `ssh-keygen -q -Y sign -n "dromas-revoke-certs-v1:$A" -f identity < statement > statement.sig`. A verifier refuses a working key's signature.

  ```abnf
  revocation-of-certificates = %s"dromas-revoke-certs-v1" LF address LF serial LF
  revoke-certs-namespace     = %s"dromas-revoke-certs-v1:" address
  ```

- **A revocation of certificates revokes every certificate of the address whose certificate serial is at or below its revocation serial.**
  - A revocation of certificates covers certificates only (Section 5.1).
  - A verifier keeps the revocation of certificates with the highest revocation serial that the verifier has verified, and that revocation stands. A revocation of certificates through a lower revocation serial changes nothing, whenever it arrives.
  - There is no way to revoke fewer certificates.
- **A revoked certificate loses the following, at each verifier that keeps the revocation:**
  - a reader refuses a message signed under the certificate, whenever the message was signed (`certificate_revoked`; Section 12.3, check 7);
  - a sender refuses a prekey statement under the certificate (Section 12.2);
  - a server refuses every pass and every prekey statement under the certificate (Sections 8, 11.7, 11.9);
  - a server refuses a send to a mailbox whose current statement is under the certificate (Section 11.10, step 7).

  The address stays in use.
- **A mailbox MUST NOT sign a message under a certificate that a revocation it keeps covers.**
- **A mailbox MUST NOT make a certificate that its identity has revoked.** That is, the mailbox's next certificate serial is above the highest revocation serial that the mailbox keeps or that the mailbox's server shows the mailbox (Section 5.2). A revocation of certificates through 2^53 − 1 leaves no certificate to make.
- **A verifier keeps a revocation of certificates permanently, as the verifier keeps a revocation of the address (Section 10.1).** A verifier keeps one revocation of certificates per address: a verified revocation through a higher revocation serial replaces the one kept, since it covers every certificate the lower one covers (Section 15.6).

### 10.3. The revocation record

A revocation record carries an identity's revocations, and the record proves itself. Anyone who has the address can check the record with nothing else.

```json
{"type":"revocation_record","identity":"<base64 of D>","revocation_signature":"<base64>","revoked_certificates":"<base64>","revoked_certificates_signature":"<base64>"}
```

- **`type`.** The value is `"revocation_record"`.
  - Every writer writes this member. A server writes the member in its answers, and `api/openapi.yaml` requires the member there. A client writes the member in every revocation record it sends.
  - A reader accepts a revocation record without this member.
  - A reader MUST refuse a revocation record that names another type (a server refuses with `400 invalid_request`, and `type` in `param`).
- **`identity`.** This member is the identity document. In a record that a server serves, the document MUST hash to the address, and its key MUST be in its type's one encoding and meet its type's key checks (Section 4.1).
- **`revocation_signature`.** If present, this member is the revocation of the address (Section 10.1): the revocation's armoured signature, in base64.
- **`revoked_certificates` and `revoked_certificates_signature`.** If present, these two members are the revocation of certificates (Section 10.2): the revocation statement's three lines and the armoured signature over those lines, each in base64. The revocation statement MUST have exactly that form, with the address as its line 2.
- **The members are in any order.** A revocation record that a server serves MUST carry at least one of the two revocations.
- **A reader acts only on what verifies.** A record that parses but is malformed by these rules shows nothing (Section 12.5): for example, a record with no identity, an identity that does not hash to the address, or neither revocation. A record that a reader cannot parse is no record, for example one that names another type or has a byte member that is not base64; a server's answer that carries one is no answer (Section 12.3, check 7).
- **A reader ignores an unknown member of a revocation record, a server among them (Section 3.3).**
- **A revocation record from a file counts the same as one from a server.**
  - A verifier rebuilds the revocation statement of the address from the address.
  - The verifier checks that the revocation of certificates has the form `revocation-of-certificates`, with the address as its line 2.
  - The verifier verifies each signature under the identity document's key.

## 11. The HTTP API

`api/openapi.yaml` gives the shape of every operation below. This section gives the meaning of each operation, and the checks that a server makes.

### 11.1. Transport

- **A client MUST call its server over `https`, with one exception.** The exception is a server on the client's own machine, named by an address in `127.0.0.0/8` or by `[::1]`. A client MAY call such a server over `http`. The name `localhost` is not such an address.
- **A server's URL is a scheme, a host and an optional port.** A client MUST refuse a URL of any other form before the client sends anything: one with user information, a path other than `/`, a query or a fragment among them. A client MUST also refuse an `https` URL with a port of 80.
- **A client MUST send a call to a loopback address, or to `localhost`, without a proxy.**
- **A server's names are the names that the server's operator gives the server.** Each name is written as Section 8 writes a server name.
- **A server SHOULD terminate its own TLS, on hosts its operator runs, with no third party between a client and the server.** Anything that terminates TLS for a server is part of the server (Section 15.8).
- **A client MUST NOT follow a redirect.** No route redirects. So a client treats a `3xx` other than `304` as no answer. A pass and a lookup each name an address, and a client never sends a pass or a lookup anywhere that a server points.
- **Every API path is under `/v1/`.**

### 11.2. Requests and answers

- **Bodies.** Section 3.3 gives the rules for reading a JSON body. A send's body is bytes (Section 11.10).
- **Query parameters.** A server reads a query parameter as it reads a member. On every call but a read of the server's document (Section 11.18), a server MUST refuse, with `400 invalid_request`, a parameter that the call does not accept or a parameter given twice, and name that parameter in `param`. Only these calls accept a query parameter:

  | Call | Parameters |
  |---|---|
  | a send (Section 11.10) | `prekey_sha256` |
  | a list (Section 11.11) | `wait` |

- **`Date`.** Every answer under `/v1/` carries `Date`. The server sets the field by the clock that the server's checks read.
- **No caching.** Every answer of a route under `/v1/` carries `Cache-Control: no-store` (RFC 9111 §5.2.2.5).
- **Compression.** A server MUST NOT compress an answer (Section 15.8).
- **`HEAD`.** A server answers `HEAD` on every route that answers `GET` (RFC 9110 §9.1, §9.3.2).
  - A `HEAD` changes nothing. A `HEAD` spends none of the fetch budget.
  - Section 11.5 gives what a `HEAD` spends.
- **Preconditions.** Preconditions are those of RFC 9110 §13. A server evaluates `If-Match` and `If-None-Match` on every call (§13.1.1, §13.1.2), at the point §13.2.1 gives, in the order §13.2.2 gives. Dromas narrows the preconditions in these ways:
  - **Normal request checks.** A call's normal request checks (§13.2.1) are the match of the call's route and method, the call's pass where the call accepts one, and the read of the call's target. A registration's pass and a renewal's pass are by the signer of the prekey statement that the call brings, or by the identity (Sections 8; 11.7, step 7; 11.9). Therefore every check of that prekey statement is one of the call's normal request checks.
  - **Only a lookup (Section 11.8), a list (Section 11.11) and an ACL (Section 11.14) carry an `ETag`.**
  - **A server answers a false `If-Match` with `412 precondition_failed`, and never with a `2xx` as for a change that appears already applied (§13.1.1).**
  - **A false precondition comes after the refusals from the server's record of the mailbox, and before a `200` from that record** (Sections 11.7, 11.9, 11.15).
  - **A value of `If-Match` or `If-None-Match` matches nothing if the value has any form other than `*` alone or a list of entity-tags.** A list with `*` among its tags is such a form.
  - **No target has a modification date.** No answer carries `Last-Modified`. So a server ignores a condition on a date (§13.1.3, §13.1.4).
  - **A call refused by a false precondition changes nothing.** Section 11.5 gives what the call spends.
- **A mailbox that changes during a call.** A server answers `409 concurrent_modification`, and changes nothing, where the mailbox, or a sending mailbox, changes between a call's checks and the call's read or write, a precondition among those checks.
  - A list, a fetch, a `HEAD` and an ack check the call again first. Where the change ended the call's pass, the server answers the call as it answers a fresh call, such as with `401` or `410`. It answers `409` only where its second read meets a change too.
  - A renewal, an ACL, a revocation, an adopt and a leave answer `409` at once. A send is answered as a fresh send is where its recipient or its sender no longer stands, and `409` otherwise.
  - A registration answers that case in its own way (Section 11.7, step 8), and an ack whose message another call deleted answers `404` (Section 11.13).
- **The first segment under `/v1/`.** A first path segment that begins with an ASCII letter and `_` names an address. `d_` is the one address form (Section 4.2). A server answers `400 invalid_address` to such a segment of another form, and to one that is not an `address`. Any other first segment is a route that the server does not offer. No route of this protocol has a first segment whose second character is `_`.
- **Unknown routes.** A server answers an unknown route with the router's plain `404` or `405`, which has no code. A retired version comes first (Section 11.4, rule 0): the server answers a request under `/v1/` whose version is retired with `410 client_version_unsupported` on every path but the document's, an unknown route included. A server MAY answer a path that is not in its clean form with a redirect to the clean form, ahead of every check of Section 11.4. A path is not in its clean form when the path has a `.` or `..` segment or two `/` in a row, or is `/v1` or `/to` without its last `/`. A client reads that answer as no answer (Section 11.1). The body of that answer may be of any type. Past a limit, the server answers an unknown route `429 rate_limited`, as for any call. A client reads a plain `404` or `405` by the status alone, as a route that the server does not offer. A client reads a `404` with a code as that code, and a `404` with a code the client does not know as a plain `404` (Section 11.3).
- **A server answers `408 request_timeout` to a request whose body does not arrive in time.**
- **A server that cannot complete a request, or is not ready to answer, answers `503 unavailable` with `Retry-After`.** The server sends this answer instead of a wrong answer. A client treats any other `5xx` as the same failure, but with no wait given.

### 11.3. Errors

- **Every error body is RFC 9457 Problem Details (`application/problem+json`), in AEP-193's form, except the router's plain `404` and `405` (Section 11.2), and the HTTP server's own answer to a request whose head it cannot read, such as a `400` or a `431` (RFC 6585 §5).** The members are `type`, `title`, `status`, `detail`, `code` and `hint`, and one more member for each value the error carries. Every value that `detail` names also has a member of its own.
- **`type`.** The value is `tag:dromas.dev,2026-10-26:errors/<code>` (RFC 4151), the same at every server. The tag resolves to nothing.
- **Every `code` is on the closed list that `api/openapi.yaml` gives, under the status that the list gives the code, with the code's own `type`.**
  - A client ignores a code that the client does not know, a code under another status, and a code with another `type`.
  - The client does not act on such a code, and shows none of the code. The client shows only the status.
  - A client treats a body as no answer when a member of the body is not of the member's type (Section 3.3).
- **A client MUST NOT show `detail`, `hint`, `title`, or any other text a server sent (a status line, a header or trailer line, a `Location`).** These texts are the server's words, meant for a person who reads the body.
  - A client states a code's meaning in its own words, with the members it has checked against their types.
  - A client shows a string member only after the client has checked that the member is a value the client knows.
  - When a client cannot read a call's answer, the client names the call by the call's method and path, and never by the call's query.
  - A `hint` names a fix as a client command, never as a shell line.
- **On every answer other than a `2xx`, a client reads `code`, the members, `Retry-After` and `Date`.**
- **A `401` carries `WWW-Authenticate` with the scheme `dromas-pass` (Section 8).**
- **`Retry-After` is delay-seconds, digits alone, on a `429`, on a `503` and on every `200` and `304` of a list (Section 11.11).** A client reads an HTTP-date in `Retry-After` as no wait.
- **A code names how a client handles the error.** Where one call can fail for causes that a client handles differently, each cause has its own code.

This table gives each code's meaning, and how a client acts on the code:

| Status | Code | Meaning |
|---|---|---|
| 400 | `invalid_request` | a request body that is not a JSON text Section 3.3 accepts; a member or query parameter, named in `param`, that is missing, unknown, repeated, or has a value the call does not accept, including a byte member that is not base64 in base64's one encoding (Section 2.2); a send's body whose age header does not parse (Section 11.10, step 4) |
| 400 | `invalid_address` | a first path segment under `/v1/` that begins with an ASCII letter and `_`, and is not an `address` (Sections 4.2, 11.2) |
| 400 | `identity_mismatch` | an identity document that does not hash to the address, or that does not have the form Section 4.1 gives |
| 400 | `unsupported_key_type` | an identity key type that this protocol does not define, or that this server does not register; `key_types` lists the types the server registers |
| 400 | `invalid_key` | an identity key that fails its type's key checks; a prekey statement or certificate that is malformed or badly signed |
| 400 | `invalid_validity_period` | at the server's clock, a certificate that has not yet begun or has ended, or a prekey statement that has ended or ends more than 8 days and an hour ahead. The cause is nearly always the client's clock |
| 400 | `certificate_lifetime_too_long` | a certificate that runs longer than the server's maximum (Section 11.7, step 6); `max_certificate_lifetime_seconds` gives the maximum |
| 400 | `invalid_recipients` | a send's age file that does not have exactly one native stanza of the current prekey's type, or that has anything beside that stanza and the grease stanzas that the server ignores (Section 11.10, step 7) |
| 400 | `invalid_revocation` | a revocation whose signature is not the identity's signature over the revocation's revocation statement (Section 11.15) |
| 401 | `invalid_pass`, `pass_expired`, `certificate_superseded`, `certificate_revoked` | the server refuses the pass; Section 8's table gives when the server answers each code. On `certificate_superseded`, `certificate_serial` names the certificate concerned (Section 8) |
| 403 | `sender_not_registered` | the mailbox that a send's pass names is not registered |
| 403 | `sender_revoked` | the sending mailbox is revoked |
| 403 | `sender_not_allowed` | the recipient's ACL does not admit the sender (Section 11.14). The refusal is final for the message |
| 403 | `unsupported_sender_key_type` | the recipient's client does not verify the sender's identity key type (Section 7); `key_type` names that type |
| 403 | `invalid_adopt_key` | an adopt key that this server did not make, or that is spent, expired or revoked (Section 11.16) |
| 404 | `mailbox_not_found` | the mailbox was never registered, or is forgotten |
| 404 | `message_not_found` | the message is gone: acked or expired |
| 404 | `revocation_not_found` | the server keeps no revocation of the address (Section 11.15) |
| 408 | `request_timeout` | the body did not arrive in time: send the request again |
| 409 | `mailbox_already_exists` | the address is registered with another prekey statement: a registration that is not an identical retry |
| 409 | `serial_too_low` | the server keeps a higher serial: a renewal by the current signer at a prekey serial that is not higher (`prekey_serial` names the prekey serial to exceed); a revocation of certificates through a lower revocation serial than the one the server keeps (`revocation_serial` names the kept revocation serial) |
| 409 | `concurrent_modification` | the mailbox changed during the request, or a precondition that the request carried was no longer true when the request wrote: send the request again unchanged |
| 409 | `prekey_superseded` | a newer prekey exists: look up the mailbox again and seal the same envelope |
| 409 | `prekey_expired` | the recipient's current prekey has ended, or the recipient's current signer is revoked: the recipient's owner must renew (Section 11.10, step 7) |
| 410 | `mailbox_revoked` | the address is revoked permanently; `record` carries the revocation record (Section 10.3), which a client checks (Section 12.5) |
| 410 | `client_version_unsupported` | the server no longer accepts the request's version (Section 11.17); `min_version`, if the server sets a version floor, is the lowest version the server accepts |
| 412 | `precondition_failed` | a precondition was false (Section 11.2) |
| 413 | `content_too_large` | a body or ciphertext over its cap, or an ACL with more entries than the server accepts; `limit` gives the cap |
| 429 | `rate_limited` | the call is past a limit (Section 11.5); the answer carries `subject` and `quota_id`, and `quota_value` for a number a day |
| 429 | `fetch_rate_limited` | the server paces the mailbox's fetches (Section 11.12) |
| 429 | `mailbox_full` | the mailbox stores as many messages as it may. The refusal says nothing of how many messages the mailbox stores |
| 429 | `mailbox_rate_limited` | the mailbox has spent its intake budget for now |
| 503 | `unavailable` | the server is not ready to answer |

Every `429` carries `Retry-After`.

### 11.4. The order of refusals

A server chooses which refusal it answers first, except where this specification fixes the order. The two rules below fix the order for every call, and the section on an operation can fix more. Elsewhere, when a request fails several checks, the server answers the failure it finds first. The client acts on the refusal that arrives. The steps of Sections 11.7 and 11.10 are numbered so that other text can cite them. The numbers do not set the order of the checks.

0. **A retired version comes before everything** (Section 11.17). The server answers a request whose version is retired with `410 client_version_unsupported`. The server reads nothing else of the request, the pass included. The request counts only against the IP address's `requests`.
1. **A mailbox's state comes before any pass.** Before the server judges any pass, the server answers with a mailbox's state:
   - a call gets the state of the mailbox whose pass the call carries;
   - a lookup gets the state of the mailbox it looks up.

   So a mailbox learns its own state, whatever pass its call carries.

   | Call | Answers before any pass |
   |---|---|
   | A call with a mailbox's own pass, other than a registration (Section 11.7) | `404 mailbox_not_found` for an unknown mailbox; `410 mailbox_revoked` for a revoked mailbox; `401 certificate_revoked` where the call accepts a pass by the current certificate, the identity has revoked that certificate, and the pass does not name the identity's key |
   | A send, about its sender | `403 sender_not_registered`, `403 sender_revoked`, `401 certificate_revoked` |
   | A lookup | `404 mailbox_not_found`, or `410 mailbox_revoked` with the address's revocation record |
   | Looking up revocations | `404 revocation_not_found`, or `200` with the revocation record |

### 11.5. Limits

A server chooses what it limits and by how much. No limit's value is part of the protocol, and a server may add limits. A client meets a limit as a `429` answer (RFC 6585 §4) with `Retry-After`. The client waits for the `Retry-After` time and then retries, unless the code says otherwise. Every server keeps these promises:

- **A drain of a full mailbox always completes.** The server may pace the drain's lists and fetches, with each `429` saying when to go on, but never stops them permanently.
- **Only three things spend a mailbox's counts:** a call that carries the mailbox's pass, a message sent to the mailbox, and a revocation of certificates that the mailbox's identity publishes through a higher revocation serial. Only calls from an IP address spend that IP address's counts.
- **A server counts the identity's acts apart from the counts that a working key can spend** (Section 15.5):
  - The server counts a renewal by a signer of higher rank than the current signer apart from a renewal by the current signer (Section 11.9). That renewal spends `certificates` and no `calls`.
  - A renewal made while the current signer is revoked spends none of the mailbox's counts (Section 11.9). That renewal still spends the IP address's `requests`.
  - The server counts a revocation of certificates through a higher revocation serial on a separate quota.
  - The server counts a revocation of the address against no mailbox (Section 11.15).
- **A request that would change nothing is never refused by a count of what the request would make new:**
  - a registration of a mailbox the server keeps (Section 11.7, step 5);
  - an identical retry of a renewal (Section 11.9);
  - a revocation the server already keeps (Section 11.15);
  - a send of a ciphertext that the recipient stores (Section 11.10, step 6).

  Only the budgets that bound any call may defer such a request with a `429`. These budgets count calls, never what a call would make new, because the server can spend them before the server can tell that the request changes nothing. Examples are the IP address's `requests`, `misses` and `sends_before_pass`, and the mailbox's `calls`.

**Who a call is counted against.** Here, an **IP address** is the IPv4 address or the IPv6 /64 that a call comes from. No caller is exempt.

| Call | Counted against |
|---|---|
| A call with a mailbox's pass | that mailbox |
| A call with no pass | the call's IP address; a server MAY also count by a wider range |
| A lookup, whatever it carries | the call's IP address |
| A check that fails, or a call that names no mailbox | the call's IP address |

The `subject` column of the table below gives the exceptions. A registration is counted against the IP address, and a revocation of certificates through a higher revocation serial is counted against the mailbox.

**How a refusal names its limit.**

- A limit that has no code of its own refuses a call with `429 rate_limited`. The limits that have codes of their own are `fetch_rate_limited`, `mailbox_rate_limited` and `mailbox_full`. In the refusal, `subject` says whom the call was counted against (`mailbox` or `ip`), and `quota_id` says which limit.
- `Retry-After` is no earlier than the time when the limit that the refusal names lets the same call through (RFC 8555 §6.6). Another limit can still refuse the call once the `Retry-After` time has passed.
- The server checks a send's `sends` only after the send's dedupe. So when a send is past the sender's `calls`, the refusal gives the wait for `calls`.
- **A number a day.** A quota of a number a day is a budget of that many for each mailbox. The server refills the budget over the day. `quota_value` gives the number.

| `quota_id` | `subject` | Counts |
|---|---|---|
| `polls` | `mailbox` | the mailbox's polls (Section 11.11), including polls answered `304` or `412` |
| `calls` | `mailbox` | the mailbox's other calls that carry the mailbox's pass, including a send, a renewal by the current signer and an identical retry of the mailbox's registration or renewal |
| `sends` | `mailbox` | the mailbox's sends, a number a day, counted only for sends that carried the mailbox's pass |
| `renewals` | `mailbox` | the mailbox's renewals by the current signer, a number a day |
| `certificates` | `mailbox` | the mailbox's renewals by a signer of higher rank than the current signer, a number a day, except a renewal made while the current signer is revoked |
| `certificate_revocations` | `mailbox` | each revocation of certificates that the mailbox's identity publishes through a higher revocation serial, a number a day |
| `registrations` | `ip` | registrations from an IPv4 address or IPv6 /64, and each call that a server counts as a registration (Section 11.15) |
| `registrations_range` | `ip` | the same, from an IPv6 /48 |
| `misses` | `ip` | calls whose lookup or read found no mailbox, or whose `Authorization` value or prekey statement cannot be read |
| `misses_range` | `ip` | the same, from an IPv6 /48 |
| `sends_before_pass` | `ip` | sends, counted before the server reads their pass |
| `sends_before_pass_range` | `ip` | the same, from an IPv6 /48 |
| `requests` | `ip` | the IP address's requests, which a server MAY leave uncounted when the request carries a pass that the server has already verified; registrations, renewals and requests that match no route are counted |
| `requests_range` | `ip` | the same, from an IPv6 /48 |

A quota counted against `ip` counts an IPv4 address by itself and an IPv6 address by its /64. Each quota ending in `_range` counts the same calls by their IPv6 /48 as well, beside the quota of the row above it; an IPv4 address has no /48 count. A call is refused when either count is spent, and the refusal names the count that sets its `Retry-After`.

A fetch and an ack of a message the mailbox holds spend no `calls`, and Section 11.12 gives a fetch's own budgets.

**What a `HEAD` and a false precondition spend.** A list's `HEAD`, and a list refused by a false precondition, spend `polls`. Any other `HEAD` that carries the mailbox's pass, and any other call with that pass refused by a false precondition, spend `calls`.

For a server's limit that is not one of these, the refusal has no `quota_id`.

### 11.6. Mailbox states

At a server, a mailbox is in one of three states:

- **unknown:** the server keeps no mailbox at the address. Either the mailbox was never registered, or the server has forgotten the mailbox (below).
- **active:** registered and in use.
- **revoked:** the mailbox's identity has revoked the address permanently (Section 10.1).

This table gives the answer to each call in each state, for a call that the call's own section accepts. That section gives the call's other refusals.

| Call | unknown | active | revoked |
|---|---|---|---|
| Register, `PUT /v1/<A>` | `201`; the mailbox is now active | an identical retry → `200`; any other registration → `409 mailbox_already_exists` | `410 mailbox_revoked` |
| Renew, `PUT /v1/<A>/prekey` | `404 mailbox_not_found` | `200` | `410 mailbox_revoked` |
| Any other call with the mailbox's own pass (list, fetch, ack, the ACL, joining or leaving an account: Sections 11.11 to 11.14, 11.16) | `404 mailbox_not_found` | answered as the call's section says | `410 mailbox_revoked` |
| Publish a revocation of the address, `PUT /v1/<A>/revocation` | `201`; the server keeps the revocation, and the address is now revoked | `201`; the address is now revoked, and the server deletes the mailbox's messages | `410 mailbox_revoked`, with the revocation record |
| Publish a revocation of certificates, the same route | `200`; the server keeps the revocation, and the address stays unknown | `200` | `410 mailbox_revoked`, with the revocation record |

- **A send.** The server answers the sender's state with `403 sender_not_registered` or `403 sender_revoked` (Section 11.10, step 1). The server answers the recipient's state as the table does.
- **There is no `DELETE` of a mailbox.** A mailbox leaves a server in one of two ways: the mailbox's identity revokes the address permanently, or the mailbox stops renewing and is forgotten. To stop accepting messages for a while, a mailbox sets its ACL (Section 11.14).
- **Forgotten.** Section 13 gives the date until which a server keeps a mailbox. Past that date, a server may forget a mailbox that has stopped renewing. A forgotten mailbox is unknown. The mailbox comes back by registering anew, without its ACL or its account. The server still keeps the revocations that the mailbox's identity made.
- **There is no pending state.** A registration carries a pass that is minutes old, so a mailbox is active from its first call.
- **A repeated request.** The server answers three kinds of repeat from the server's current record:
  - an identical retry (Section 2.3) gets `200`, as Sections 11.7 and 11.9 say;
  - a revocation that the server already keeps gets the answer that Section 11.15 gives;
  - a send of a ciphertext that the recipient already stores gets the answer that Section 11.10, step 6, gives.

  The server answers any other request as the section of that request's call says, even when the request is a copy of one that the server has applied.

### 11.7. Register

A registration, `PUT /v1/<A>`, carries `identity`, `prekey` and `prekey_signature` (the exact bytes of each, in base64). The registration also carries `sender_key_types` if the mailbox declares any. The registration carries a pass by the signer of that prekey statement. The mailbox is in use at once.

The server checks:

1. The address in the path is an `address` (Section 4.2) → otherwise `invalid_address`.
2. The body has exactly those members → otherwise `invalid_request`, naming the member.
3. `identity` hashes to the address and has the form of an identity document (Section 4.1) → otherwise `identity_mismatch`.
4. **The key's type and the key:**

   | Check | Otherwise |
   |---|---|
   | the type is one this protocol defines | `unsupported_key_type` |
   | the key is in its one encoding | `identity_mismatch` |
   | the key meets its type's key checks | `invalid_key` |

   A server registers `ssh-ed25519` and any other defined types that its operator chooses. The server answers every other type `unsupported_key_type`, with the list of types the server registers.
5. **A registration never changes a registered mailbox.** When the server keeps the mailbox, the server answers the registration from the server's record of the mailbox, once steps 1 to 4 are met. The table below gives the answer. This answer comes ahead of every other refusal of this call. This answer also comes ahead of every count except the budgets that bound any call (Section 11.5).

   | The server holds | The request | Answer |
   |---|---|---|
   | an active mailbox | an identical retry | `200 {}` once the request's pass (step 7) is verified and the request's preconditions are true (Section 11.2), or `401 certificate_revoked` if the identity has revoked the certificate of that prekey statement |
   | an active mailbox | anything else | `409 mailbox_already_exists` |
   | a revoked address, with a mailbox or none | any | `410 mailbox_revoked`, with the address's revocation record |

   The server counts any other registration against the registration's IP address (Section 11.5, `registrations`).
6. **The prekey statement and its signer.** Each of these is true:
   - the prekey statement has the form of Section 6;
   - line 2 is the address;
   - line 3 is the rank of the signer;
   - line 5 is a valid age recipient of the prekey type, whose X25519 half is not of small order;
   - the signer is that identity, or a certificate of that identity that meets every rule of Section 5.2;
   - the namespace is `dromas-prekey-v1:<A>`;
   - the prekey statement's `not_after` is after now and at most 8 days and an hour after now.

   Otherwise the server answers `invalid_key`, or `invalid_validity_period` where the check that fails is the certificate's time or the prekey statement's `not_after`.

   The server also refuses:
   - a certificate that runs longer than the server's maximum (Section 11.18), measured as `valid before` less `valid after`, unless the certificate is the current certificate → `400 certificate_lifetime_too_long`;
   - a certificate that the identity revoked, according to the revocations the server keeps for the address (Section 5.1) → `401 certificate_revoked`.
7. **The pass.** The pass (Section 8) is this mailbox's, is for this server, has not ended, and is by the identity or by the signer of step 6 → otherwise a `401` (Section 15.5).
8. **A new mailbox.** The server stores the new mailbox as `active` → `201 {}`. If another request has registered the mailbox meanwhile, the server answers this registration as step 5 does.
9. **The server keeps the prekey statement's signer as the current signer.** That signer is the identity, or a certificate. For a certificate, the server keeps the certificate serial as well. Section 8 gives which passes the server then accepts, and Section 11.9 gives which later prekey statements the server accepts.

### 11.8. Look up a mailbox

A lookup, `GET /v1/<A>`, accepts no pass (Section 8). The lookup answers with the information a sender needs before posting, and with the information a mailbox checks about itself (Sections 12.4, 12.5).

- **An active mailbox.** The server answers `200` with `identity`, `prekey` and `prekey_signature`. The answer also carries `sender_key_types` if the mailbox declared any. If the server keeps a revocation of the mailbox's certificates, the answer also carries `revoked_certificates` with `revoked_certificates_signature`.
- **An unknown address.** The server answers `404 mailbox_not_found`, whatever certificates the address's identity has revoked. Looking up revocations serves those revocations (Section 11.15).
- **A revoked address.** The server answers `410 mailbox_revoked`, with the revocation record in `record`.
- **A lookup is public.** A client sends no pass on a lookup. The server counts a lookup as Section 11.5 says.
- **The `ETag`.** A `200` carries a weak `ETag` (RFC 9110 §8.8.1, §8.8.3). The tag changes whenever the answer's content changes. A lookup whose `If-None-Match` names the tag is answered `304`, with the tag and no content (Section 11.2). A `304` spends what a lookup spends (Section 11.5). A server answers a lookup that would be `404` or `410` as without the condition.

### 11.9. Renew the prekey

A renewal, `PUT /v1/<A>/prekey`, carries `prekey` and `prekey_signature`, and `sender_key_types` if the mailbox declares any. The renewal carries a pass by the signer of that prekey statement or by the identity.

The server accepts a renewal because the renewal's prekey statement is later than the current statement, and is signed by the identity or by a working key that the identity certified. The renewal needs no pass by the current signer. So a mailbox that lost its working key comes back by renewing under a new certificate. A mailbox also moves to a new certificate, its first included, by renewing.

- **An identical retry.** The server answers an identical retry from the server's record of the mailbox. This answer comes ahead of every check below, and ahead of every count except the budgets that bound any call (Section 11.5). The answer is `200 {}` once the retry's pass is verified and the retry's preconditions are true (Section 11.2), or `401 certificate_revoked` while the current signer is revoked.
- **Any other prekey statement.** The server verifies any other prekey statement as at registration (Section 11.7, steps 6 and 7). The prekey statement MUST be later than the current statement by `(c, p)` (Section 5.3). That is, the prekey statement is signed by a signer of higher rank at any prekey serial, or by the current signer at a higher prekey serial. Otherwise:

  | The new prekey statement is signed | Answer |
  |---|---|
  | by the current signer, at a prekey serial that is not higher | `409 serial_too_low`; `prekey_serial` names the prekey serial that the new prekey statement must exceed |
  | by a signer of lower rank, or by another certificate with the current certificate's serial | `401 certificate_superseded`; where the new prekey statement must be above a certificate, `certificate_serial` names that certificate's certificate serial |
  | under a certificate the identity revoked | `401 certificate_revoked` |

- **On success:**
  - The new prekey becomes the current prekey, and the new prekey statement's signer becomes the current signer. So the server no longer accepts a pass by a certificate that the renewal replaced (Section 8).
  - The renewal's declaration (Section 7) is the mailbox's declaration from then on.
  - The server answers `200 {}`.
- **Counting.** Section 11.5 gives how the server counts a renewal (`renewals`, `certificates`). An identical retry spends neither quota. The server answers a renewal past either quota with `429 rate_limited`, naming that quota.
- **A forgotten mailbox.** The server answers a renewal of a mailbox it has forgotten with `404 mailbox_not_found` (Section 12.4).

### 11.10. Send

A send, `POST /v1/<B>/messages?prekey_sha256=<hash>`, carries the sender's pass. The send's body is the age file's exact bytes (`Content-Type: application/vnd.age`, age's registered media type). The server answers the send `201` with `id`, `received_at` and `expires_at`, and `Location: /v1/<B>/messages/<id>`. The sender is the mailbox that the pass names.

`prekey_sha256` is REQUIRED. `prekey_sha256` names the prekey statement that the age file is sealed to, as `statement-hash`: the SHA-256 of the prekey statement's bytes as the lookup of `B` served them (Section 11.8). The hash covers the prekey statement alone, never the prekey statement's signature. Another encoding of the same signature (Section 3.2) does not change the hash.

```abnf
statement-hash = 64lowhexdig
```

- **The message id.** The message id in `id` and `Location` is the SHA-256 of the age file's bytes, written as `message-id`. The message id names the message in Sections 11.11 to 11.13.

  ```abnf
  message-id = 64lowhexdig
  ```

- **A server reads the body as bytes, whatever the `Content-Type` says.**
- **A ciphertext is at most 16 MiB (16,777,216 bytes).** Every cap that a server sets on a ciphertext, including an account's caps, is at most 16 MiB. Every reader accepts a ciphertext of any size up to 16 MiB, so every reader reads any message that any server accepts. A larger ciphertext needs a new version of the protocol.
- **The server checks no signature on a message, because there is none for the server to see.** The server checks the sender against the pass alone.

The server checks the steps below. Only step 9 stores anything.

1. **Who is sending.** The server reads the pass (Section 8) for the mailbox that the pass names. The server checks, in this order:
   1. the IP address's `sends_before_pass`;
   2. the mailbox that the pass names: unknown → `403 sender_not_registered`; revoked → `403 sender_revoked`;
   3. the pass's own refusals, and the sender's `calls` (Section 11.5). Every send spends `calls`, including a send of a ciphertext that `B` already stores (step 6).
2. **The path and the query.** `<B>` is an address → otherwise `invalid_address`. `prekey_sha256` is given once, as `statement-hash`, and no other parameter is given → otherwise `invalid_request`, naming the parameter.
3. **The body's size.** The body is at most the sender's cap → otherwise `413 content_too_large`, with the cap in `limit`. The server refuses by the `Content-Length` before it reads anything, or while it reads.
4. **The age header.** The body begins with an age header that parses (C2SP age) → otherwise `invalid_request`, with no `param`. An empty body gets the same refusal.
5. **`B` is active:** unknown → `404 mailbox_not_found`; revoked → `410 mailbox_revoked`.
6. **Dedupe, while the message is live.** The server evaluates the send's preconditions before this step (Section 11.2). The message id is the ciphertext's SHA-256. If `B` stores an unacked message with that message id, from any sender, the server answers `200` with the receipt it kept, whatever has changed at `B` since. This answer comes ahead of steps 7 to 9, and ahead of every count except the budgets that bound any call (Section 11.5). The server keeps nothing of a message once the message is gone. So the same bytes sent after that are a new message, which the server stores and counts as any send. A reader that accepted those bytes once skips or refuses them (Section 12.3, check 8).
7. **`B` accepts messages on this prekey, from this sender:**

   | Failure | Answer |
   |---|---|
   | `B`'s current prekey is past its `not_after`, or the current signer is one `B`'s identity has revoked | `409 prekey_expired` |
   | The sender's identity key is of an optional type (Section 4.1) that `B` did not declare (Section 7) | `403 unsupported_sender_key_type` |
   | `prekey_sha256` is not the hash of `B`'s current statement | `409 prekey_superseded` |
   | The age file does not have **exactly one native stanza** (`mlkem768x25519`) of the current prekey's type, or has anything beside that stanza and the grease stanzas that the server ignores | `invalid_recipients` |

   The server ignores a stanza whose type matches `^[!-~]{1,8}-grease$` and that has at most 4 arguments, as age has a reader ignore a stanza that the reader does not recognize. Only the message cap bounds the body of such a stanza. The server cannot check which key the file is sealed to.
8. **Quotas, counted only for sends that carried their sender's pass:**

   | Failure | Answer |
   |---|---|
   | `B`'s ACL does not admit the sender | `403 sender_not_allowed`, with one code and one wording whether the sender is denied or only not allowed |
   | The sender has spent its `sends` | `429 rate_limited` |
   | `B` stores as many messages as its cap | `429 mailbox_full`, with a `Retry-After` of the poll interval |
   | `B` has spent its intake budget | `429 mailbox_rate_limited`, with a `Retry-After` of the time until `B` accepts another message |

   A send of a ciphertext that `B` already stores (step 6) spends none of the intake budget.
9. **Store the message.** The server stores the message (Section 13) → `201`. If a concurrent send of the same ciphertext is stored first, the server answers this send as step 6 does. Any other failure → `503 unavailable`. The sender then posts the message again from its outbox.

### 11.11. List

`GET /v1/<B>/messages` carries the mailbox's pass → `200` with `total_count` and `messages`, and `Retry-After`.

- **`total_count`:** the number of live messages in the mailbox. For an empty mailbox, the answer is `{"total_count":0,"messages":[]}`.
- **`messages`:** one page of list entries, the mailbox's oldest, oldest first by `received_at`. Each list entry has the message id in `id`, `size` (the length of the message's ciphertext, Section 11.10), `received_at` and `expires_at`. A list entry has nothing about the sender.
- **On every `200` and `304` of a list, `Retry-After` is the server's poll interval, in seconds.**
- **A list carries an `ETag`.** The `ETag` is a strong validator of the page's body. The `ETag` changes whenever a message enters or leaves the page or the count.
- **A mailbox that polls faster than its `polls` budget gets `429`, never `304`** (Section 11.5).
- **The server checks:**

  | Check | Otherwise |
  |---|---|
  | `<B>` is an address | `400 invalid_address` |
  | the only parameter is `wait`, at most once | `400 invalid_request`, naming the parameter |
  | `wait` is delay-seconds, digits alone | `400 invalid_request`, naming `wait` |

- **A list MAY be a long poll:**
  - A list MAY carry `wait`, a number of seconds.
  - Where such a list's `If-None-Match` would make the answer `304`, the server waits to answer.
  - When the page's tag no longer matches the `If-None-Match`, the server answers the page as it answers any list.
  - When the wait has passed, the server answers the `304`.
  - A server MAY hold a wait past a message's expiry; the answer at the wait's end is the page as it then stands, the expired message gone from it.
  - A server makes a long poll wait at most a time that the server chooses. That time is not part of the protocol.
  - The server MAY answer the `304` sooner. The server answers the `304` at once when it stops serving.
  - The server answers a list at once if the list's `If-None-Match` would not make the answer `304`, or if the list's `wait` is `0`.
  - The server counts a long poll as one poll, when the long poll arrives (Section 11.5).
- **Lists are eventually consistent.** For a moment, a list may show a just-acked message, or miss a just-stored one.

### 11.12. Fetch

`GET /v1/<B>/messages/<id>` carries the mailbox's pass → `200`, `application/vnd.age`, the exact bytes of the ciphertext with a `Content-Length`, and nothing else. A message that is gone → `404 message_not_found`.

- **Ranges.** Range requests follow RFC 9110 §14. A server honours only one form, `range-asked`: one open-ended range whose `N` is below the ciphertext's length. The server answers that range `206 Partial Content`, with the bytes from `N` to the end, and with `Content-Range` as `content-range-206`.
- **A server ignores every other `Range` (§14.2).** The server answers such a fetch with the whole body, `200`.

  ```abnf
  range-asked       = "bytes=" 1*DIGIT "-"
  content-range-206 = "bytes" SP range-number "-" range-number "/" range-number
  range-number      = "0" / %x31-39 *DIGIT   ; no leading zero
  ```

- **A fetch carries no validator.** So an `If-Range` is false (§13.1.5), and the server ignores the `Range` that comes with the `If-Range`. The bytes under a message id never change, because the message id is the ciphertext's SHA-256.
- **Counting.** Every fetch spends the mailbox's fetch budget, a ranged fetch and a fetch of a message fetched before among them. Past it → `429 fetch_rate_limited`.

- **The API serves bodies itself, never through a redirect.**

### 11.13. Ack

`DELETE /v1/<B>/messages/<id>` carries the mailbox's pass → `204`. The ack deletes the message. The server keeps nothing of the deleted message (Section 11.10, step 6). A message that is gone → `404 message_not_found`. Reading a message does not delete the message.

- **An ack whose message another call deletes first answers `404 message_not_found`, never `409`.**

### 11.14. ACL

A mailbox's ACL says from which senders the mailbox's server accepts messages to the mailbox.

- **Semantics.** A mailbox with no ACL accepts messages from everyone. For a mailbox with an ACL, the server checks `deny` first, then `allow`. The server refuses a sender that neither list matches, with `403 sender_not_allowed`.
- **Set the ACL: `PUT /v1/<B>/acl`.** The call carries the mailbox's pass, and replaces the whole ACL with `allow` and `deny`.
  - Each ACL entry is an address, or `*`, which matches every address. An ACL entry has the form `acl-entry`. There is no other pattern. A repeated entry is read as one entry.

    ```abnf
    acl-entry = "*" / address
    ```

  - `allow` is REQUIRED. In `allow`, `["*"]` matches everyone and `[]` matches nobody. A document without `allow` → `400 invalid_request`.
  - `deny` may be left out, which is the same as an empty `deny`.
  - An ACL with more entries than the server accepts, in both lists together → `413 content_too_large`. The server counts entries as sent, before a repeated entry is read as one entry. A server MUST NOT accept more than 10,000 entries, and MAY accept fewer.
  - The answer is `200` with the ACL as stored, and no `ETag`. The answer lists `*` first, then each address once, in ascending order of the addresses' 48 bytes (not of their text: base64url's alphabet is not in ASCII order, so the two orders differ).
- **Get the ACL: `GET /v1/<B>/acl`.** The call carries the mailbox's pass. The server answers the ACL as stored, in that order, with the ACL's `ETag`. That `ETag` is a strong validator that changes whenever the lists change. For a mailbox with no ACL, the server answers `{"allow":["*"],"deny":[]}`, also with a tag. There is no `DELETE` of the ACL.
- **A `PUT` MAY carry `If-Match` (RFC 9110 §13.1.1), so that the `PUT` replaces only the ACL its writer read.**
- **Every mailbox has an ACL and the ACL's tag, a mailbox with no ACL set included.** Therefore `If-None-Match: *` on a `PUT` is false (§13.1.2).
- **Setting the ACL deletes no message.** A change to the ACL refuses only later sends. A send that passed the ACL check while the ACL changed may still be stored after the change.
- **The ACL `{"allow":[],"deny":["*"]}` refuses every sender.**
- **The ACL is not signed.** Only the mailbox gets its ACL. Only the server acts on the ACL.

### 11.15. Revocations

The two calls in this section accept no pass (Section 8).

- **Publish a revocation: `PUT /v1/<A>/revocation`.** The call's body is a revocation record (Section 10.3). The server verifies the revocation record as a client does. The server permanently keeps a revocation of the address that verifies, and the highest revocation of certificates that verifies, whether or not a mailbox is at the address (Section 10). This section gives the exceptions.
  - **The server answers a revocation it already keeps from its stored revocations.** For an address that the server keeps revoked, that answer comes ahead of every other refusal of this call. For any other address, that answer comes after `400 identity_mismatch` and ahead of every other refusal. Either answer comes ahead of every count except the budgets that bound any call (Section 11.5). A `200` comes only when the request's preconditions are true (Section 11.2). Two kinds of body count as a revocation the server already keeps:
    - any body for an address the server keeps revoked;
    - a body that carries only a revocation of certificates, through a revocation serial no higher than the one the server keeps, whether or not that revocation verifies.

  | The body carries | Answer |
  |---|---|
  | a revocation of the address that verifies | `201 {}`. A mailbox at the address is revoked permanently. The server deletes the mailbox's messages and everything else that the server holds of the mailbox, except what Section 13 keeps of a revoked address |
  | a revocation of certificates, through a revocation serial no lower than the one kept, if one is kept | `200 {}` |
  | a revocation of certificates through a lower revocation serial than the one kept | `409 serial_too_low` (RFC 9110 §9.3.4), with `revocation_serial` naming the revocation serial kept |
  | anything, for an address already revoked | `410 mailbox_revoked`, with the address's revocation record |
  | an identity document that does not hash to the address | `400 identity_mismatch` |
  | no revocation of either kind | `400 invalid_request` |
  | a revocation of the address that does not verify, or a revocation of certificates that does not verify with no revocation of the address beside it | `400 invalid_revocation` |

  **A body that carries a revocation of the address:**
  - The server keeps a revocation of the address that verifies, and answers `201`, whatever is beside that revocation.
  - The server answers a revocation of the address that does not verify with `400 invalid_revocation`. The server keeps nothing in that body, even a revocation of certificates that verifies.
  - A revocation of certificates beside a revocation of the address that verifies spends no `certificate_revocations`, so that count cannot defer the body.

  **A revocation of the address is counted against no mailbox.** The server counts the revocation against the caller's IP address. For an address that the server keeps nothing of, the server MAY count a revocation of either kind as a registration (`registrations`).

  **A revocation record kept for an address with no mailbox binds a later registration.** While the address is revoked, the server answers that registration `410 mailbox_revoked`. While the server keeps only a revocation of the address's certificates, the server answers a registration under a certificate that the revocation covers `401 certificate_revoked` (Section 8).
- **Look up revocations: `GET /v1/<A>/revocation`.** The server answers `200` with the revocation record it keeps for the address, whether or not a mailbox is there. Otherwise the server answers `404 revocation_not_found`.

### 11.16. Accounts

A mailbox may belong to one account at its server. The protocol fixes how a mailbox joins and leaves an account. The server decides what an account does, within the promises of Section 11.5. A server without accounts does not offer these routes.

- **Join: `PUT /v1/<A>/account`.** The call carries the mailbox's pass and `key`, an adopt key. The server answers `200` with `account`, the account id. A join spends one use of the adopt key. A mailbox already in the account that the key names gets `200` and spends no use, whatever state the key is in, and whether or not the server still has the key. A mailbox that is in another account moves to the account it joins.
- **Leave: `DELETE /v1/<A>/account`.** The call carries the mailbox's pass. The server answers `204`, whether or not the mailbox is in an account. An account can also drop a mailbox from its side.
- **Joining or leaving changes nothing about the mailbox's messages.**
- **Adopt key.** An adopt key is `dra1_` followed by base64url without padding (RFC 4648 §5) of one byte or more. An adopt key is at most 1,024 bytes in all, and has the form `adopt-key`. The server decides what an adopt key encodes.

  ```abnf
  adopt-key      = %s"dra1_" ( 1*254( 4base64url-char ) [ 2base64url-char / 3base64url-char ]
                           / 2base64url-char / 3base64url-char )   ; at most 1,024 bytes
  base64url-char = ALPHA / DIGIT / "-" / "_"
  ```

  - A client requires an adopt key to match that form, and reads nothing else of the key.
  - An adopt key that this server did not make, or that is spent, expired or revoked → `403 invalid_adopt_key`, unless the mailbox is already in the account that the key names.
- **Account id.** An account id has the form `account-id`.

  ```abnf
  account-id = 1*32( %x61-7A / DIGIT / "-" )
  ```

- **An account's caps on a ciphertext are within the caps of Section 11.10.**

### 11.17. Versions

- **Every request names the version of the protocol that the client implements, in `Dromas-Version`.** The value has the form `policy-version`: a major and a minor. A major of `0` marks a version before version 1 is declared. The client's own release goes in `User-Agent` (RFC 9110 §10.1.5), outside the protocol.

  ```abnf
  policy-version = version-number "." version-number
  version-number = "0" / %x31-39 *DIGIT
  ```

  - The server reads the `policy-version` that the value begins with, when the value's end or a character other than a digit follows it, and ignores whatever follows: `0.6.11-rc.1` reads as `0.6`, and `1.05` begins with no `policy-version`.
  - The server reads a request without the field, or with a value that does not begin with a `policy-version`, as version `0.0`.
- **A server sets its own version policy.** The policy has four parts:
  - a **version floor**;
  - the server's **deprecations**: the versions that the server deems deprecated from a date;
  - the server's **sunsets**: the versions that the server has scheduled to stop accepting;
  - the **latest version** the server names, if the server names one.

  A version in the policy has the form `policy-version`. Versions are ordered by major, then minor.

  - A deprecation or a sunset is a date and one of:
    - `below` a version, which covers every version before that version;
    - `version` a version, which covers that version.

  A server MUST NOT set a policy under which an answer's `Sunset` would be earlier than its `Deprecation` (RFC 9745 §4).
- **`Deprecation`.** An answer under `/v1/` carries `Deprecation` (RFC 9745 §2.1) when a deprecation covers the request's version. The field's date is the earliest date among the deprecations that cover the version.
  - The field's scope is the version that the request names, on every route under `/v1/`. That scope is wider than the resource that RFC 9745 §2.2 gives the field by default.
  - Only those answers carry `Deprecation`.
  - No answer carries a `deprecation` link (RFC 9745 §3), because a URL is a server's text, and a client never shows a server's text (Section 11.3).
- **`Sunset`.** An answer under `/v1/` carries `Sunset` (RFC 8594 §3) when a sunset covers the request's version. `Sunset` has the same scope as `Deprecation`. The field's date is the earliest date among the sunsets that cover the version. Only those answers carry `Sunset`.
- **A retired version.** The server answers `410 client_version_unsupported` to a request whose version is below the version floor, or is covered by a sunset whose date has passed at the server's clock. Where the server sets a version floor, the answer carries `min_version`. Section 11.4, rule 0, places this refusal first. The server accepts a request for the server's document at every version.
- **A client may read `Deprecation` and `Sunset` on any answer, and reads nothing more of them.** A `Deprecation` value in a form other than RFC 9745 §2.1's counts as absent, and so does a `Sunset` value in a form other than RFC 8594 §3's. A client shows neither field as the server's words (Section 11.3).
- **A client chooses how often the client gets the server's document (Section 11.18).**
- **A client compares `latest_version` with the version of the protocol that the client implements.**

### 11.18. The server's document

`GET /v1/` accepts no pass. The server answers with its version policy and the capabilities it serves, the same to every caller:

- **`min_version`:** the version floor, when the server sets one.
- **`latest_version`:** the latest version the server names, when the server names one.
- **`deprecations`:** the list of deprecations. Each entry has `below` or `version`, and has `effective_at`, the deprecation's date as a time (Section 2.2).
- **`sunsets`:** the list of scheduled sunsets, each written the same way. A sunset whose date has passed stays in the list until the server raises the version floor past that sunset.
- **`max_certificate_lifetime_seconds`:** the server's maximum, in seconds (Section 11.7, step 6). The server's maximum is the longest that a certificate the server accepts may run, measured as `valid before` less `valid after`. The server's maximum is more than the TTL and an hour, and at most the protocol's maximum (Section 5.2). A client makes no certificate longer than the protocol's maximum, whatever `max_certificate_lifetime_seconds` says.
- **`capabilities`:** the list of the capabilities of version 1 that the server serves, each by `name`. A capability name has the form `capability-name`, and is defined in this section. A client ignores a name it does not know. A client uses a capability only if the server lists that capability. This version defines no capability.

  ```abnf
  capability-name = %x61-7A *63( %x61-7A / DIGIT / "_" )
  ```
- **`server`:** the implementation that answers, when the server names one: `name`, `version`, and `revision`, the source revision the implementation was built from, where its build records one. Each is a string of `implementation-text`. The member is informational: it is what the server says it runs, for a reader to check against that implementation's releases. A hostile server can name anything, so nothing a client checks rests on this member (Section 15), and a client MUST NOT change how it speaks the protocol because of it. `min_version`, the deprecations, the sunsets and `capabilities` say that.

  ```abnf
  implementation-text = 1*128%x21-7E
  ```

A server lists at most 64 deprecations, 64 sunsets, and 64 capabilities. A client reads only the members it uses.

## 12. Clients

### 12.1. Keys and the clock

- **A client MUST NOT derive a prekey from a seed.** Forward secrecy rests on the deletion of each retired prekey (Section 15.3), and whoever holds a seed can make every prekey again.
- **A client MUST NOT adopt a server's `Date` as the client's clock.** A mailbox checks everything against its own clock (Section 15.7).
- **A client uses a key that decrypts messages on the messages the client fetches (Section 12.3), and on nothing else a server sends.**

### 12.2. Sending

**A sender looks up the recipient before every post, whether the message is new or has waited (Section 11.8).** Before the sender seals anything, the sender MUST check the lookup's answer:

- **Identity:** the pinned identity or, at first contact, the served identity.
  - The served identity document MUST hash to the address and meet Section 4.1, checked as a server checks an identity document at registration.
  - The client refuses a served identity document of a key type that the client does not verify, and seals nothing.
  - The client pins the served identity only after something that identity signed has verified, which is the served prekey statement or a revocation. A later lookup never replaces the pin.
- **The prekey statement:**
  - the signature verifies by Section 5.4, with that identity's document as the input;
  - the prekey statement meets every rule of Section 6:
    - the form and namespace;
    - line 2 the recipient's address;
    - line 3 the rank of the signer;
    - the key;
    - the `not_after` not passed;
    - the prekey statement not earlier than any prekey statement the sender has seen (Section 5.3).

  The sender records the prekey statement's `(c, p)` once the statement's signature, form, namespace, address and rank have checked, and no revocation that the sender keeps covers its signer. The statement must also be not earlier than any the sender has seen. The sender records the value whatever the key's type, the `not_after`, and whether the recipient's client verifies the sender's key type (Section 7) then find.
- **Revocations:**
  - The sender verifies any revocation of the recipient's address or certificates that the lookup carries, and keeps each one that verifies (Section 12.5).
  - The sender posts nothing to an address if the sender keeps a revocation of that address, and makes no call about that address.
  - The sender refuses a prekey statement under a certificate that the recipient's revocation of certificates covers, and seals nothing. The revocation of certificates that counts here is the one the sender keeps at that point (Section 5.1).
- **No answer is not "no revocation shown."** If the lookup fails, or serves no mailbox (`404 mailbox_not_found`, or `410 mailbox_revoked` with nothing that verifies), the sender seals nothing and posts nothing.
- **A conditional lookup.** A sender MAY keep the last `200` of a lookup whose checks passed, with the answer's `ETag`, and send that tag in the next lookup's `If-None-Match`.
  - On a `304`, the sender checks the kept answer as this section checks a lookup's answer, every preceding check made again at that time.
  - A `304` whose `ETag`, compared weakly, is not the tag that the lookup sent is no answer.
  - A `304` to a lookup that sent no `If-None-Match` is malformed.
  - After a `409 prekey_superseded`, the sender's next lookup of that address sends no `If-None-Match`.

**The outbox:**

- **Every post of an outbox entry carries the same envelope, never a new message (Section 15.9).** Every member of the envelope is as written, except `sent_at`.
- **The sender seals each post anew, after the lookup before that post:**
  - the post's `sent_at` is the sender's clock at the time of sealing;
  - the post's signature is by the signer the mailbox signs messages under (Sections 9.2, 12.7);
  - the post is sealed to the prekey that the lookup served.
- **A sender dates every copy of a message at most the TTL after the first copy.**

**A message to a group:**

- **The sender sends the message to each member of the group but itself.** Each member's message is an outbox entry of its own, with `to` naming that member, and each post of it is sealed to that member's prekey after that member's lookup.
- **Every member's message carries the same `msg_id`, the same `group` and the same `body`.** A reply to every member is a message to the same group.
- **The sender writes every member's outbox entry before the sender posts any of them.** Each entry waits, and its TTL counts, on its own.

### 12.3. Receiving

A client drains its mailbox: it lists (Section 11.11), fetches the message of each list entry (Section 11.12), but one that the verdict below lets it ack without a fetch, and, once it has acked the page, lists again while the list's `total_count` is more than the page held:

- **The client accepts only a body of the listed `size`, and reads at most one byte past it.** An answer whose body has another length is malformed, and the client judges nothing and acks nothing on that answer.
- **A fetch that resumes a cut fetch by range (Section 11.12) is checked as a whole.** The client checks the bytes kept and the range together against the listed `size` and the message id (check 8), as for a body read whole.
- **A `206` is malformed if the `Content-Range` is not the range asked for, or is not of the listed size.**

**The checks, in this order.** Each check but check 9 names the code it refuses with. A client MUST NOT accept a message that does not clear every check.

1. **Check 1, decryption.** The reader decrypts the file, in age's binary format (Section 9.4), trying every retained prekey (`decrypt_error`). A reader MUST refuse a file without exactly one native stanza as `decrypt_error`, before any key agreement. No server accepts such a file as a send (Section 11.10, step 7).
2. **Check 2, layout.** The plaintext has the layout of Section 9.2: the envelope on line 1, then a signature block from line 2 to the first END line, followed by LF (`malformed_message`).
3. **Check 3, JSON.** The envelope is one JSON object, read by Section 3.3's rules for a JSON text, the rule on types aside, and the envelope's body meets the same rules (`invalid_envelope`). Check 6 reads the types of the envelope's members. The client passes the body on unchanged.
4. **Check 4, identity.** The sender's identity document comes from the envelope's `identity`.
   - The document is base64, has the form of Section 4.1, and has a key in its type's one encoding that meets the key checks of the key's type (`invalid_identity`).
   - `from` MUST be the document's hash (`sender_mismatch`).
   - The reader refuses a well-formed document whose hash is `from` and whose key type the reader does not verify, as `unsupported_key_type`.

5. **Check 5, signature.** The signature meets all of these (`invalid_signature`):
   - the signature is over line 1 exactly as decrypted;
   - the signature is in the namespace `dromas-msg-v1:<this mailbox>`;
   - the signature verifies by Section 5.4, with that identity's document as the input.
6. **Check 6, envelope.** The reader checks the rest of the envelope, in this order:

   | Order | Rule | Otherwise |
   |---|---|---|
   | 1 | a body is present, every member is of its type, and `from` and `to` are addresses | `invalid_envelope` |
   | 2 | `v` is the integer 1 | `invalid_envelope` |
   | 3 | `to` is this mailbox | `recipient_mismatch` |
   | 4 | `msg_id` is in its form, and `sent_at` is a time | `invalid_envelope` |
   | 5 | `sent_at` is no older than the TTL | `message_expired` |
   | 6 | `sent_at` is no more than the skew allowance ahead of this mailbox's clock | `message_not_yet_valid` |

   A `from` or `to` that is absent or `null` names no address: it is refused as a mismatch, `sender_mismatch` at check 4 or `recipient_mismatch` at row 3, not at row 1.

7. **Check 7, revocation.** The reader follows three steps, in this order:
   1. **What the reader keeps comes first, with no call.** A kept revocation of the sender's address (Section 12.5) refuses the message as `sender_revoked`, now and for every later message from that address (Section 10.1). A kept revocation of the sender's certificates that covers the signer (Section 5.1) refuses the message as `certificate_revoked`.
   2. **Otherwise the reader looks up the sender's revocations (Section 11.15),** once in a drain for each sender, after that sender's signature has verified. The server serves them whether or not the server holds a mailbox for the sender. The reader accepts three answers: any 2xx answer whose body parses as a revocation record (Section 10.3); a `404 revocation_not_found`; and a `410 mailbox_revoked` whose revocation record verifies. A 2xx answer is the server's answer, so what verifies in the record is shown, and nothing else is. For example, `200 {}` shows nothing revoked, as an unsigned `404` does. Anything else is no answer, a `410` whose record does not verify among them, so the drain stops and the message stays on the server.
   3. **On an answer, the reader keeps each revocation that verifies, and applies step 1 again.** If nothing refuses the message, the message passes this check. A revocation that does not verify counts as nothing shown, as Section 12.5 says. A later message from that sender in the drain makes no second call, and the reader applies step 1 to the later message by what the reader then keeps.

8. **Check 8, replay.** The reader computes the SHA-256 of the ciphertext. That hash is not in the replay set (`message_already_received`).
   - The reader refuses a message whose listed `id` differs from that hash (`id_mismatch`).
   - The replay set keeps each message's hash and `(from, msg_id)` until the message's `sent_at` + 14 days and an hour.
   - A replay set that is lost, or put back from an older copy, lacks records that the mailbox made before the loss. Section 15.9 states what that costs.
9. **Check 9, duplicate.** `(from, msg_id)` is not in the replay set. A match means the message is a copy of a message already delivered. The reader acks the copy and does not deliver the copy again.

**A reader never asks the server who a sender is.** The message carries the proof of who its sender is, and check 7 reads only the sender's revocations. The reader MUST NOT pin the sender's identity before the sender's signature verifies.

**The verdict.**

- **A client does each of the following only for a message the client accepts:**
  - keep the message decrypted;
  - add the message to the replay set;
  - deliver the message.

  A client acks each message after the client has kept a verdict on that message, except a list entry whose `id` is in its replay set (check 8), which the client MAY ack without fetching the message. The verdict is accepted (delivered or held) or refused. Until the client acks the message, the message stays on the server, and a later drain can serve the message again. So delivery is at least once.
- **A client MUST ack a refused message and MUST NOT deliver the message.** The ack deletes the message from the server. A refusal MUST NOT block the message's sender (Section 15.4). A refusal for a time is a verdict like any other, so the client does not leave the message on the server to wait for a clock to catch up.
- **A refusal is a code from a closed set:** `decrypt_error`, `malformed_message`, `invalid_envelope`, `invalid_identity`, `unsupported_key_type`, `invalid_signature`, `sender_mismatch`, `recipient_mismatch`, `sender_revoked`, `certificate_revoked`, `message_expired`, `message_not_yet_valid`, `message_already_received` and `id_mismatch`.
- **A transient failure (a fetch that errors) and a fault of the mailbox (an unreadable key or replay set) are errors, never verdicts.** On such an error, the client acks nothing, and the message waits for the next drain.

**The drain.**

- **With the `ETag` of the answer for an empty mailbox, a `304` means the mailbox is still empty.** A client that keeps the tag of a page with messages MUST act on the page it kept when the client is answered `304`.
- **A `304` whose `ETag`, compared weakly, is not the tag the poll sent is no answer.** The drain stops.
- **A `304` to a list that sent no `If-None-Match` is malformed.**
- **A client treats a list's answer as no answer in any of these cases:**
  - a list entry's `id` does not have the form `message-id` (Section 11.10);
  - a list entry's `size` is over the largest ciphertext (Section 11.10).

  The client does so before the client fetches anything.

### 12.4. Renewal and key deletion

- **A client MUST give each renewal a prekey unlike every prekey the mailbox has ever made.**
- **Before each renewal, the mailbox looks itself up.** The mailbox keeps each revocation of its certificates that the lookup carries and that verifies. A renewal goes ahead only on an answer to that lookup, except in the remedy (Section 12.6).
  - A mailbox whose current statement is signed by its identity renews under that identity, or under a certificate (below).
  - A mailbox whose current statement is under a certificate renews under a certificate, because a prekey statement that the identity signs is earlier than the current statement (Section 5.3). A client that makes a new certificate gives it a certificate serial above the revocation serial of the revocation kept from that lookup (Section 5.2).
- **A mailbox MUST check its own certificate at its own clock before signing under that certificate.** This check stops a mailbox whose clock has gone back past the certificate's start.
- **Prekey lifetime.** A prekey is valid for at most 8 days, which is the TTL and a day, or for a shorter prekey lifetime that the mailbox's owner sets.
  - A client renews while enough of the prekey's lifetime is left for the clocks of the mailbox's senders (Section 3.4).
- **A client signs each prekey serial one time only.** A renewal that the client sends again carries its prekey statement exactly as signed.
- **Two answers to a renewal are final for the renewal's prekey statement:** `409 serial_too_low`, and `401 certificate_superseded` under the second pass that Section 8 allows. Such an answer is final because the server keeps a prekey statement no earlier than the renewal's, and accepts only a later one (Section 11.9). The mailbox's next lookup of itself, before its next renewal, shows what the server keeps.
- **A client MUST NOT use a kept certificate that began less than an hour before the client's clock (Section 15.7).**
- **Deletion.** A client deletes a prekey, current or retired, at the prekey's deletion time. The deletion time is at the latest the prekey statement's `not_after` plus the TTL.
  - **A client MUST NOT delete a retired prekey if a message that the client's server stores may be sealed to that prekey, by the client's clock.**
  - **A client SHOULD delete a retired prekey before the deletion time, when no message that the client's server stores can be sealed to that prekey (Section 15.3).**
  - **A client deletes a working key when the server accepts a renewal under a later certificate.**
- **A client deletes a prekey, current or retired, at the first drain that the client attempts at or past the deletion time by the client's own clock, whether or not its server answers (Section 15.3).** So a server that refuses the mailbox cannot keep the prekey on the mailbox's disk. No sender seals to a prekey past its `not_after` (Section 12.2), so no message waits for the current prekey once its deletion time has come; the next renewal that the server accepts makes a new prekey.
- **A client deletes a retired prekey before the deletion time, and prunes its replay set, only after a call that its server answered, by the client's clock read then (Section 15.7).** A drain's list answered, or a renewal accepted, is such a call.
- **A mailbox that its server has forgotten sends its renewal as a registration (Section 11.7).** The mailbox sends that registration at a prekey serial above every prekey statement the mailbox has registered or renewed.
- **When a mailbox looks itself up (Section 11.8), the mailbox checks the lookup's answer by every rule of Section 5 except a certificate's dates (Section 15.7) and the revocation serial (Section 5.1).** The mailbox renews past a certificate that the identity has revoked, so that certificate does not stop the renewal.
  - The mailbox stops the renewals it makes on its own where a served prekey statement does not verify, or is earlier than one the mailbox has registered or renewed (Section 5.3). Its owner's renewal goes past such a prekey statement, by the remedy where the mailbox signs under certificates (Section 12.6).
- **A prekey statement that the mailbox did not make, in the mailbox's lookup of itself, shows a stolen key, except at a restore (below):**

  | The prekey statement is | What is stolen | What answers the theft |
  |---|---|---|
  | signed by its identity, or under a certificate of a working key the mailbox did not make | the mailbox's identity | revoking the address (Section 10.1). A revocation of certificates cannot end the use of the stolen identity, because anyone who has the identity can make a higher certificate as easily (Section 15.5) |
  | under a certificate of the mailbox's own working key, where the identity is kept beside the mailbox's other keys | that working key, and the identity kept beside that working key | revoking the address |
  | under a certificate of the mailbox's own working key, where the identity is kept elsewhere | that working key | the remedy (Section 12.6) |

- **When a mailbox's server serves a prekey statement that the mailbox did not make:**
  - A mailbox that has registered or renewed a prekey statement of its own MUST NOT renew above a prekey statement it did not make, unless its owner asks.
  - A mailbox restored from its identity alone has made no prekey statement, so it reads the lost machine's prekey statement as one it did not make. The restored mailbox renews. That prekey statement shows a stolen identity only if the owner did not make it.
  - A mailbox MUST NOT sign messages under a certificate of its own working key when such a prekey statement shows that working key is stolen.
- **A mailbox moves to certificates by renewing under a certificate (Section 11.9).** From then on, the mailbox's prekey statements are under certificates (Section 5.3). Everything the mailbox signed with the identity stays valid.

### 12.5. Revocation at a client

- **A client MUST NOT accept "revoked" without a revocation that verifies.** A `410 mailbox_revoked`, a `403 sender_revoked` or a `401 certificate_revoked` is a server's word. A revocation record that verifies is final. A client MAY look up the mailbox that such an answer is about, to read its revocation record (Section 11.8). Without a revocation record that verifies, the call has failed, and the client changes no state. Anything a server shows that does not verify counts as nothing shown.
- **On `401 certificate_revoked`, a client looks up its own mailbox before the client tries again.** A revocation in that lookup that verifies and covers the certificate the client signs under is final. The client then signs no second pass, and the mailbox renews under a new certificate. Otherwise the client signs one more pass, as for any `401` (Section 8).
- **A mailbox checks for revocations, and publishes its own revocations, only at its own server** (Section 12.2, and Section 12.3, check 7). A mailbox whose server keeps no mailbox for it looks up its own revocations with `GET …/revocation`.
- **A mailbox permanently keeps what it has verified about an address, from any source and at any time.** The mailbox checks every send and every read against what it keeps, with no call to anyone. The mailbox checks and keeps a revocation record handed over in the same way as a served one. A mailbox never keeps "no revocation shown."
- **A mailbox that keeps a revocation of its own address is finished, regardless of any server's answer.**
  - The mailbox signs nothing more as that address: no pass, no message, no certificate.
  - The mailbox still checks for, keeps and publishes revocations, which carry no pass.
- **A revocation record made in advance is the body of the call that publishes the record.** Publishing the record later needs no mailbox and no key (Section 15.5).

### 12.6. The remedy for a stolen working key

The remedy is for a working key stolen without the identity that certified that working key. A stolen identity is answered instead by revoking the address (Section 10.1). The remedy runs where the identity is. The remedy's steps run in order: the remedy first revokes, then renews.

1. **Look up the mailbox.** The client looks up the mailbox at the mailbox's own server. The client verifies any revocation of the mailbox's certificates that the lookup carries, and keeps each one that verifies. The remedy goes on even if the client cannot use the lookup's answer.
2. **Revoke every certificate below the certificate serial of the mailbox's next certificate.** Section 5.2 gives that certificate serial. A certificate serial that the lookup served is below that certificate serial, so the revocation covers that certificate. The client signs one of these:
   - a new revocation of certificates through the serial one below that certificate serial;
   - a new signature on a revocation of certificates through a higher revocation serial that is already kept.

   The client publishes the signed revocation once (Section 11.15).
   - A `409 serial_too_low` means the server keeps a revocation of certificates through a higher revocation serial. The client then looks up the mailbox again. If that revocation verifies, the client keeps that revocation and renews above that higher revocation serial.
   - If a `serial_too_low` shows no revocation that verifies and covers the certificates, the remedy stops there, and the client renews nothing.
3. **Then renew.** The client renews under a new working key and a certificate whose certificate serial is one above the revocation serial. The client sends nothing that an earlier renewal left, because anyone who copied the mailbox while that renewal waited has that renewal's working key.

If the revocation of a mailbox's certificates covers the certificate that the mailbox uses, the mailbox renews at its next drain.

### 12.7. A mailbox whose identity is kept elsewhere

A mailbox whose identity is kept elsewhere signs under certificates. The identity holder makes the mailbox's certificates and revocations. The mailbox keeps its working keys, prekeys, and state.

- **The mailbox makes and keeps each working key.** The identity holder certifies only the working key's public half. The steps run in this order:
  1. The mailbox gives the identity holder the public key and the lowest certificate serial that the certificate may have. That lowest serial is one above the highest certificate serial the mailbox knows of for itself (Section 5.2).
  2. The identity holder sets the certificate serial by Section 5.2, at that lowest serial or above. The identity holder makes the certificate run no longer than the server's maximum (Section 11.18), and never longer than the protocol's maximum (Section 5.2).
  3. The mailbox checks the certificate against each of these:
     - every rule of Section 5.2;
     - a certificate serial no lower than the one the mailbox gave;
     - the key the mailbox made.
  4. The mailbox renews under the certificate (Section 11.9). The mailbox uses any certificate that began less than an hour before the mailbox's clock (Section 12.4) only after that hour has passed.

  A prekey never leaves the mailbox. The identity holder has no key that decrypts messages.
- **Between certificates, the mailbox renews under its current certificate.**
- **A reader accepts a message signed under a certificate only while the certificate is valid at the reader's clock (Section 5.2).** A message can wait the TTL before a reader reads the message. So an identity holder gives the mailbox the next certificate before the current certificate's `valid before`, less the message margin (Section 2.3). For a certificate of the full maximum, that is the server's maximum less the skew allowance and the message margin, counted from when the identity holder made the certificate.
- **After the certificate has ended, the mailbox's server accepts no pass under that certificate.** Nothing goes on until the identity holder gives the mailbox a certificate of higher rank. While the server keeps the mailbox, the server accepts the renewal under that new certificate (Sections 11.9, 13). After the server has forgotten the mailbox, that renewal registers the mailbox anew (Section 12.4).
- **Wherever Sections 12.5 and 12.6 have a mailbox renew under a new certificate, this mailbox waits for its identity holder to give it a new certificate.** A certificate that the identity holder gives this mailbox counts as the owner asking (Section 12.4).
- **A renewal answered `409 serial_too_low`, or `401 certificate_superseded` under the second pass that Section 8 allows, is final for the renewal's prekey statement (Section 12.4).** The mailbox signs no prekey statement at a higher prekey serial to get above the served one, because anyone who has the same working key can sign at any prekey serial. Only a certificate of higher rank gets above the served prekey statement.
  - After such a `409`, a prekey statement that the mailbox's next lookup of itself shows and that the mailbox did not make is under the certificate of the mailbox's own working key. So that working key is stolen. The mailbox signs no message under that certificate (Section 12.4), and the remedy answers the theft (Section 12.6).
  - After such a `401`, the mailbox waits for a certificate above the certificate serial that the answer names.
- **The revocation of the address and the revocation of certificates are both the identity holder's (Section 10).**
- **The remedy (Section 12.6) is split into these steps, in this order:**
  1. The identity holder runs steps 1 and 2.
  2. The mailbox makes a new working key, never one made before the revocation.
  3. The identity holder certifies the new working key above the revocation serial.
  4. The mailbox renews under the new certificate (step 3).

## 13. What a server stores, and for how long

A server chooses how it stores things. A server promises a client the following:

- **Per mailbox.** The server stores:
  - the mailbox's identity document;
  - the mailbox's state (Section 11.6);
  - the current statement and the statement's signature, as they were sent;
  - the current signer and, where the signer is a certificate, the certificate serial;
  - the sender key types that the mailbox declared;
  - when the mailbox was registered;
  - the mailbox's account, if the mailbox has one;
  - the mailbox's ACL.

  The server serves the current statement and the statement's signature as they were sent. The server stores no private key, no pass, and no record of when the mailbox was last seen.
- **Per address.** For an address with or without a mailbox, the server stores the identity document and the revocations that the address's identity made (Section 10). The server keeps both kinds permanently, a revocation of certificates replaced only by a higher one (Section 10.2), and so keeps the identity document permanently too. The server serves each one to anyone who looks up the address. Anyone can make an identity and revoke its address, so what a server keeps of addresses grows without bound, at the rate that Section 11.15 counts revocations.
- **A server keeps a mailbox until nothing valid for the mailbox is left.** That date is the later of:
  - the latest `not_after` of any prekey statement that the server accepted for the mailbox, plus the TTL;
  - the latest `valid before` of any certificate that the server accepted for the mailbox.

  A registration and every renewal raise that date. Nothing lowers the date. Past that date, a server MAY forget the mailbox at any moment. The mailbox is then unknown (Section 11.6).
- **Per message.** The server stores the ciphertext exactly as the send's body carried it, the ciphertext's size, `received_at` and `expires_at`. The message id is the ciphertext's SHA-256. The server stores no sender and no signature, because the message's signature, which names the sender, is inside the ciphertext.
- **A `200` or `201` answer to a send means that the message is stored.**
- **A message expires 7 days less an hour and two minutes after the server receives the message, whether the message is read or unread:**

      TTL − skew allowance − 2 minutes

  The two minutes are for the post's own time: from when the sender dates the post until the server receives the post. `expires_at` is the authority, and a server MUST NOT serve a message past it.
- **`received_at` is the server's clock no later than the server's check of the send's pass.** A server that stamps the message later, for example once the body has arrived or is stored, can serve a message near its expiry that a fast reader refuses as older than 7 days (Section 12.3, check 6).
- **An ack deletes the message.** The server keeps nothing of the message (Section 11.10, step 6).
- **A revocation of the address deletes every message in the mailbox, in the same way as an ack deletes one message.** The server also deletes its record of the mailbox, and keeps the revocation (Section 11.15).
- **Setting the ACL deletes no message (Section 11.14).**
- **A server finishes a send in flight well inside the hour for sends in flight that Section 15.3 gives a client.** A send in flight is a send to the prekey statement that a renewal replaced, which passed Section 11.10, step 7, before the server accepted the renewal. The server stores and lists the send's message within that time, or does not store the message.
- **Logs.** A server MUST NOT log an address or a message id in the clear. Where a server would log one of these values, the server logs a name for the value instead. A day after the server logs a name, nobody, the server's operator included, can match the name to its value from the log alone. For example, a server makes the name with a keyed pseudorandom function, under a random key that the server keeps only in memory and replaces each day. A server MUST NOT log a pass or a request body.

## 14. Compatibility and versioning

Nothing is final until version 1 is declared stable. From that declaration on:

- **Unknown members are read as Section 3.3 says.**
- **The identity document and the signed statements match their formats exactly.** The signed statements are the prekey statement, the pass, and the two revocation statements. A new format needs a new tag. Each namespace is versioned on its own.
- **A new member is optional.**
- **A server MAY add a route.** Section 11.2 says how a client reads a route that a server does not offer.
- **Versions (Section 11.17).** A client names its version on every request. A server says when it stops accepting a version:
  - with a `Deprecation` on every answer to a version that the server deems deprecated;
  - with a `Sunset` on every answer to a version that the server will stop accepting;
  - with `410 client_version_unsupported` when the server has stopped accepting that version.
- **Features outside version 1.0.** Every feature that a server offers outside version 1.0 is a capability that the server lists in the server's document (Section 11.18). A client uses such a feature of a server only where that server lists the capability. A check that a client makes at a party other than the client's server, named in the client's own configuration, is not a feature of a server, and needs no capability. `latest_version` enables no feature.
- **`dromas-revoke-v1` stays valid permanently.** A revocation signed in advance therefore keeps working.
- **A new identity key type is an addition inside v1.** The identity document has one form for every type (Section 4.1), so a type defined later needs no new tag. A new identity key type is optional. A mailbox declares such a type once its client verifies the type (Section 7).
- **A new prekey type is an addition inside v1 in the same way (Section 6).**

What version 1 fixes, and how each fixed part can grow inside version 1:

| Fixed | Grows by |
|---|---|
| The identity document and the signed statements, byte for byte (Sections 4.1, 6, 8, 10) | a new format under a new tag; a new identity or prekey key type |
| A certificate's type, key id, principal and one form, with no critical option or extension; its validity, a window checked at the verifier, whose longest is each server's own (Sections 5.2, 11.18) | a new certificate format under a new key id |
| The two signer forms, their ranks, and the order `(c, p)` (Section 5) | nothing |
| The namespaces, `dromas-<purpose>-v1:<address>` | a new purpose |
| A signature's form and its bound (Section 3.2) | a new key type, which raises the bound if its signatures are longer |
| The plaintext: the envelope, the signature block, the padding (Section 9) | the envelope's optional members; `v` changes only for a breaking change |
| JSON as Section 3.3 reads it; a byte member's one encoding; a message's ciphertext as a send's body | nothing |
| The largest ciphertext, 16 MiB (Section 11.10) | a new version of the protocol |
| The routes, methods, statuses, codes and members (`api/openapi.yaml`) | a route; an optional member; a code, which a client that does not know the code reads by the answer's status |
| The pass's scheme and its three parameters (Section 8) | a new scheme |
| An error's `type` (Section 11.3); the link (Section 4.3) | a new code |

## 15. Security considerations

This table gives each security property, the party that the property holds against, the condition under which the property holds, and the assumption that the property rests on. The sections it names give the detail.

| Property | Against whom | Holds while | Rests on |
|---|---|---|---|
| Confidentiality of a message's content | a party that holds the ciphertext, the server included, and that party with a quantum computer later (Section 15.10) | the prekey that the message is sealed to has not leaked (Section 15.5) | the confidentiality and integrity of the age v1 file format [age] with one `mlkem768x25519` stanza (Section 9.4), whose stanza is HPKE [RFC 9180] with the MLKEM768-X25519 KEM [draft-ietf-hpke-pq-03], the X-Wing construction [X-Wing] |
| Confidentiality against a substituted prekey | an active attacker, the server included | the address reached the sender intact (Section 15.1), the mailbox's signing keys are not stolen (Section 15.5), and no quantum computer can forge a signature (Section 15.10). | EUF-CMA of the signer's key type under SSHSIG (Sections 3.2, 5, 6); second-preimage resistance of SHA-384 (Section 4.2) |
| Forward secrecy | a party that steals the mailbox's keys later | from the deletion of every prekey that the message could be encrypted to, which Section 15.3 bounds. | a client's real deletion of prekeys (Sections 12.4, 15.3); the first row |
| Sender authentication | any party without the signer's private key, the server and the recipient included | the sender's signing keys are not stolen (Section 15.5), and no quantum computer can forge a signature (Section 15.10). | EUF-CMA of Ed25519 [BCJZ] and of ECDSA P-256, under SSHSIG and in a certificate's own signature (Sections 3.1, 3.2, 5.2); collision resistance of SHA-512 (Section 3.2), and of SHA-256 for a security key's signature (Section 3.2); second-preimage resistance of SHA-384 (Section 4.2); sign-then-encrypt [ADR] |
| Recipient binding (no surreptitious forwarding) | a recipient that forwards a signed message to a third mailbox as a message from the sender | sender authentication holds | the namespace and `to`, both inside the signature (Sections 9.2, 15.4; Section 12.3, checks 5 and 6) [Davis] [ADR] |
| Key-compromise impersonation resistance | a party that holds the mailbox's stolen prekey | sender authentication holds | the signature, by a key apart from the prekey (Section 15.4) [ADR] |
| Replay and duplicates | the server | the mailbox runs in one place, and keeps its replay set (Section 15.9). | checks 6, 8 and 9 (Section 12.3), with `sent_at` and `msg_id` inside the signature |

**Not provided:**

- delivery, and proof of delivery, against the server (Sections 15.2, 15.9);
- deniability toward a recipient (Section 15.4);
- metadata privacy from the server, and from the party that terminates TLS for it (Sections 15.1, 15.2, 15.8).

### 15.1. Threat model

Dromas protects a message's content from everyone but the message's recipient. Dromas protects the sender's identity from forgery by anyone, the server included. Dromas does not hide from the server who writes to whom.

- **The adversaries:**
  - the server and the server's operator, including the party that terminates TLS for the server (Section 15.8), who see everything stored and in transit;
  - a network attacker, who sees TLS;
  - a registered sender;
  - many cheap identities;
  - a compromised or prompt-injected mailbox.
- **The assets, in order:** a message's content; the authenticity of the message's sender; the authenticity of a mailbox's keys; availability; metadata.
- **The trust root is the address.** An address is exchanged out of band. So the party that delivers an address to a sender is trusted to deliver the right address, as with any key fingerprint.
- **Every defence below applies to a client that verifies and gates.** Such a client runs every check of Section 12, and acts on nothing that failed one of those checks. Code or commands that a server serves are not such a client.
- **Nothing here defends a mailbox against code that runs as the mailbox's owner.** Such code can read the mailbox's keys and write the mailbox's files, the messages its client kept as delivered among them. A file's permissions keep out other users alone, as ssh's do.

### 15.2. What a hostile server can and cannot do

- **A hostile server sees:**
  - addresses, identity documents, certificates and prekeys;
  - who sends to whom;
  - each message's size to within a padding block (Section 9.3);
  - times and IP addresses;
  - ciphertext;
  - each mailbox's passes;
  - which account a mailbox is in;
  - each mailbox's ACL. The ACL's allow list names senders that the mailbox accepts messages from, and a sender on that list may never have written to the mailbox. The ACL's deny list names the senders that the mailbox blocked. The entries are addresses in the clear, because a server can hash every address that the server holds. So hashed entries would hide only an allowed sender that the server has never seen.
- **A hostile server never sees:** plaintext, a private key, an age file key, or any message's signature.
- **A hostile server keeps nothing signed that says who wrote to whom.** A pass names a mailbox and a time, and names no recipient and no message.
- **A hostile server can:**
  - deny service;
  - drop, delay or delete messages undetectably;
  - say falsely that a mailbox is revoked, which a client checks and does not believe (Section 12.5);
  - withhold a revocation from a peer that has never seen the revocation (Section 15.6);
  - replay old messages, which a reader refuses (Section 12.3);
  - serve a sender a stale prekey, but only a prekey that the mailbox's signer signed, only until that prekey's `not_after`, and never to a sender that has seen a later prekey statement;
  - act as a mailbox toward itself;
  - refuse every pass from a mailbox, which keeps the mailbox's prekeys on the mailbox's disk until the first drain that the mailbox attempts at or past each prekey's deletion time (Section 15.3);
  - accept messages that a mailbox's ACL refuses, which the mailbox's client still judges, or refuse messages that the ACL admits, which the server could drop anyway;
  - write anything in an error's words, which a client never shows, or in a receipt or an account id, which a client checks against the value's form before using the value (Section 11.3);
  - answer a lookup `304`, which holds a sender on an answer the server served before; the server can already serve that answer's bytes again, and the sender checks the kept answer at every post (Section 12.2);
  - serve altered instructions to an agent that runs anything it is served.
- **Against a client that verifies and gates, a hostile server cannot:**
  - read messages;
  - forge a sender;
  - reattribute a message;
  - substitute a key (that would need a SHA-384 second preimage or a signature forgery);
  - alter a message undetected;
  - revoke an address;
  - make a pass;
  - turn a pass into plaintext or into a signature on a message.

### 15.3. Forward secrecy

- **Every mailbox has forward secrecy, given a client that deletes its prekeys (Section 12.4).** How often the mailbox renews and deletes sets the bound on that forward secrecy.
  - A message cannot be recovered from the mailbox's keys once every prekey that the message could be encrypted to is deleted. For a prekey, current or retired, that time comes, at the latest, at the first drain that the mailbox attempts at or past the `not_after` of the prekey statement that the message is sealed to, plus the TTL, by the mailbox's clock, whether or not a server answers the mailbox (Section 12.4). That is at most 15 days after the prekey statement was made (Section 6).
  - Suppose a client deletes every retired prekey after a drain that empties its mailbox. For that client, that time comes at the first such drain whose list is answered more than an hour after the server accepted the mailbox's next renewal, both by the mailbox's clock. For example, that time comes this long after the message arrives:
    - about a day, for a mailbox that renews daily and polls between renewals;
    - about two days, for a mailbox whose only drain is a daily one and which renews at the start of that drain.
  - The hour is for sends in flight. A server accepts a send only to the current prekey statement (Section 11.10, step 7). So once the server accepts a renewal, the server refuses a send to the prekey that the renewal replaced. A send that the server accepted before the renewal is stored and listed within that hour, or is not stored (Section 13).
  - The bound keeps no state per peer, because the mailbox renews, drains, and deletes on its own. The bound needs a server that accepts the mailbox's passes. A client that deletes by this hour relies on the promise of Section 13 on a send in flight, so that no message arrives sealed to a deleted prekey.
- **A message waiting on the server is exposed until the mailbox fetches it.** A mailbox that stops renewing, or whose server refuses its renewals, keeps its ended prekey as the current prekey, and that prekey's key on the mailbox's disk until the first drain that the mailbox attempts at or past the prekey's deletion time (Section 12.4). The mailbox's last messages stay exposed until then at the latest.
- **Forward secrecy depends on real deletion.** A key kept in a backup, a synced folder or a store with version history survives its deletion.
- **Forward secrecy is per prekey, as in X3DH without a one-time prekey, but here the prekey alone decrypts.** X3DH needs both the identity key and the signed prekey to compute an earlier shared key. A leaked prekey decrypts every message encrypted to it until the mailbox renews and deletes the prekey, because version 1 has no ratchet.
- **Forward secrecy per reply can be added as an optional envelope member.** Version 1 does not yet define such a member, but leaves room for one. Such a member is possible because the envelope is inside the encryption, where the server cannot see the envelope, and because a reader ignores an unknown member (Sections 3.3, 14).

### 15.4. Sender authentication

- **Each message carries the sender's signature inside the encryption.** The signature is by the sender's identity, or by a working key that the identity certified, and the recipient verifies the signature. The signature resists key-compromise impersonation, so a leaked prekey lets nobody forge a sender to the prekey's mailbox [ADR].
- **The signature is bound to the recipient by the namespace and by the envelope's `to`.** So a recipient cannot forward a signed message to a third mailbox as a message from the sender. That forwarding is the known flaw of signing before encrypting [Davis]. The sender's signature names the recipient, the encrypted plaintext names the sender, and the reader refuses a name that does not match [ADR].
- **The signature is not deniable toward a recipient.** A recipient can show anyone what a sender signed. That is both an audit trail for programs that act on messages and a privacy cost. The server keeps no message signature, and can prove nothing about who sent what.
- **A message that a mailbox cannot decrypt has no sender at all.** The server keeps no sender (Section 13). So a mailbox restored without its prekeys cannot learn whom to ask to send the message again.
- **A reader decrypts before it verifies.** Until the signature is checked, the reader handles bytes that nobody vouched for: first age's, then the envelope's. By design, age accepts files from anyone, and a reader acks a refused message whatever the reason for the refusal, so neither the server nor the sender learns which check failed. The one exception is check 7's read of a sender's revocations, which tells the server which senders the reader has verified (Section 15.8). Each part of the plaintext has one place, and nothing is searched for (Section 9.2).
- **A security key's signature proves that its authenticator claimed a user was present, and nothing more (Section 3.2).** The key and its signatures carry no attestation (`PROTOCOL.u2f`), so a verifier has no evidence that an authenticator holds the key at all: a key in software makes the same signatures. A verifier reads neither the counter nor any flag but user presence. The cost of the rule: a security key enrolled to sign without a touch (`ssh-keygen -O no-touch-required`) cannot be an identity, since each of its signatures lacks the flag.
- **A security key's point may also be a working key of the security key's plain type.** A certified key is compared with the identity key byte for byte (Section 5.2), and the two wire keys differ in their type, so an `sk-ssh-ed25519@openssh.com` identity can certify the `ssh-ed25519` key of its own point, and an `sk-ecdsa-sha2-nistp256@openssh.com` identity the `ecdsa-sha2-nistp256` key of its own point. The two types sign different bytes (Section 3.2).
- **A verifier accepts both (r, s) and (r, n − s) as a P-256 signature, and nothing depends on a signature having one set of bytes (Section 3.2).** A message's id is the ciphertext's hash, and a send names a prekey statement by the hash of the statement alone (Section 11.10).
- **Encryption with age to a public key authenticates nobody.** Only the signature inside makes a message the sender's. The padding after the signature is unsigned, and is never read.
- **A malformed identity document is evidence of tampering, and so is an identity document that does not hash to the address.** A well-formed identity document of a key type that a reader does not verify is not evidence of tampering (Section 4.1).
- **A refusal blocks no sender, because the sender may not have written the message.** A forgery may be the operator framing the sender. A message under a revoked certificate may be a thief's, and the thief's signature verifies.

- **A group is what each member's message says it is.** A sender can write a different `group` in each member's message, and each member sees only the message sealed to that member. No member can check another member's message. A message proves only that its sender sent it to that member.
- **`sent_at` does not order a group's messages.** A member's message that waited in the outbox is dated at its post, so two members can receive two messages in different orders. `in_reply_to` is the only link between two messages that a sender signs.

### 15.5. Stolen keys

- **A stolen identity key is the worst case. Only revoking the address answers that case (Section 10.1).**
  - Until the owner revokes the address, the thief can sign as the mailbox, register and renew prekey statements, and read new messages. The thief can sign with the identity itself, or through a certificate of the thief's own working key.
  - Revoking the address is permanent, so recovery is a new address, announced out of band.
  - A thief that has the identity can also revoke, which gains the thief nothing.
  - A mailbox that signs with its identity keeps the identity beside its other keys. So a copy of the mailbox is a copy of the identity. A mailbox that signs under certificates can keep its identity elsewhere. The cost is an identity holder who certifies a new working key at least as often as Section 12.7 requires.
- **A registration needs the identity to choose the key, and needs the holder of the signer's key to be present.** The signer shows that the identity chose the key. A pass minutes old shows that the holder is present. Only a party that has the identity key, or a working key under a certificate of that identity, can register that identity. A party that finds a leaked prekey statement cannot register the statement (Section 11.7, step 7).
- **A revocation of certificates does not cover the identity's own signature (Section 10.2).** Refusing the identity's signature would stop no thief, because the party that has the identity key makes a certificate above any revocation just as easily. A revocation of certificates answers a stolen working key, and for that purpose needs nothing of the identity's signatures.
- **If the identity key is lost, only a revocation record made in advance can revoke the address (Section 12.5).** Without such a record, the address stops accepting messages once its prekey ends, and the address's correspondents are told the new address out of band. Anyone who has such a record can revoke the address, and a revocation of an address is permanent.
- **SSHSIG does not sign the signing-key field.** So a signature can be carried under any certificate of the key that made the signature.
- **A prekey statement signs the rank of the prekey statement's signer (Section 6).** So a verifier refuses a prekey statement carried under a certificate of another rank. So an older prekey statement cannot stand above a sender's latest `(c, p)` under a later certificate of the same key. The same prekey statement cannot pass a revocation of certificates that covers the certificate that the working key signed under.
- **A pass and a message sign no rank, so a certified key is never the identity key, and every certificate certifies a new working key (Section 5.2).** Without these rules:
  - The identity's own signature on a pass or a message could be carried under a certificate of the identity key. That signature would then read as a working key's signature.
  - A working key's signature on a pass or a message under a certificate of certificate serial s1 could be carried under a certificate of the same key at a higher certificate serial, s2. A verifier would then accept that signature past a revocation of certificates through s1.
- **A server counts the identity's acts apart from a working key's acts (Section 11.5).** So the holder of a stolen working key cannot stop the identity from revoking that key's certificate, or from renewing under a new certificate.
- **A stolen working key signs messages that every reader accepts until the key's certificate ends, through any server, or until a reader sees a revocation of that certificate.**
  - A server accepts a prekey statement under a certificate that runs at most the server's maximum (Section 11.18).
  - A reader accepts a certificate within the certificate's validity window, and only one that runs at most the protocol's maximum (Section 5.2). So a stolen working key signs for at most 45 days and the skew allowance after its certificate began, whatever a hostile server served the maker as its maximum.
  - A certificate that no server accepted signs messages while it lasts. Such a certificate can also register its address at a server that has forgotten the address.
  - A renewal under a new certificate ends the stolen key's passes and prekey statements at the server at once, and at every sender that has seen the new certificate. A renewal ends nothing at a reader.
  - A revocation of the stolen key's certificate ends the key wherever the revocation is seen (Section 12.6).
  - Messages that the owner sent under a revoked certificate, and that are still unread, are refused along with the thief's messages.
- **The party that has the identity key chooses how long a certificate runs, up to the server's maximum and never past the protocol's maximum.** A shorter certificate ends a stolen working key sooner, and needs the identity more often. A reader checks a certificate at the reader's own clock, because nothing vouches for when a signature was made. A message may also wait the TTL before it is read. So a certificate signs messages that every reader accepts until the certificate's `valid before`, less the message margin (Section 2.3). For a certificate of the full maximum, that is the server's maximum less the skew allowance and the message margin, counted from when the maker made the certificate.
- **A stolen pass works at most until the pass ends, and only at the server that the pass names.** A pass by a working key stops working sooner, once the server refuses the pass's certificate as revoked or superseded (Section 8). A client signs a pass to end at most 10 minutes after signing (Section 8). So a pass taken from a log, a proxy, or anything else that the pass passes through works for the rest of those minutes, and longer by as much as the client's clock runs ahead of the server's clock. A server accepts a pass that ends at most 15 minutes after the server's clock, the pass's 10 minutes and 5 for clocks that differ (Section 8), so no pass that a server accepts has more than 15 minutes left. A pass names no call. A stolen pass:
  - gives the mailbox's metadata and ciphertext;
  - gives control of the mailbox's availability: deleting unacked messages permanently, leaving the mailbox's account, and setting the mailbox's ACL, with which the stolen pass can refuse every sender until the owner sets the next ACL;
  - gives sending in the mailbox's name, which verifies at no recipient;
  - never gives plaintext, signs no message and no prekey statement, and cannot revoke the address.

  All of this is within a hostile server's powers (Section 15.2), at the one server that the pass names, until the pass ends.
- **A pass is not bound to the request that carries the pass.** A binding of the pass to each request, such as an HTTP message signature (RFC 9421) or a proof of possession (RFC 9449), costs one of these properties:
  - A signature over a send would cover the recipient and the ciphertext. A hostile server would then keep a signed record of who wrote to whom, which Section 15.2 rules out.
  - A signature over an ack or an ACL has the same cost, because a message id is the ciphertext's hash and an ACL names the mailbox's peers.
  - A binding to the TLS connection (RFC 9266) needs the TLS session's exporter where the server checks the pass. The party that terminates TLS can be a process other than the one that checks the pass.

  So the pass is bounded by its end and its one server, and a stolen pass gives only what a hostile server can do (Section 15.2).
- **A stolen prekey decrypts every message encrypted to it, until the mailbox renews.** A sender that has seen no later prekey statement can still be served the old statement until the old statement's `not_after`. A shorter prekey lifetime (Section 12.4) narrows that time, for a mailbox that renews often.

### 15.6. Revocation's limits

- **A server can withhold a revocation from a peer that has never seen the revocation.** The server answers that it keeps no revocation, and nothing tells the peer otherwise. The lookup before every post narrows this risk in time, and no further, because a client keeps every revocation that the client was shown while the client's server answered truly. The client still keeps those revocations after that server stops answering truly. Only a revocation record from the mailbox's owner, handed over out of band, answers a server that hides a revocation record from the server's first answer.
- **A mailbox checks revocations at its own server alone (Section 12.5).** Asking another server too, such as one running another implementation, would help against a server that withholds a revocation, but only if the revoked mailbox's owner and the reader both use that other server. This version defines no second server.
- **This protocol sets no bound on how long a revocation can go unseen by a peer whose server hides the revocation.** The usual answer is key transparency: a verifiable map that clients check. This protocol lacks key transparency. Key transparency fits inside version 1 with nothing reserved: a client checks a verifiable map of revocations that the client's own configuration names, and a server cannot remove that check by listing no capability (Section 14). The map's proof of absence bounds the time a revocation goes unseen only if the revocation reached that map and a party other than the map's operator compares the map's signed heads.
- **A verifier keeps a revocation of certificates permanently (Section 10.2), because no verifier can tell when the certificates that the revocation covers end.** A revocation through a revocation serial covers certificates that the verifier has never seen. A covered certificate can begin at any date up to `9999-12-31T23:59:59Z` and runs up to the protocol's maximum from that start (Section 5.2), so its end can come after any period for which a verifier keeps the revocation. The cost is one revocation of certificates for each address whose identity has revoked certificates.

### 15.7. Clocks

- **A client never sets its clock by a server's `Date` (Section 12.1).** A clock set by a lying server would make an ended certificate valid again, and a stale message fresh.
- **A mailbox whose clock is further off than a pass permits (Section 8) is stopped.** The mailbox is stopped before it fetches messages that it would judge by that clock, or prunes its replay set by that clock. The mailbox is stopped:
  - in most cases, at the mailbox's pass (`401 pass_expired`);
  - if the mailbox's clock is more than the skew allowance ahead when the mailbox makes a certificate, when the server checks that certificate (`400 invalid_validity_period`).
- **A certificate that a server accepts need not have begun at every reader.** A reader refuses a message under a certificate whose start is after the reader's clock (`invalid_signature`). The reader acks that message, and the message is lost. The maker of a certificate dates the certificate back by the skew allowance, and that covers this case (Section 5.2).
- **If a server accepts passes from two clocks, the two clocks are less than 25 minutes apart.** A server accepts a pass from a mailbox whose clock is less than 10 minutes behind the server's clock. A server accepts a new pass from a mailbox whose clock is up to 5 minutes ahead, and a kept pass, signed while that clock read slower, from a mailbox whose clock is less than 15 minutes ahead.
- **What this does not cover.** A server checks a pass when the pass is first shown, and a server MAY remember the pass until the pass ends, at most 15 minutes (Section 8). Two cases escape:
  - a clock that moves by minutes while the server remembers the pass;
  - a clock that goes back by more than an hour in the middle of a drain.

  Either case can put a `sent_at` past a reader's skew allowance, or have a reader judge messages by a clock that no server accepted a pass from. The reader then refuses the message, and keeps the message with the findings of the reader's checks, the reader's clock among them. Each case needs a clock that is already wrong.
- **A client prunes its replay set only after a call that a server answered, by the client's clock read then (Section 12.4).** A clock far ahead is stopped at its pass before that. **A client deletes a prekey, current or retired, at the first drain that it attempts at or past the deletion time by its own clock, whether or not a server answers (Section 12.4).** **A clock that is wrong is a failure, and its cost is accepted.** A clock stepped back more than an hour after a prune lets a hostile server deliver a pruned message twice. A clock far ahead deletes a prekey early: a message stored sealed to that prekey that the mailbox has not fetched is then unreadable.
- **If a kept certificate began less than an hour before the client's clock, the certificate was made while that clock read ahead (Section 12.4).** A new certificate is made by the clock as the clock now reads.
- **A mailbox checks its lookup of itself by every rule except a certificate's dates (Section 12.4).** From that lookup, the mailbox needs two things: that its identity signed the prekey statement, and where the prekey statement stands in the mailbox's order. A certificate's dates bind everything signed under the certificate, and never bind a renewal past the certificate. So a date never stops the mailbox from renewing past a served prekey statement.

### 15.8. Metadata

- **The server sees the social graph, times, IP addresses and each message's size to within a padding block.** Padding hides a length, not a pattern of traffic: who writes to whom, when and how often. A sender other than the reference clients may pad differently or not at all, and the server cannot tell.
- **Once a message is stored, the server keeps no sender beside the message's recipient (Section 13).** The server sees the sender at the send, with the sender's IP address and the time. The server also sees the message while the message is live. A server that turns hostile can record all of this from then on.
- **A lookup shows anyone who has the address when the mailbox renews.** A prekey serial and a `not_after` read the clock of the prekey statement's maker, and a lookup needs no pass (Section 11.8).
  - A lookup needs no pass because a lookup returns only the documents that a sender verifies before a post.
- **A sender that keeps its ciphertext learns, on the server's word, whether the recipient's mailbox still holds the message.** A post of the same ciphertext is answered `200` while the mailbox holds the message unacked (Section 11.10, step 6). Once the message is gone (acked, expired or deleted), the same post is a new message, answered `201`.
  - The sender knows the message's `expires_at`, so the sender can tell an expiry from an earlier end.
  - The sender's `calls` bound how often the sender can ask. A post answered `200` spends none of the mailbox's intake budget.
  - A conforming sender posts the same sealed file a second time only after the server rejected the first post's pass (Section 8), so only a sender that breaks that rule can ask.
  - The answer is the server's word, and a server can give either answer whatever the recipient did.
  - Removing the signal would need a record of each acked message, which Section 13 rules out.
- **The lookup before a post tells the server that the mailbox is about to be written to.** The post tells the server the same thing a moment later.
- **A reader's look-up of a sender's revocations tells the server which senders the reader has just verified.** The reader makes that call during its drain, at most once for each sender, right after that sender's signature verifies (Section 12.3, check 7). So the server can link the sender to the reader at read time, from the reader's own calls. Any call that names the sender tells the server the same, so no choice of route removes this link.
- **A server does not compress an answer (Section 11.2).** A compressed answer has a length that depends on the answer's own bytes. So the length of a compressed lookup could help a network observer narrow down whom a sender is about to write to. A compressed list would set values that senders chose beside the mailbox's own values (BREACH, RFC 7457 §2.6).
- **Anything that terminates TLS for a server is part of the server.** A TLS terminator sees everything the server sees, and each pass in transit. For the minutes a pass has left, the pass does at that server everything that Section 15.5 lists. A third party in that position would replace the server for every mailbox whose pass the third party sees. That is why Section 11.1 keeps TLS inside the server.
- **An address in a URL is seen wherever URLs are logged.** Such an address is seen, for example, by the party that terminates TLS, in a chat that unfurls links, and in a transcript. A leaked address is answered by a new mailbox and by revoking the old address.

### 15.9. Addresses, messages, and availability

- **A mailbox is one durable copy of the mailbox's own state, with one writer.** What a mailbox holds against a hostile server is in that state: the replay set (Section 12.3, checks 8 and 9), the identities that the mailbox pinned (Section 12.2), the revocations that the mailbox kept (Section 12.5), and the mailbox's prekeys (Section 12.4). That state outlives every process that runs the mailbox. One writer means one copy of the state, not one process: the processes of one client can share the copy, each writing in turn. So more concurrency than one copy gives is more mailboxes, each with its own identity and address. The bullets below state what a second copy costs, and what the mailbox's own state lost or put back from an older copy costs.
- **An address is a send capability.** Keeping an address private is the first defence against unwanted messages. Sending to a mailbox hands that mailbox the sender's address, so the mailbox can write back.
- **Authentic is not safe.** A signed message from a compromised or prompt-injected sender is genuine. Messages are data, never instructions: a verified signature proves who sent a message, not whether to obey the message. A mailbox's defence at the server is the mailbox's ACL, whose allow list names the senders that the mailbox accepts.
- **An open mailbox can be filled to its caps, and its intake budget spent (Section 11.10, step 8).** One verified sender within the sender's own limits can do this, and so can enough verified identities. This delays the messages of the mailbox's other senders.
  - The mailbox's ACL answers one sender. Denying that sender refuses the sender's later sends, and the mailbox drains the messages that the sender sent (Section 11.14).
  - An allow list is the full defence for a mailbox that knows its senders. A deny list is not the full defence, because a new identity is cheap.
- **A reader that bounds its drains limits a hostile server's cost to that reader.** Messages from senders that a server made up fail to decrypt or verify, and leave no pin. A sender that a server made with the server's own keys is a real sender, at an address that nobody gave the reader.
- **Silent drops are undetectable, because the protocol has no receipt from the recipient.** A sender's repeat post (Section 15.8) gets the server's word, which proves no delivery.
- **A message is sent again as the same envelope (Section 12.2).** A new message would carry a new `msg_id`, and a reader that acts on messages would act twice. A post whose answer is lost costs a send. In that case the server stored the message, and the next post is a new ciphertext that the server stores and counts again. The reader acks the second copy and does not deliver the second copy while the reader's replay set holds the first (Section 12.3, check 9).
- **Two copies of a mailbox that both run fail as one mailbox.** Two copies of a mailbox keep two replay sets and two sets of prekeys, and each copy renews and deletes without the other. So one copy delivers again a message that the other copy delivered, and one copy still has a prekey that the other copy retired. A mailbox restored from its identity alone replaces the mailbox that it restores (Section 12.4). A mailbox restored from an older backup cannot tell a later prekey statement of its own from a thief's.
- **A mailbox that loses its replay set, or puts back an older copy of the replay set, has failed.** After that failure, a server can deliver again a message that the mailbox accepted before the loss.
  - An honest server still holds each message that the mailbox had not acked at the loss. A hostile server can keep any message and serve it again, until the reader stops accepting its `sent_at`, at most a TTL after it.
  - The mailbox's kept prekeys open that message, and the replay set that the mailbox now keeps does not record the message.
  - A reader whose work must not happen twice keys that work by `(from, msg_id)`, as a consumer of any at-least-once queue does.
  - A restore from the identity alone keeps no prekey. So no message that the lost mailbox delivered decrypts after that restore.
- **A mailbox that loses the revocations it kept (Section 12.5), of other addresses and its own, or puts back an older copy of them, has failed too.** A server can then withhold a lost revocation, as from a reader that has not seen it (Section 15.6). The mailbox then accepts a message that the revocation covers, seals and posts to an address or under a certificate that the revocation covers (Section 12.2), and signs again under its own revoked address or certificate.
- **Losing the identity loses the address.** So the identity is the one key whose loss a backup answers. A restored mailbox makes new working keys and prekeys, so neither needs a backup.
- **A mailbox that does not renew is sent nothing once its prekey's `not_after` passes.** The mailbox's senders get `409 prekey_expired`. A mailbox under a certificate can poll while the certificate lasts. A mailbox that has its identity can poll with a pass by the identity. Once the certificate has ended, the mailbox's server accepts no pass under the certificate. A renewal brings the mailbox back while the server keeps the mailbox.

### 15.10. Post-quantum

- **Content is protected against harvest-now-decrypt-later, because every prekey is post-quantum.** Against a quantum computer, that protection rests on ML-KEM-768 and SHA3-256 [X-Wing].
- **Future content, not only authenticity, rests on the classical signature until a mailbox uses a post-quantum signature type.** An active adversary with a quantum computer signs prekey statements in the mailbox's name, and senders encrypt to those prekey statements.
- **Signatures are classical: Ed25519 or P-256, a security key's included.** A forgery needs a quantum computer at signing time. The transferable audit trail stays valid until such a computer exists. A post-quantum signature key would be added as an identity key type inside v1 (Section 14). A mailbox that moves to such a key gets a new address, because an address commits to one identity key (Section 4.2), and every peer has to learn the new address, as it learned the old one (Section 15.1).
- **The TLS connections are separate.** Each TLS connection is protected as its endpoints negotiate.

## 16. Test vectors

`testdata/vectors/` has the conformance vectors: scenarios, each one file or the files that share one name, and the fixtures that scenarios share, such as mailboxes A, B, and C. `testdata/vectors/README.md` gives each scenario's expected outcome, describes the vectors' format, and says how each vector is checked. A conforming client meets every vector of the parts it implements. The crypto and container vectors are checked by `age`, `head`, `sed`, `ssh-keygen`, and `openssl`, which are tools written outside this project. The keys of the crypto and container vectors are published test keys. No stock tool signs as a security key without one, so this project's code makes the vectors of the two security-key types, and `ssh-keygen` checks them.

<!-- vale off -->
## 17. References

### 17.1. Normative References

- **[age]** C2SP, "age", v1.1.0, read 2026-11-02, <https://c2sp.org/age@v1.1.0>.
- **[BIP 173]** Wuille, P. and G. Maxwell, "Base32 address format for native v0-16 witness outputs", BIP 173, March 2017, <https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki>.
- **[draft-ietf-hpke-pq-03]** Barnes, R. and D. Connolly, "Post-Quantum and Post-Quantum/Traditional Hybrid Algorithms for HPKE", Work in Progress, Internet-Draft, draft-ietf-hpke-pq-03, 6 November 2025, <https://datatracker.ietf.org/doc/html/draft-ietf-hpke-pq-03>.
- **[draft-ietf-sshm-cert-03]** Miller, D., "SSH Certificate Format", Work in Progress, Internet-Draft, draft-ietf-sshm-cert-03, 17 November 2026, <https://datatracker.ietf.org/doc/html/draft-ietf-sshm-cert-03>.
- **[FIPS 180-4]** National Institute of Standards and Technology, "Secure Hash Standard (SHS)", FIPS PUB 180-4, DOI 10.6028/NIST.FIPS.180-4, August 2015, <https://csrc.nist.gov/pubs/fips/180-4/upd1/final>.
- **[FIPS 186-5]** National Institute of Standards and Technology, "Digital Signature Standard (DSS)", FIPS PUB 186-5, DOI 10.6028/NIST.FIPS.186-5, February 2023, <https://csrc.nist.gov/pubs/fips/186-5/final>.
- **[PROTOCOL.sshsig]** OpenSSH, "PROTOCOL.sshsig", OpenSSH 10.6p1, <https://github.com/openssh/openssh-portable/blob/V_10_6_P1/PROTOCOL.sshsig>.
- **[RFC 1123]** Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", RFC 1123, DOI 10.17487/RFC1123, October 1989, <https://www.rfc-editor.org/info/rfc1123/>.
- **[RFC 2119]** Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119/>.
- **[RFC 3339]** Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, <https://www.rfc-editor.org/info/rfc3339/>.
- **[RFC 3986]** Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", RFC 3986, DOI 10.17487/RFC3986, January 2005, <https://www.rfc-editor.org/info/rfc3986/>.
- **[RFC 4151]** Kindberg, T. and S. Hawke, "The 'tag' URI Scheme", RFC 4151, DOI 10.17487/RFC4151, October 2005, <https://www.rfc-editor.org/info/rfc4151/>.
- **[RFC 4251]** Ylonen, T. and C. Lonvick, Ed., "The Secure Shell (SSH) Protocol Architecture", RFC 4251, DOI 10.17487/RFC4251, January 2006, <https://www.rfc-editor.org/info/rfc4251/>.
- **[RFC 4253]** Ylonen, T. and C. Lonvick, Ed., "The Secure Shell (SSH) Transport Layer Protocol", RFC 4253, DOI 10.17487/RFC4253, January 2006, <https://www.rfc-editor.org/info/rfc4253/>.
- **[RFC 4648]** Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, <https://www.rfc-editor.org/info/rfc4648/>.
- **[RFC 5234]** Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 5234, DOI 10.17487/RFC5234, January 2008, <https://www.rfc-editor.org/info/rfc5234/>.
- **[RFC 5656]** Stebila, D. and J. Green, "Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer", RFC 5656, DOI 10.17487/RFC5656, December 2009, <https://www.rfc-editor.org/info/rfc5656/>.
- **[RFC 6585]** Nottingham, M. and R. Fielding, "Additional HTTP Status Codes", RFC 6585, DOI 10.17487/RFC6585, April 2012, <https://www.rfc-editor.org/info/rfc6585/>.
- **[RFC 7405]** Kyzivat, P., "Case-Sensitive String Support in ABNF", RFC 7405, DOI 10.17487/RFC7405, December 2014, <https://www.rfc-editor.org/info/rfc7405/>.
- **[RFC 7493]** Bray, T., Ed., "The I-JSON Message Format", RFC 7493, DOI 10.17487/RFC7493, March 2015, <https://www.rfc-editor.org/info/rfc7493/>.
- **[RFC 8032]** Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital Signature Algorithm (EdDSA)", RFC 8032, DOI 10.17487/RFC8032, January 2017, <https://www.rfc-editor.org/info/rfc8032/>.
- **[RFC 8174]** Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174/>.
- **[RFC 8259]** Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 8259, DOI 10.17487/RFC8259, December 2017, <https://www.rfc-editor.org/info/rfc8259/>.
- **[RFC 8594]** Wilde, E., "The Sunset HTTP Header Field", RFC 8594, DOI 10.17487/RFC8594, May 2019, <https://www.rfc-editor.org/info/rfc8594/>.
- **[RFC 8709]** Harris, B. and L. Velvindron, "Ed25519 and Ed448 Public Key Algorithms for the Secure Shell (SSH) Protocol", RFC 8709, DOI 10.17487/RFC8709, February 2020, <https://www.rfc-editor.org/info/rfc8709/>.
- **[RFC 9110]** Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "HTTP Semantics", RFC 9110, DOI 10.17487/RFC9110, June 2022, <https://www.rfc-editor.org/info/rfc9110/>.
- **[RFC 9111]** Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "HTTP Caching", RFC 9111, DOI 10.17487/RFC9111, June 2022, <https://www.rfc-editor.org/info/rfc9111/>.
- **[RFC 9457]** Nottingham, M., Wilde, E., and S. Dalal, "Problem Details for HTTP APIs", RFC 9457, DOI 10.17487/RFC9457, July 2023, <https://www.rfc-editor.org/info/rfc9457/>.
- **[RFC 9562]** Davis, K., Peabody, B., and P. Leach, "Universally Unique IDentifiers (UUIDs)", RFC 9562, DOI 10.17487/RFC9562, May 2024, <https://www.rfc-editor.org/info/rfc9562/>.
- **[RFC 9745]** Dalal, S. and E. Wilde, "The Deprecation HTTP Response Header Field", RFC 9745, DOI 10.17487/RFC9745, March 2025, <https://www.rfc-editor.org/info/rfc9745/>.

### 17.2. Informative References

- **[ADR]** An, J. H., Dodis, Y., and T. Rabin, "On the Security of Joint Signature and Encryption", EUROCRYPT 2002, LNCS 2332, <https://cims.nyu.edu/~dodis/ps/signcrypt.pdf>.
- **[AEP-158]** API Enhancement Proposals, "Pagination", AEP-158, <https://aep.dev/158/>.
- **[AEP-193]** API Enhancement Proposals, "Errors", AEP-193, <https://aep.dev/193/>.
- **[BCJZ]** Brendel, J., Cremers, C., Jackson, D., and M. Zhao, "The Provable Security of Ed25519: Theory and Practice", IEEE S&P 2021, <https://dennis-jackson.uk/assets/pdfs/ed25519.pdf>.
- **[Davis]** Davis, D., "Defective Sign & Encrypt in S/MIME, PKCS#7, MOSS, PEM, PGP, and XML", USENIX Annual Technical Conference 2001, <https://www.usenix.org/legacy/publications/library/proceedings/usenix01/full_papers/davis/davis.pdf>.
- **[RFC 6648]** Saint-Andre, P., Crocker, D., and M. Nottingham, "Deprecating the "X-" Prefix and Similar Constructs in Application Protocols", RFC 6648, DOI 10.17487/RFC6648, June 2012, <https://www.rfc-editor.org/info/rfc6648/>.
- **[RFC 7457]** Sheffer, Y., Holz, R., and P. Saint-Andre, "Summarizing Known Attacks on Transport Layer Security (TLS) and Datagram TLS (DTLS)", RFC 7457, DOI 10.17487/RFC7457, February 2015, <https://www.rfc-editor.org/info/rfc7457/>.
- **[RFC 8555]** Barnes, R., Hoffman-Andrews, J., McCarney, D., and J. Kasten, "Automatic Certificate Management Environment (ACME)", RFC 8555, DOI 10.17487/RFC8555, March 2019, <https://www.rfc-editor.org/info/rfc8555/>.
- **[RFC 9180]** Barnes, R., Bhargavan, K., Lipp, B., and C. Wood, "Hybrid Public Key Encryption", RFC 9180, DOI 10.17487/RFC9180, February 2022, <https://www.rfc-editor.org/info/rfc9180/>.
- **[RFC 9266]** Whited, S., "Channel Bindings for TLS 1.3", RFC 9266, DOI 10.17487/RFC9266, July 2022, <https://www.rfc-editor.org/info/rfc9266/>.
- **[RFC 9421]** Backman, A., Ed., Richer, J., Ed., and M. Sporny, "HTTP Message Signatures", RFC 9421, DOI 10.17487/RFC9421, February 2024, <https://www.rfc-editor.org/info/rfc9421/>.
- **[RFC 9449]** Fett, D., Campbell, B., Bradley, J., Lodderstedt, T., Jones, M., and D. Waite, "OAuth 2.0 Demonstrating Proof of Possession (DPoP)", RFC 9449, DOI 10.17487/RFC9449, September 2023, <https://www.rfc-editor.org/info/rfc9449/>.
- **[X-Wing]** Barbosa, M., Connolly, D., Duarte, J. D., Kaiser, A., Schwabe, P., Varner, K., and B. Westerbaan, "X-Wing: The Hybrid KEM You've Been Looking For", IACR Communications in Cryptology 1(1), 2024, DOI 10.62056/a3qj89n4e, <https://doi.org/10.62056/a3qj89n4e>.

<!-- vale on -->
## Appendix A. Where `ssh-keygen` differs (informative)

`ssh-keygen -Y verify` checks a signature, but does not define one. So a client built on the tool checks a signature against Section 3.2 itself. Acceptance by the stock tools is not sufficient: a message that `age` decrypts and whose signature `ssh-keygen -Y verify` accepts is not thereby a message that a reader accepts, because a reader makes every check of Sections 3.2 and 12.3. `ssh-keygen -Y verify` accepts these forms, which Section 3.2 refuses:

- a BEGIN line ending in CRLF;
- whitespace anywhere in the base64;
- other line lengths;
- a NUL before the final LF;
- anything after the END line;
- version 0;
- `sha256`;
- a non-empty reserved field;
- a string that ends in a NUL and that no signature covers;
- an ECDSA number with leading zero bytes, up to 2,049 bytes in all.

The tool's builds also differ from Sections 3.2 and 4.1:

- **An Ed25519 signature's R.** OpenSSH's own Ed25519 from 10.6p1, libsodium's, used where libcrypto has none, refuses the neutral R. That Ed25519 accepts R with a point of order 2 or 4 added, and refuses R with a point of order 8 added.
- **An Ed25519 signature's S.** `ssh-keygen` accepts S + L before 10.3p1 on OpenSSL's Ed25519, and before 10.4p1 on its own Ed25519.
- **An Ed25519 key.** OpenSSH before 10.6p1 accepts small-order and non-canonical keys. So a client checks Ed25519 keys itself.
- **A P-256 key's coordinates.** OpenSSH up to 10.2p1 refuses a coordinate of 128 bits or fewer, or of n − 1 or more. OpenSSH from 10.3p1 accepts such a coordinate.
- **A P-256 key at all.** OpenSSH built without OpenSSL reads no P-256 key, `sk-ecdsa-sha2-nistp256@openssh.com` included. So a client built on such an OpenSSH does not verify every type that Section 4.1 defines.
- **A security key at all.** OpenSSH built without security-key support (`--disable-security-key`) reads neither security-key type. So a client built on such an OpenSSH does not verify every type that Section 4.1 defines.
- **A security key's signature.** `ssh-keygen -Y verify` accepts flags without user presence, and accepts a `webauthn-sk-ecdsa-sha2-nistp256@openssh.com` signature for an `sk-ecdsa-sha2-nistp256@openssh.com` key, in an SSHSIG and on a certificate. So a client built on the tool reads the signature's type and flags itself.
- **Certificates.** `ssh-keygen -Y verify` accepts a certificate with a second principal, a critical option, extensions out of order or given twice, or a validity of `forever`. The tool checks no key id, and knows a serial only through a revocation list. So a client built on the tool reads those fields from the certificate itself.

Go's libraries also differ from Section 4.1:

- **An Ed25519 key.** `crypto/ed25519` accepts small-order and non-canonical keys. So a client on that library checks Ed25519 keys itself.
- **A P-256 key's coordinates.** `golang.org/x/crypto/ssh` accepts a coordinate of 128 bits or fewer, or of n − 1 or more.

## Appendix B. Collected ABNF

Every rule of this document, in alphabetical order. A rule that this document borrows from another document is given as prose (Section 2.2). The core rules of RFC 5234 Appendix B are not repeated.

```abnf
account-id                 = 1*32( %x61-7A / DIGIT / "-" )
acl-entry                  = "*" / address
address                    = address-form "_" 64base64url-char
address-form               = %s"d"   ; the one form this version defines
address-param              = "address" BWS "=" BWS ( address / DQUOTE address DQUOTE )
adopt-key                  = %s"dra1_" ( 1*254( 4base64url-char ) [ 2base64url-char / 3base64url-char ]
                                     / 2base64url-char / 3base64url-char )   ; at most 1,024 bytes
age-recipient              = %s"age" *bech32-hrp-char "1" 6*bech32-char
base64                     = *( 4base64-char ) [ base64-final ]
base64-char                = ALPHA / DIGIT / "+" / "/"
base64-char-by-16          = %s"A" / %s"Q" / %s"g" / %s"w"   ; its value a multiple of 16
base64-char-by-4           = %s"A" / %s"E" / %s"I" / %s"M" / %s"Q" / %s"U" / %s"Y"
                             / %s"c" / %s"g" / %s"k" / %s"o" / %s"s" / %s"w"
                             / "0" / "4" / "8"   ; its value a multiple of 4
base64-final               = 2base64-char base64-char-by-4 "="
                             / base64-char base64-char-by-16 "=="
base64-nonempty            = 1*( 4base64-char ) [ base64-final ] / base64-final
base64-token               = 1*( 4( ALPHA / DIGIT / "+" ) )   ; base64 that is a token
base64url-char             = ALPHA / DIGIT / "-" / "_"
bech32-char                = "0" / %x32-39 / %x61 / %x63-68 / %x6A-6E / %x70-7A
                             ; BIP 173's alphabet: no 1, b, i or o
bech32-hrp-char            = %x21-40 / %x5B-7E   ; printable ASCII but A-Z
BWS                        = <BWS, see [RFC 9110], Section 5.6.3>
capability-name            = %x61-7A *63( %x61-7A / DIGIT / "_" )
content-range-206          = "bytes" SP range-number "-" range-number "/" range-number
dns-char                   = %x61-7A / DIGIT
dns-label                  = dns-char [ *61( dns-char / "-" ) dns-char ]
dns-name                   = dns-label *( "." dns-label )   ; at most 253 characters
domain                     = domain-label 1*( "." domain-label )
domain-label               = ( ALPHA / DIGIT ) [ *61( ALPHA / DIGIT / "-" ) ( ALPHA / DIGIT ) ]
envelope-line              = 1*( %x00-09 / %x0B-FF ) LF   ; the envelope (Section 9.1)
full-date                  = <full-date, see [RFC 3339], Section 5.6>
identity-document          = %s"dromas-v1" LF key-type SP base64-nonempty LF
implementation-text        = 1*128%x21-7E
IPv6address                = <IPv6address, see [RFC 3986], Section 3.2.2>
key-name                   = 1*( %x21-2B / %x2D-3F / %x41-7E )   ; printable ASCII, no "," or "@"
key-type                   = key-name [ "@" domain ]   ; at most 64 characters
lowhexdig                  = DIGIT / %x61-66   ; HEXDIG in lowercase
message-id                 = 64lowhexdig
msg-id                     = 8lowhexdig "-" 4lowhexdig "-" 4lowhexdig "-" 4lowhexdig "-"
                             12lowhexdig   ; the UUID of [RFC 9562], Section 4, in lowercase
msg-namespace              = %s"dromas-msg-v1:" address
not-after-param            = "not_after" BWS "=" BWS DQUOTE time DQUOTE
OWS                        = <OWS, see [RFC 9110], Section 5.6.3>
padding                    = *"."   ; Section 9.3
pass-authorization         = %s"dromas-pass" SP
                             %s"address=" DQUOTE address DQUOTE "," SP
                             %s"not_after=" DQUOTE time DQUOTE "," SP
                             %s"signature=" DQUOTE base64-nonempty DQUOTE
pass-credentials           = pass-scheme 1*SP [ pass-gap ] pass-params [ pass-gap ]
pass-gap                   = 1*( OWS "," ) OWS   ; empty list elements skipped
pass-namespace             = %s"dromas-pass-v1:" address
pass-params                = address-param pass-gap not-after-param pass-gap signature-param
                             / address-param pass-gap signature-param pass-gap not-after-param
                             / not-after-param pass-gap address-param pass-gap signature-param
                             / not-after-param pass-gap signature-param pass-gap address-param
                             / signature-param pass-gap address-param pass-gap not-after-param
                             / signature-param pass-gap not-after-param pass-gap address-param
pass-scheme                = "dromas-pass"
pass-statement             = %s"dromas-pass-v1" LF address LF server-name LF time LF
plaintext                  = envelope-line ssh-signature padding
policy-version             = version-number "." version-number
prekey-namespace           = %s"dromas-prekey-v1:" address
prekey-statement           = %s"dromas-prekey-v1" LF address LF rank LF serial LF
                             age-recipient LF time LF
range-asked                = "bytes=" 1*DIGIT "-"
range-number               = "0" / %x31-39 *DIGIT   ; no leading zero
rank                       = "0" / serial
revocation-of-address      = %s"dromas-revoke-v1" LF address LF
revocation-of-certificates = %s"dromas-revoke-certs-v1" LF address LF serial LF
revoke-certs-namespace     = %s"dromas-revoke-certs-v1:" address
revoke-namespace           = %s"dromas-revoke-v1:" address
serial                     = %x31-39 *15DIGIT   ; no leading zero
server-host                = dns-name / "[" IPv6address "]"   ; in lowercase
server-name                = server-host [ ":" server-port ]
server-port                = %x31-39 *4DIGIT   ; no leading zero, at most 65535,
                                                 ; and neither 80 nor 443
signature-even             = signature-groups LF
signature-groups           = *16( 4base64-char ) ( 4base64-char / base64-final )
signature-line             = 70base64-char LF
signature-odd              = 68base64-char
                             ( 2base64-char LF 2base64-char [ signature-groups ]
                             / 2base64-char LF base64-char-by-4 "="
                             / base64-char base64-char-by-16 LF "==" ) LF
                             ; a group of 4 split across the last two lines
signature-param            = "signature" BWS "=" BWS
                             ( base64-token / DQUOTE base64-nonempty DQUOTE )
signature-text             = *( 2signature-line ) ( signature-even / signature-odd )
                             ; two lines of 70 hold 35 groups of 4
ssh-signature              = %s"-----BEGIN SSH SIGNATURE-----" LF
                             signature-text
                             %s"-----END SSH SIGNATURE-----" LF
statement-hash             = 64lowhexdig
time                       = full-date %s"T" time-hour ":" time-minute ":" time-sec %s"Z"
time-hour                  = <time-hour, see [RFC 3339], Section 5.6>
time-minute                = <time-minute, see [RFC 3339], Section 5.6>
time-sec                   = %x30-35 DIGIT   ; 00 to 59
version-number             = "0" / %x31-39 *DIGIT
```
