Commit 4de648e
* feat(signing): SigningProvider Protocol for KMS-backed signing (#283)
Decouples the RFC 9421 request-signing profile from in-process key
storage so KMS / HSM / Vault deployments can plug in without forking
the signer or pulling private material out of the managed store at boot.
* `SigningProvider` Protocol — async `sign(signature_base) -> bytes`,
`key_id() -> str`, `algorithm() -> Literal["ed25519","ecdsa-p256-sha256"]`.
Contract docstring covers lazy init, public-key type-checking,
rotation tripwire, key separation by `adcp_use`, and fingerprint
redaction.
* `InMemorySigningProvider` — default adapter; validates Ed25519 vs.
EC, EC curve = SECP256R1, and key_id non-empty at construction.
* `async_sign_request(provider=...)` — async entry point sharing the
canonicalization spine (`_prepare_signature`) with the sync
`sign_request`, so both paths produce byte-identical
Signature-Input.
* `pem_to_adcp_jwk(pem, *, kid, purpose, password=None)` — derives
the public JWK for KMS adopters whose private half never leaves the
managed store. Accepts both PKCS#8 private and SPKI public PEMs.
* RFC 8941 §3.3.3 escaping fix at `signer.py:_escape_sf_string` —
applies to `keyid`, `nonce`, `tag`. Rejects characters outside
printable ASCII 0x20-0x7E to close header-injection / parser-
divergence vectors at non-httpx integrators.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(signing): validate sig label as RFC 8941 sf-key (#283)
The `label` kwarg on `sign_request` / `async_sign_request` is a public
input that lands unquoted in both the `Signature-Input` and
`Signature` headers. Without validation, a CRLF or other non-token
character in the label would inject extra header bytes (at non-httpx
integrators that don't sanitize embedded line terminators) or produce
a label that conformant verifiers parse differently from this
serializer.
Add `_validate_sf_key()` enforcing the RFC 8941 §3.1.2 token grammar:
must start with `[a-z*]`, then `[a-z0-9_\-.*]`. Applied at the entry
of `_prepare_signature` so both sync and async signers are covered.
Same parser-divergence / header-injection class as the
`keyid`/`nonce`/`tag` escaping fix already in this PR — just for the
remaining unguarded input.
Also adds the SPKI-public-key RSA rejection test for `pem_to_adcp_jwk`
that was missing from the previous coverage round.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d3e1a0f commit 4de648e
5 files changed
Lines changed: 1038 additions & 45 deletions
File tree
- src/adcp/signing
- tests/conformance/signing
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| |||
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
| 213 | + | |
208 | 214 | | |
209 | 215 | | |
210 | 216 | | |
| |||
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
299 | 306 | | |
300 | 307 | | |
301 | 308 | | |
| 309 | + | |
302 | 310 | | |
303 | 311 | | |
| 312 | + | |
304 | 313 | | |
305 | 314 | | |
306 | 315 | | |
| |||
310 | 319 | | |
311 | 320 | | |
312 | 321 | | |
| 322 | + | |
313 | 323 | | |
314 | 324 | | |
315 | 325 | | |
| |||
330 | 340 | | |
331 | 341 | | |
332 | 342 | | |
| 343 | + | |
333 | 344 | | |
334 | 345 | | |
335 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
81 | 74 | | |
82 | 75 | | |
83 | 76 | | |
84 | | - | |
| 77 | + | |
85 | 78 | | |
86 | 79 | | |
87 | 80 | | |
| |||
91 | 84 | | |
92 | 85 | | |
93 | 86 | | |
94 | | - | |
95 | 87 | | |
96 | 88 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
108 | 94 | | |
109 | 95 | | |
110 | 96 | | |
| |||
115 | 101 | | |
116 | 102 | | |
117 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
118 | 129 | | |
119 | 130 | | |
120 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
121 | 215 | | |
122 | 216 | | |
123 | 217 | | |
| |||
0 commit comments