HTTP Message Signatures by RFC 9421: sign a request or a response, and verify the signatures of one.
A message is a request or response map like those of wary-fetch. A request has :method, :url, :headers and :body, and a response has :status, :headers and :body. Header names can be in any case. A header's value is text or a vector of texts, and the body is text, bytes or nil. You can hide any of these texts, and a key's PEM or secret, with wary-fetch's secret/hide.
A key is a map with a :keyid, an :alg (one of algorithms) and the key material, one of these:
Without an :alg, the algorithm follows from the kind of key, e.g. rsa-v1_5-sha256 for RSA as in Mastodon. For verifying, a key map can also have the :public-pem of its private key, as generate-key returns it.
The functions that sign and verify return values on the JVM and promises in ClojureScript, since WebCrypto only has promises. Chain them with wary-fetch's async/then to write code for both.
HTTP Message Signatures by RFC 9421: sign a request or a response, and verify the signatures of one. A message is a request or response map like those of wary-fetch. A request has :method, :url, :headers and :body, and a response has :status, :headers and :body. Header names can be in any case. A header's value is text or a vector of texts, and the body is text, bytes or nil. You can hide any of these texts, and a key's PEM or secret, with wary-fetch's secret/hide. A key is a map with a :keyid, an :alg (one of algorithms) and the key material, one of these: - :pem, a key in PEM: SPKI or PKCS#8, or PKCS#1 and SEC1 - :jwk, a JWK as a map - :secret, the bytes or the text of a shared secret for hmac-sha256 - :key, a webcrypto-clj key, e.g. a CryptoKey that a page keeps unextractable Without an :alg, the algorithm follows from the kind of key, e.g. rsa-v1_5-sha256 for RSA as in Mastodon. For verifying, a key map can also have the :public-pem of its private key, as generate-key returns it. The functions that sign and verify return values on the JVM and promises in ClojureScript, since WebCrypto only has promises. Chain them with wary-fetch's async/then to write code for both.
Signatures of draft-cavage-http-signatures as the fediverse uses them: the Signature field that Mastodon and the servers that talk to it send.
The fediverse uses a profile of the draft that no version describes exactly: RSA-SHA256 over a few headers, with a little of the twelfth and last version (from 2019), such as hs2019 and (created). This namespace implements that profile and nothing else of the draft. It uses the key maps, results and errors of the root namespace, and its functions also return values on the JVM and promises in ClojureScript.
Every fediverse server accepts these signatures, but only some accept those of RFC 9421. To sign for both, give httpsig/sender the :signers [sign httpsig/sign].
Signatures of draft-cavage-http-signatures as the fediverse uses them: the Signature field that Mastodon and the servers that talk to it send. The fediverse uses a profile of the draft that no version describes exactly: RSA-SHA256 over a few headers, with a little of the twelfth and last version (from 2019), such as hs2019 and (created). This namespace implements that profile and nothing else of the draft. It uses the key maps, results and errors of the root namespace, and its functions also return values on the JVM and promises in ClojureScript. Every fediverse server accepts these signatures, but only some accept those of RFC 9421. To sign for both, give httpsig/sender the :signers [sign httpsig/sign].
Digest Fields by RFC 9530: the Content-Digest and Repr-Digest of a body, and the Want- fields that ask for them.
The library computes sha-256 and sha-512, the two algorithms in RFC 9530's registry that aren't deprecated. RFC 9530 forbids the others wherever an attacker may be involved.
Digest Fields by RFC 9530: the Content-Digest and Repr-Digest of a body, and the Want- fields that ask for them. The library computes sha-256 and sha-512, the two algorithms in RFC 9530's registry that aren't deprecated. RFC 9530 forbids the others wherever an attacker may be involved.
Verifying the signatures of Ring requests, as a function (e.g. for a Pedestal interceptor) and as middleware.
A Ring request has the parts of its URL under separate keys and its body in a stream. So before verifying a signed request, these functions turn it into a message with its whole URL and its body read into bytes. The handler then gets the request with a new stream of those bytes (the bytes themselves in ClojureScript), so it can read the body again.
Verifying the signatures of Ring requests, as a function (e.g. for a Pedestal interceptor) and as middleware. A Ring request has the parts of its URL under separate keys and its body in a stream. So before verifying a signed request, these functions turn it into a message with its whole URL and its body read into bytes. The handler then gets the request with a new stream of those bytes (the bytes themselves in ClojureScript), so it can read the body again.
Structured fields by RFC 9651: the values of HTTP fields such as Signature-Input and Content-Digest as data.
A field is a List, a Dictionary or an Item. The values of RFC 9651 are these in Clojure:
To serialize, an item without parameters can be its value alone, and Parameters and a Dictionary can be maps.
Structured fields by RFC 9651: the values of HTTP fields such as Signature-Input and Content-Digest as data. A field is a List, a Dictionary or an Item. The values of RFC 9651 are these in Clojure: - an Integer, a String or a Boolean is a number, a string or a boolean - a Token is a symbol, e.g. sha-256 - a Byte Sequence is bytes, as webcrypto-clj has them - a Date is an inst of whole seconds - a Decimal is a record that decimal makes, since JavaScript can't tell 1.0 from 1 - a Display String is a record that display-string makes, to tell it from a String - an Item is a pair of its value and its parameters - an Inner List is a pair of a vector of items and its parameters - a List is a vector of items and inner lists - a Dictionary or Parameters are a vector of pairs of a key and a value, which keeps their order To serialize, an item without parameters can be its value alone, and Parameters and a Dictionary can be maps.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |