Expand description
HTTP Message Signatures (RFC 9421).
The successor to the draft-cavage signatures ActivityPub grew up on. Where
the draft signs a list of header names against an ad-hoc string, RFC 9421
signs components — including derived ones like @method and
@target-uri — against a canonical signature base, and carries the covered
list in its own Signature-Input header so a verifier reconstructs exactly
what was signed.
Mastodon 4.7 sends these as a fallback: a request goes out with a cavage
signature first, and is retried with an RFC 9421 one if the peer answers
400 or 401. It covers ("@method" "@target-uri" "content-digest") for a
request with a body and ("@method" "@target-uri") for one without, which
is what sign_request produces.
Structs§
- Signed
Headers - Headers produced by
sign_request, to attach to the outgoing request.
Enums§
- Algorithm
- A signature algorithm this module can produce and check.
- Signing
Key - The private key a signature is made with.
- Verifying
Key - The public key a signature is checked against.
Functions§
- content_
digest - The
Content-Digestfield value for a body: a structured-field dictionary whosesha-256member holds the digest as a byte sequence (RFC 9530). - covered_
components - The components a
Signature-Inputclaims to cover. - created_
at - The
createdparameter of aSignature-Input, as a Unix timestamp. - expires_
at - The
expiresparameter of aSignature-Input, as a Unix timestamp. - key_id
- The
keyidparameter of aSignature-Input: the URI identifying the key that signed, which the verifier resolves to a public key. - sign_
request - Sign an outgoing request.
- sign_
response - Sign a response over
@statusandcontent-digest, as Linzer signs one (Linzer.sign!(response, key:, components: %w(@status content-digest))) and the Fediverse Auxiliary Service Provider protocol has both sides sign theirs. - verify_
request - Verify an RFC 9421 signature on an inbound request.
- verify_
response - Verify an RFC 9421 signature on a response, given its status, the
Signature-InputandSignaturefield values, and its header fields.