What
/dims5/ requires an HMAC-SHA256 signature over the commands, the image URL, and the canonical query. A caller in any language has to reproduce that message byte for byte, and today nothing in this repository lets one do so without reading C.
Three pieces:
- A C library that exposes the signing rules, so a caller links it rather than reimplementing it.
- A Go client.
- A Java client.
Why
src/signature.c holds the rules and src/signature.h declares them, but every function takes an apr_pool_t and the header includes mod_dims.h, which pulls in httpd. A caller outside the module cannot use it.
test/endurance/sign.c reimplements the same rules against OpenSSL for the soak client. Its header says so: "Every function here reproduces what the module checks. A change to the module's rules that this file does not follow appears in a run as a signed request the service refuses." That is a second copy, and a third copy exists in go-dims.
The message format is easy to get wrong. dims_signed_query orders the parameters by name, percent encodes each one with uppercase hex, writes a space as a plus, and leaves out sig, url, eurl, _keys, and download. A client that sorts differently or escapes a tilde produces a signature the module refuses, and the failure says only "Key mismatch".
Scope
The C library. Split the pool and httpd types out of signature.h so the rules take plain C strings and a caller-supplied buffer. The module keeps its pool-based wrapper. Ship a header and a static library, and a dims-sign command that signs a URL from the shell.
Go. A package with one exported function that takes the key, the base URL, the commands, the image URL, and the query, and returns the signed URL. go-dims already has an implementation to compare against.
Java. The same shape, using javax.crypto.Mac with HmacSHA256.
Verify
The signature is portable between mod_dims and go-dims, and a test asserts it. Extend that: one fixture file of message and signature pairs, read by the C, Go, and Java test suites. A client that disagrees fails its own suite rather than a soak run.
Cover the cases that differ between naive implementations:
- a query parameter with several values
- a parameter name that sorts after another only when compared byte by byte
- a space, a plus, and a tilde in a value
- a value holding a percent sign
_keys naming a parameter that is absent
Notes
docs/docs/endpoints/dims5.md documents the URL shape. The signing rules belong beside it once a caller can follow them.
What
/dims5/requires an HMAC-SHA256 signature over the commands, the image URL, and the canonical query. A caller in any language has to reproduce that message byte for byte, and today nothing in this repository lets one do so without reading C.Three pieces:
Why
src/signature.cholds the rules andsrc/signature.hdeclares them, but every function takes anapr_pool_tand the header includesmod_dims.h, which pulls in httpd. A caller outside the module cannot use it.test/endurance/sign.creimplements the same rules against OpenSSL for the soak client. Its header says so: "Every function here reproduces what the module checks. A change to the module's rules that this file does not follow appears in a run as a signed request the service refuses." That is a second copy, and a third copy exists in go-dims.The message format is easy to get wrong.
dims_signed_queryorders the parameters by name, percent encodes each one with uppercase hex, writes a space as a plus, and leaves outsig,url,eurl,_keys, anddownload. A client that sorts differently or escapes a tilde produces a signature the module refuses, and the failure says only "Key mismatch".Scope
The C library. Split the pool and httpd types out of
signature.hso the rules take plain C strings and a caller-supplied buffer. The module keeps its pool-based wrapper. Ship a header and a static library, and adims-signcommand that signs a URL from the shell.Go. A package with one exported function that takes the key, the base URL, the commands, the image URL, and the query, and returns the signed URL. go-dims already has an implementation to compare against.
Java. The same shape, using
javax.crypto.MacwithHmacSHA256.Verify
The signature is portable between mod_dims and go-dims, and a test asserts it. Extend that: one fixture file of message and signature pairs, read by the C, Go, and Java test suites. A client that disagrees fails its own suite rather than a soak run.
Cover the cases that differ between naive implementations:
_keysnaming a parameter that is absentNotes
docs/docs/endpoints/dims5.mddocuments the URL shape. The signing rules belong beside it once a caller can follow them.